27, routing route


In preference to the network card configuration, but restart or reboot the network card fails to boot from the start to join the best service in the /etc/rc.local file;

27.1, add a network route:

Destination network, destination network mask, gateway, network card;

Network addressing the routing table to route preference;

The host automatically generated automatically direct route (next hop 0.0.0.0 may facilitate interconnection with the network host) and a default route (Internet convenient for terminal equipment) are arranged according to the network card and the gateway ip;

(Also generates direct routes between routers, the address must be specified particularly surprised, the default route is mainly used at the end of the routing device)

route add -just 192.168.1.0/24 gw 192.168.1.1 eth0

route del -net 192.168.1.0/24 gw 192.168.1.1 eth0

27.2, add a default route information:

Specify the default gateway (plus the name of the NIC, facilitate the distinction; may not add, because the distinction between network segments),

[Root @ centos6 ~] # route del default gw 192.168.2.253 eth1 # remove the default gateway

route add default gw 192.168.2.253 eth1 # Add a default gateway

[Root @ centos6 ~] # route -n # Display the routing information

Kernel IP routing table

Destination Gateway Genmask Flags Metric Ref Use Iface

192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1 # direct routes, essential, represents the current segment may pass;

192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0

169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth1

169.254.0.0 0.0.0.0 255.255.0.0 U 1003 0 0 eth0

0.0.0.0 192.168.2.253 0.0.0.0 UG 0 0 0 eth1 # default gateway (default route), destination network and mask are both 0.0.0.0 network on behalf of all, the general configuration for terminal equipment);

Guess you like

Origin www.cnblogs.com/LiuChang-blog/p/12313550.html