CentOS7配置默认网关 |
您所在的位置:网站首页 › centos7怎么看路由表 › CentOS7配置默认网关 |
背景信息 在Vmware里安装CentOS7后,通过route add default gw 192.168.209.2 dev ens33命令配置了网关,但是重启后失效,导致重启后访问不了外网,因此,需要写成静态配置,避免每次重启后都需要配置。 查看默认路由 [root@bigdata01 ~]# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0 192.168.209.0 0.0.0.0 255.255.255.0 U 100 0 0 ens33配置步骤 1、编辑/etc/sysconfig/network-scripts/ifcfg-ens33文件 vi /etc/sysconfig/network-scripts/ifcfg-ens33 2、在文件末尾添加如下信息 GATEWAY=192.168.209.2 (说明要到达相同的目的也可以在/etc/rc.local文件末尾添加route add default gw 192.168.209.2 dev ens33)3、重启网卡 ifdown ens33 ifup ens33 4、查看路由 [root@bigdata01 ~]# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.209.2 0.0.0.0 UG 100 0 0 ens33 192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0 192.168.209.0 0.0.0.0 255.255.255.0 U 100 0 0 ens33可以看出增加了一条路由 |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |