1. Static routes, dynamic routes, and default routing routers can have dynamic and static routes in two of the routing records in the middle of a table. Dynamic routing is generated automatically based on routing protocols, and static routes are manually configured. The default route is one of the static routes that is manually configured to represent the routing policy that is executed by default when a routing request does not match the routing rule in the routing table. The default route, also known as the default route or default gateway. Dynamic routing can automatically find the optimal path, and neighbor routing can learn to get the routing table, but dynamic routing occupies the line bandwidth and CPU processing time. Static routing is not required CPU processing time also does not occupy the line bandwidth, but this route needs to the terminal PC configuration gateway to achieve, the workload is relatively large.
Static routing Configuration method in 2.redhat/centos (1) using the route command, the machine restarts after the failure of specific see "Linux Routing Configuration Command route learning", the form is as follows:
Route add-net 192.168.0.0/24 GW 192.168.0.1
(2) The use of IP command, machine Restart after the failure of specific see the Linux Network Configuration command IP (ifconfig+route) Summary, the form is as follows:
IP route add 192.168.10.0/24 via 192.168.5.100 Dev eth1
(3) Configure the routing information in the/etc/sysconfig/network file, and after the machine restarts it will add a configuration similar to the following/etc/sysconfig/network:
Default via 192.168.3.1 dev eth0 #192.168.3.1 gateway address for eth0 network card
10.211.6.0/24 via 192.168.3.1 dev eth0
10.0.0.0/ 8 via 10.212.52.1 Dev eth1 #10.212.52.1 gateway address for ETH1 network card
Note: In/etc/sysconfig/network configuration gateway=x.x.x.x represents the default route OH (4) Configure routing information in the/etc/sysconfig/static-routes file, which is still valid after the machine restarts/etc/ Add a configuration similar to the following in Sysconfig/static-routes:
Any net no GW 192.168.3.1 any
net 10.211.6.0/24 GW 192.168.3.1 the Any
net 10.0.0.0 netmask 255.0.0.0 GW 10.212.52.1
Note: The file is not available on the host by default, and it can be because the/etc/init.d/network startup script invokes the file. (5) Configure routing information for the specified network card (/etc/sysconfig/network-scripts/route-interferface), which is still valid after the machine restarts for example, configuring routing information for the ETH0 network card, which is required in/etc/sysconfig/ Network-scripts/route-eth0 to add routing information, here are two configuration formats: a The ordinary way, the form is as follows:
0.0.0.0/0 via 192.168.3.1 Dev eth0
10.211.6.0/24 via 192.168.3.1 Dev eth0
B) Network Mask method
address0=0.0.0.0
netmask0=0.0.0.0
gateway0=192.168.3.1
address1=10.211.6.0
netmask1= 255.255.255.0
gateway1=192.168.3.1
Note: The network segment address and mask are all 0 represent all network segments, that is, the default route. Note: The above is the configuration method in Redhat/centos, if in other Linux distributions, the configuration file may not be the above files. Need to pay attention to OH. (6) The configuration of the route can also be written to the configuration file/etc/sysconfig/network-scripts/interface.route, and the configuration method is the same as the/etc/sysconfig/network-scripts/ Route-interferface (7) The default route can be configured via gateway=x.x.x.x in the NIC configuration file/ETC/SYSCONFIG/NETWORK-SCRIPTS/IFCFG-ETHX.
3. View the machine's routing table information
NETSTAT-NR
route-n
IP route list
IP route show
4. The Routing table Rule example assumes that a machine has two network cards, eth1 configures the private IP address 10.10.89.21,eth0 configures the public network IP address 220.181.91.23. View the routing table information by command as follows:
[@localhost/etc/sysconfig/network-scripts]# route-n
Kernel IP routing table
destination Gateway Genmask Flags Metric Ref use iface
0.0.0.0 220.181.91.254 0.0.0.0 UG 0 0 eth0
10.0.0.0 10.10.89.254 255.128.0.0 UG 0 0 eth1
10.10.89.0 0.0.0.0 255.255.255.0 U 0 0 eth1
192.168.0.0 10.10.89.254 255.255.0.0 UG 0 0 eth1
220.181.91.0 0.0.0.0 255.255.255.0 U 0 0 eth0
The simple analysis is as follows:
10.10.89.0 0.0.0.0 255.255.255.0 U 0 0 eth1
This means that if the destination address of the packet is within the 10.10.89.0/24 range, there is no need for static routing, and it is OK to forward directly via the upper switch. Because the destination address and eth1 in the same network segment, directly through the ARP protocol to obtain the destination machine physical address, directly sent on the OK, do not need a router or gateway forwarding. Where gateway=0.0.0.0 means that you do not need to specify a gateway, send directly on the OK.
220.181.91.0 0.0.0.0 255.255.255.0 U 0 0 eth0
The routing rule is interpreted in the same way.
192.168.0.0 10.10.89.254 255.255.0.0 UG 0 0 eth1
10.0.0.0 10.10.89.254 255.128.0.0 UG 0 0 eth1
If the destination address is a private network segment, then the static route is 10.10.89.254, and the packet goes out from the eth1 NIC.
0.0.0.0 220.181.91.254 0.0.0.0 UG 0 0 eth0
This is the well-known default route or default gateway, which means that when the destination address does not match any of the routing rules, it is sent to the default route. This represents the default gateway address that is sent to the public network, and the packet is sent from eth0. Note: We can use the traceroute command to verify the routing rules above.
Resources See: http://zhaoyuqiang.blog.51cto.com/6328846/1177924 http://www.361way.com/linux-define-static-route/4053.html