我试图改变默认路由到eth2我现在的路由-no / p–
Destination Gateway Genmask Flags Metric Ref Use Iface 10.235.4.0 * 255.255.255.0 U 0 0 0 eth3 10.235.3.0 * 255.255.255.0 U 0 0 0 eth2 10.235.2.0 * 255.255.255.0 U 0 0 0 eth0 169.X.0.0 * 255.255.0.0 U 0 0 0 eth3 default 10.235.4.1 0.0.0.0 UG 0 0 0 eth3
IP ro sh – 输出
# ip ro sh 10.235.4.0/24 dev eth3 proto kernel scope link src 10.235.4.21 10.235.3.0/24 dev eth2 proto kernel scope link src 10.235.3.21 10.235.2.0/24 dev eth0 proto kernel scope link src 10.235.2.21 169.x.0.0/16 dev eth3 scope link default via 10.235.4.1 dev eth3
我想要做的是
> Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 10.235.4.0 * 255.255.255.0 U 0 0 0 eth3 10.235.3.0 * 255.255.255.0 U 0 0 0 eth2 10.235.2.0 * 255.255.255.0 U 0 0 0 eth0 169.x.0.0 * 255.255.0.0 U 0 0 0 eth3 default 10.235.2.1 0.0.0.0 UG 0 0 0 eth2
我尝试了不同的方式在/ etc / sysconfig / network中添加“gatewaydev = eth2”。
b>通过命令添加路由eth2,删除eth3路由表项。
服务networking重新启动后,回到第一个输出。
帮我谢谢
只需在/ etc / sysconfig / network中添加/replace默认的网关IP地址
GATEWAY=10.235.2.1
然后重新启动新的networking服务
# service network restart
您必须先在eth2上从10.235.2.0networking获得地址,然后才能更改GATEWAY=值。
打开/ etc / sysconfig / network文件:
#vi /etc/sysconfig/network
设置GATEWAY = {路由器IP]
GATEWAY=10.235.2.1
您需要重新启动networking服务:
# /etc/init.d/networking restart
我倾向于将网关添加到相应接口的/ etc / sysconfig / network-scripts / ifcfg-ethXconfiguration文件中,例如:
BOOTPROTO=none DEVICE=eth0 ONBOOT=yes SLAVE=no IPADDR=10.20.30.40 NETMASK=255.255.255.0 GATEWAY=10.20.30.1 USERCTL=no BROADCAST=10.20.30.255
我倾向于不把它放在/ etc / sysconfig / network中,尽pipe你当然可以。 我做了很多非常复杂的绑定configuration,如果所有的文件都在同一个地方,它会更容易。
如果像我这样做,不要在其他IFCFG文件中声明网关接口。 它将按顺序读取它们,每次重置网关,并且不会得到预期的行为。