Add a route when both NICs need to set a gateway

Source: Internet
Author: User

Under normal conditions, two NICs of a server can only be configured with one gateway. If both NICs are configured with a gateway, I am sorry. At this time, the network will fail, there must be at least one NIC address.

The last time I went to the hosting data center to install the server for the customer, one Nic needs to be configured with a public IP address, the gateway needs to be configured, And the other needs to communicate with another server of the data center customer, however, the server to be installed is not in the same rack as the original server, and the address allocated by the IDC is not in the same network segment as the original server.

Network requirements:

Servers to be installed:

Eth0: addr: 211. X. X.50 eth1 is the address allocated by the data center ):

Mask: 255.255.255.252 addr: 10.0.3.5 mask: 255.255.255.0

Gateway: 211. X. X.49 gateway: 10.0.3.253

Original Server:

Addr: 10.0.1.6

Mask: 255.255.255.0

If you have set an IP address or gateway for eth0, you can access the public network. This is for sure, unless there is a network problem. However, after you set an IP address for eth1, you cannot access the original server 10.0.1.6) communication.

[Root @ testServer etc] # ping 10.0.1.6
PING 10.0.1.6 (10.0.1.6) 56 (84) bytes of data.
From 10.0.3.253 icmp_seq = 1 Destination Net Unreachable
From 10.0.3.253 icmp_seq = 2 Destination Net Unreachable
From 10.0.3.253 icmp_seq = 3 Destination Net Unreachable
From 10.0.3.253 icmp_seq = 4 Destination Net Unreachable

In this case, you need to add a route to make the 10.0.1.0 and 10.0.3.0 CIDR blocks recognize each other.

[Root @ testServer etc] # route add-net 10.0.0.0/8 gw 10.0.3.253 eth1
[Root @ testServer etc] # route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.0.3.252*255.255.255.252 U 0 0 0 eth1
211. X. X.48 * 255.255.255.252 U 0 0 eth0
169.254.0.0*255.255.0.0 U 0 0 0 eth1
10.0.0.0 10.0.3.253 255.0.0.0 UG 0 0 0 eth1
Default 211. X. X .. 49 0.0.0.0 UG 0 0 0 eth0

After adding this route, ping it again:

[Root @ testServer etc] # ping 10.0.1.6

PING 10.0.1.1 (10.0.1.1) 56 (84) bytes of data.
64 bytes from 10.0.1.1: icmp_seq = 1 ttl = 255 time = 3.11 MS
64 bytes from 10.0.1.1: icmp_seq = 2 ttl = 255 time = 1.01 MS
64 bytes from 10.0.1.1: icmp_seq = 3 ttl = 255 time = 0.808 MS
64 bytes from 10.0.1.1: icmp_seq = 4 ttl = 255 time = 1.05 MS
64 bytes from 10.0.1.1: icmp_seq = 5 ttl = 255 time = 0.902 MS

At this time, communication is available, but this is not complete yet, because the route just added will disappear as soon as the machine is restarted, and the two machines still cannot communicate. But what should I do? There is no need to worry. There is a way to add the command that just added the route to the last line of the file/etc/rc. local, and then save and exit. In this way, you are not afraid to restart the machine.

[Url = http://www.51zxw.net/study.asp? Vip =] 51 self-study network-video tutorials recorded by professional training instructors, making learning easy [/url]

This article from the "Great Wall" blog, please be sure to keep this source http://wlcc121.blog.51cto.com/861451/563058

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.