本文摘自PHP中文网,作者藏色散人,侵删。

linux怎么添加路由?
linux下添加路由的方法:
一:使用 route 命令添加
使用route 命令添加的路由,机器重启或者网卡重启后路由就失效了,方法:
1 2 3 4 5 6 7 8 9 10 11 | # route add ?Chost 192.168.168.110 dev eth0
# route add ?Chost 192.168.168.119 gw 192.168.168.1
# route add ?Cnet IP netmask MASK eth0
# route add ?Cnet IP netmask MASK gw IP
# route add ?Cnet IP/24 eth1
# route add default gw IP
# route del ?Chost 192.168.168.110 dev eth0
|
二:在linux下设置永久路由的方法:
1.在/etc/rc.local里添加
方法:
1 2 | route add -net 192.168.3.0/24 dev eth0
route add -net 192.168.2.0/24 gw 192.168.3.254
|
2.在/etc/sysconfig/network里添加到末尾
方法:GATEWAY=gw-ip 或者 GATEWAY=gw-dev
3./etc/sysconfig/static-router :
1 | any net x.x.x.x/24 gw y.y.y.y
|
linux 添加永久静态路由
Linux 的路由功能:
# route 命令添加的路由,机器重启或者网卡重启后就没掉了,在linux下设置永久路由的方法:
1.在/etc/rc.local里添加
2.在/etc/sysconfig/network里添加到末尾
3./etc/sysconfig/static-router :
any net x.x.x.x/24 gw y.y.y.y
开启 IP 转发:
1 2 | # echo "1" >/proc/sys/net/ipv4/ip_forward (临时)
# vi /etc/sysctl.conf --> net.ipv4.ip_forward=1 (永久开启)
|
相关推荐:《linux教程》
以上就是linux怎么添加路由的详细内容,更多文章请关注木庄网络博客!
相关阅读 >>
ubuntu如何卸载软件?
Linux怎么下载安装软件?
存放Linux基本命令的是什么目录
什么是Linux?Linux怎么使用?
为什么黑客都用Linux
Linux如何为用户添加root权限
Linux如何获取cpu信息?
Linux如何返回上一级目录
Linux如何实现禁止ping的实例代码分享
如何理解迁云工具的cli参数以及使用方法
更多相关阅读请进入《Linux》频道 >>
转载请注明出处:木庄网络博客 » linux怎么添加路由