Introduction to route usage
Print the current routing table: route -n common parameters: add: Add a new route. del: Deletes a route. -net: The destination address is a network. -host: The destination address is a host. netmask: When you add a network route, you need to use a netmask.           GW: Route packets through the gateway. Note that the gateway you specify must be able to be reached. metric: Sets the route hop count. The # route command adds a route, the machine restarts, or the network card restarts, and the method of setting the permanent route under Linux: 1. Add 2 in/etc/rc.local. Add to end 3 in/etc/sysconfig/network ./etc/sysconfig/static-router :any net x.x.x.x/24 gw y.y.y.yroute add default gw 192.168.1.254route del default gw 192.168.1.254route add - net 192.168.100.0 netmask 255.255.255.0 dev eth0route add -host Ip dev lo:1route del -host ip If the IP has been properly configured, but want to adjust the default gateway, how to do it? "Adjust instances of the default gateway" view Route:[[email protected] ~]# route -nkernel ip routing tabledestination gateway genmask flags metric ref Use Iface10.0.200.0 0.0.0.0 255.255.255.0 U 0 0 0 em2169.254.0.0 0.0.0.0 255.255.0.0 u 1003 0 0 em20.0.0.0 10.0.200.128 0.0.0.0 ug 0       0        0 EM2 add default gateway [email protected] ~]# route add default gw 10.0.200.2 && route -n Kernel IP routing tableDestination Gateway Genmask flags metric ref use iface10.0.200.0 0.0.0.0 255.255.255.0 u 0 0 0 em2169.254.0.0 0.0.0.0 255.255.0.0 &nBsp u 1003 0 0 em20.0.0.0 10.0.200.2 0.0.0.0 ug 0 0 0 em20.0.0.0 10.0.200.128 0.0.0.0 UG 0 0    0 EM2 The default route is only one, so to remove the old invalid default route [[Email protected] ~]# route del] default gw 10.0.200.128 && route -n && ping qq.comkernel ip routing tabledestination gateway &nBsp genmask flags metric ref Use Iface10.0.200.0 0.0.0.0 255.255.255.0 U 0 0 0 em2169.254.0.0 0.0.0.0 255.255.0.0 u 1003 0 0 em20.0.0.0 10.0.200.2 0.0.0.0 ug 0 0 0 em2 Finally, remember to update the configuration file:[[email protected] ~]# sed -i ' S/200.128/200.2/' /etc/sysconfig/network-scripts/ifcfg-em1 && cat /etc/sysconfig/ Network-scripts/ifcfg-em1
Introduction to route usage