Linux System Tips: Two Ways to Add Soft Routes in Linux

  

Method of Adding Soft Routes in Linux One:

route add -net 172.16.6.0 netmask 255.255.255.0 gw 172.16.2.254 dev eth0/*

Add a network 172.16.6.0/24 After 172.16.2.254 eth0 *//* -net increase network -host increase host, netmask subnet mask, gw gateway, dev device, device, here is you Network card name */route del gw 172.16.2.254 /* Delete default gateway 172.16.2.254 */route del -net 172.16.86.0/24 /* Delete default network 172.16.86.0 */route /* Display current routing table */commonly used This is the way, but sometimes you will not work when deleting or a soft route, there will be a hint: SIOCADDRT: can not contact the network, so this method can be used as follows.

Method 2 for adding soft routes in Linux:

The function is the same as above

ip route add 172.16.6.0/24 via 172.16.2.254 dev eth0 ip route Del gw 172.16.2.254 ip route del 172.16.6.0/24 dev eth0ip route

Method of deletion: Add route:

Here is the code snippet:

route add -net 10.0.0.0 netmask 255.0.0.0 dev eth0

Deleting Routes:

The following is a code snippet:

route del -net 10.0.0.0 netmask 255.0.0.0 dev eth0

Add default route:

Here is the code snippet

route add default gw 10.0.0.1

Delete default route:

Here is the code Fragment:

route del default gw 10.0.0.1

or

Here is the code snippet:

route del default

under linux Method of adding a route:

Adding a route using the route command

Adding a route using the route command, restarting the machine or restarting the network card By default, the method:

The following is a code snippet:

//Adding a route to the host

# route add –host 192.168.168.110 dev eth0

# route add –host 192.168.168.119 gw 192.168.168.1

//Adding routes to the network

# route add –net IP netmask MASK eth0

# Route add –net IP netmask MASK gw IP

# route add –net IP/24 eth1

//Add default gateway

# route add default gw IP

//Delete route

# route del –host 192.168.168.110 dev eth0

Set permanent route method under linux:

1. In /etc/Add

to rc.local The following is a code snippet:

route add -net 192.168.3.0/24 dev eth0 route add -net 192.168.2.0/24 gw 192.168.3.254

2. Add to the end of /etc/sysconfig/network

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

3./etc/sysconfig/static-router :

Here is Code Snippet:

any net x.x.x.x/24 gw y.y.y.y

The method of adding soft routing in Linux should be able to master and understand, and we will continue to sort out relevant content for your reference.

Copyright © Windows knowledge All Rights Reserved