Introduction to route usage

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.