How to add routing in Linux?
Methods to add routes under Linux:
1: Use the route command to add routes
Use the route command to add routes, restart the machine or The routing will become invalid after the network card is restarted. Method:
//添加到主机的路由 # 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
2: Method to set up permanent routing under Linux:
1. Add
## in /etc/rc.local #Method:route add -net 192.168.3.0/24 dev eth0 route add -net 192.168.2.0/24 gw 192.168.3.254
any net x.x.x.x/24 gw y.y.y.y
any net x.x.x.x/24 gw y.y.y.y
# echo "1" >/proc/sys/net/ipv4/ip_forward (临时) # vi /etc/sysctl.conf --> net.ipv4.ip_forward=1 (永久开启)
The above is the detailed content of How to add routing in linux. For more information, please follow other related articles on the PHP Chinese website!