Configure the route table for dual NICs in Linux

Source: Internet
Author: User
Configure the route table for the dual network adapter in Linux-Linux Enterprise Application-Linux server application information. For more information, see. If eth0 is 192.168.10.123/255.255.255.0 and eth1 is 192.168.255.231/255.255.255.0, the command format is as follows:

# Route add-net 192.168.10.0 netmask 255.255.255.0 dev eth0

# Route add-net 192.168.20.0 netmask 255.255.255.0 dev eth1

The above Command sends the IP packet sent to the 192.168.10.0 network segment to eth0 for forwarding, And the IP packet of the 192.168.20.0 network segment to eth1 for forwarding. If a package may be sent to another destination IP address, you may want to set a "Default Gateway ":

# Route add default gw 192.168.10.1

The preceding command forwards all packets sent to other destination IP addresses to 192.168.10.1, the rule on How to forward the address to 192.168.10.1 has been defined in the first command just now (forwarded from eth0 ). In general, the default gateway has been automatically set, and you do not need to set it again. You can use the route command to add the-n parameter for inspection.

To delete a certain entry, the command format is:

# Route del-net 192.168.10.0 netmask 255.255.255.0

One idea during configuration is to route the 192.168.10.0 CIDR block to eth0 and 192.168.20.0 CIDR block to eth1, and then set the default route. Another idea is to specify only one of them, and then route the default 0.0.0.0 to the other. In fact, the effect is the same, that is, two styles.

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.