Linux route命令
[root@linux ~]# route del -net 169.254.0.0 netmask 255.255.0.0 dev eth0
[root@linux ~]# route add -net 192.168.100.0 netmask 255.255.255.0 dev eth0
# 透过 route add 来增加一个路由!请注意,这个路由必须要能够与你互通。
[root@linux ~]# route add default gw 192.168.10.30(添加默认路由)
linux下添加好路由后,仅在当前有效,在重启后无效
需要在/etc/rc.local中将路由命令添加进去
另一个添加永久路由文件 ,/etc/sysconfig/static-routes
any net 192.168.10.0/24 gw 192.168.8.1
any net 192.168.10.0 netmask 255.255.255.0 gw 192.168.8.1
如果在 rc.local 中添加路由会造成NFS无法自动挂载问题,所以使用static-routes的方法是最好的。无论重启系统和service network restart 都会生效。
WINDOWS下的route命令
简单的的操作如下,
查看路由状态:routeprint
只查看ipv4(ipv6)路由状态:route print-4(-6)
route add 192.168.20.0 mask 255.255.255.0192.168.10.1
route -p add 192.168.20.0 mask 255.255.255.0192.168.10.1 (添加永久路由)
route delete 192.168.20.0 mask255.255.255.0
转载于:https://blog.51cto.com/552627/1910601