手机版

centos设置默认网关

时间:2020-05-10 来源:互联网 编辑:宝哥软件园 浏览:

第一生效文件

[root@oldboy ~]# grep -i gate /etc/sysconfig/network-scripts/ifcfg-eth0
GATEWAY=192.168.1.1

第二生效文件

[root@oldboy ~]# grep -i gate /etc/sysconfig/network

GATEWAY=192.168.1.1

第三:命令行有限,且临时生效

查看网关命令:route-n和netstat -n(两个命令都是查看网关的)

[root@oldboy ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     1002   0        0 eth0
0.0.0.0         192.168.1.1     0.0.0.0         UG    0      0        0 eth0
[root@oldboy ~]# netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 eth0
0.0.0.0         192.168.1.1     0.0.0.0         UG        0 0          0 eth0

route add default gw 192.168.1.1

route del default gw 192.168.1.1

route功能很多,不仅仅配置默认网关,网络(静态)路由。

版权声明:centos设置默认网关是由宝哥软件园云端程序自动收集整理而来。如果本文侵犯了你的权益,请联系本站底部QQ或者邮箱删除。

相关文章推荐