Linux 系统添加静态路由的方法
1、添加一条默认路由
route add default gw 10.0.0.1 (默认只在内存中生效)
开机自启动可以追加到/etc/rc.local文件里
echo "route add default gw 10.0.0.1" >>/etc/rc.local
2、添加一条静态路由
route add -net 192.168.2.0/24 gw 192.168.2.254
要永久生效的话要这样做:
echo "any net 192.168.2.0/24 gw 192.168.2.254" >>/etc/sysconfig/static-routes
添加到一台主机的静态路由
route add -host 192.168.2.2 gw 192.168.2.254
要永久生效的话要这样做:
echo "any host 192.168.2.2 gw 192.168.2.254 " >>/etc/sysconfig/static-routes
注:Linux 默认没有这个文件 ,得手动创建一个
相关推荐
Charliewolf 2020-06-18
ljbhander 2020-05-11
kanpiaoxue 2019-12-24
yungame 2019-12-07
81971834 2011-08-24
baohuanlove 2019-06-21
yutian0 2015-10-22
kuihan0 2014-06-29
scarecrowbyr 2012-05-27
hfight 2012-01-16
Carlchangxin 2014-11-18
soSoBusy 2017-02-16
HeKing 2013-02-14
ljl 2016-12-30
gglinux 2009-10-27
linkelinux 2007-03-23