您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

linux怎么添加路由

2024/11/11 7:46:57发布33次查看
linux怎么添加路由?
linux下添加路由的方法:
一:使用 route 命令添加
使用route 命令添加的路由,机器重启或者网卡重启后路由就失效了,方法:
//添加到主机的路由# route add –host 192.168.168.110 dev eth0# route add –host 192.168.168.119 gw 192.168.168.1//添加到网络的路由# route add –net ip netmask mask eth0# route add –net ip netmask mask gw ip# route add –net ip/24 eth1//添加默认网关# route add default gw ip//删除路由# route del –host 192.168.168.110 dev eth0
二:在linux下设置永久路由的方法:
1.在/etc/rc.local里添加
方法:
route add -net 192.168.3.0/24 dev eth0route 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 :
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 转发:
# echo "1" >/proc/sys/net/ipv4/ip_forward (临时)# vi /etc/sysctl.conf --> net.ipv4.ip_forward=1 (永久开启)
相关推荐:《linux教程》
以上就是linux怎么添加路由的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product