1 | < br > |
拓展:其他写法
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | [root@oldboy~] # route add -net 192.168.1.0 netmask 255.255.255.0 dev eth0 #==>指定设备而不是地址。 [root@oldboy~] # route -n Kernel IProuting table Destination Gateway Genmask Flags Metric Ref Use Iface 10.0.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 192.168.1.0 192.168.1.1 255.255.255.0 UG 0 0 0 eth0 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 10.0.0.254 0.0.0.0 UG 0 0 0 eth0 [root@oldboy~] # route del -net 192.168.1.0/24 dev eth0 [root@oldboy~] # route add -net 192.168.1.0/24 dev eth0 [root@oldboy~] # route -n Kernel IProuting table Destination Gateway Genmask Flags Metric Ref Use Iface 10.0.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 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 10.0.0.254 0.0.0.0 UG 0 0 0 eth0 总结: route add-net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.1 route add-net 192.168.1.0 netmask 255.255.255.0 dev eth0 route add-net 192.168.1.0 /24 dev eth0 route del-net 192.168.1.0 /24 dev eth0 特别强调:以上配置在重启网络时都会失效,那么如何让它永久生效呢? |