linux如何配置靜態路由(ubunt14。04實測)
阿新 • • 發佈:2019-02-08
1、在/etc/network/裡,配置interfaces文件,例項如下(紅色字型):
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 10.100.2.154
network 10.100.2.0
netmask 255.255.255.0
up route add -net10.0.0.0 netmask 255.0.0.0 gw 10.100.2.254 eth0
up route add -net192.168.0.0 netmask 255.255.0.0 gw 10.100.2.254 eth0
2、 修改rc.local,寫在exit 0 前面
sudo vim /etc/rc.local
route add –net 0.0.0.0 netmask0.0.0.0 gw 113.61.47.115 dev eth1 //填寫自己的閘道器啊
route add –net 10.27.0.0netmask 255.255.0.0 gw 10.26.254.1 dev eth0 //dev表示指定網絡卡,eth0表示網絡卡1
3、 /etc/sysconfig/static-router : any net x.x.x.x/24 gw y.y.y.y