Get the App
SLTechnology News&Howtos  ›  Servers  › 

The method of adding Route under ​ linux

Shulou Source: shulou.com Published: 2022-06-03 05:48:53 10月25日 Update

One: use the route command to add

The route added using the route command becomes invalid after the machine is rebooted or the network card is restarted. Method:

/ / routes added to the host # route add-host 192.168.168.110 dev eth0# route add-host 192.168.168.119 gw 192.168.168.1Accord / routes added to the network # route add-net IP netmask MASK eth0# route add-net IP netmask MASK gw IP# route add-net IP/24 eth2// add default gateway # route add default gw IP// delete route # route del-host 192.168.168.110 dev eth0

Second: the method of setting permanent route under linux:

1. Add to / etc/rc.local

Methods:

Route add-net 192.168.3.0 dev eth0route add 24 dev eth0route add-net 192.168.2.0 Universe 24 gw 192.168.3.254

two。 Add to the end in / etc/sysconfig/network

Method: GATEWAY=gw-ip or GATEWAY=gw-dev

3./etc/sysconfig/static-router:

Any net x.x.x.x/24 gw y.y.y.y

Linux add permanent static rout

Routing functions of Linux:

# the route added by the route command is not lost after the machine is rebooted or the network card is rebooted. How to set a permanent route under linux:

1. Add to / etc/rc.local

two。 Add to the end in / etc/sysconfig/network

3./etc/sysconfig/static-router:

Any net x.x.x.x/24 gw y.y.y.y

Enable IP forwarding:

# echo "1" > / proc/sys/net/ipv4/ip_forward (temporary) # vi / etc/sysctl.conf-> net.ipv4.ip_forward=1 (permanently open)

These are the details of how to add routing to linux. Please pay more attention to other related articles!

Tags: Routing method permanent command tail machine network card host content function that is article more gateway network static y.y.y.y Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple MariaDB Linux Microsoft vpn