A test machine is installed in the IDC. The system is Ubuntu9.04X64 and the master machine is IBMX336. The user needs a dual-line connection. Therefore, one Nic is used to configure the telecom address, and the other Nic is configured with the UNICOM address. After the system is installed, only one Unicom address and one Telecom address can be pinged, if the China Unicom address does not match the gateway, you can only ping the China Telecom address. Otherwise, you can only ping the China Unicom address. If both China Unicom and China Telecom addresses are configured, the two cannot be connected. Because it is not our company's network
A test machine is installed in the data center. The system is Ubuntu 9.04 X64 and the master machine is IBM X336. The user needs a dual-line connection. Therefore, one Nic is used to configure the telecom address, and the other Nic is configured with the UNICOM address. After the system is installed, only one Unicom address and one Telecom address can be pinged, if the China Unicom address does not match the gateway, you can only ping the China Telecom address. Otherwise, you can only ping the China Unicom address. If both China Unicom and China Telecom addresses are configured, the two cannot be connected.
Because it is not our company's network, we are not clear about the Upper-layer implementation method. We only know that China Unicom and China Telecom lead to different VLANs, and China Telecom and China Unicom cannot pass through, however, other machines with the same intervention method can work normally out of the internet, so as to eliminate network problems, in addition, the network can be accessed normally when the machine is 2003, And the NIC problem is also ruled out. This is the only problem with the operating system. After asking for help from google and other masters, we finally got it done. The procedure is as follows:
Ubuntu dual-nic Dual IP. Different gateways. different subnets. How to ping two NICs at the same time,
The server environment is as follows :,
System: Ubuntu 9.04X64 server
China Telecom IP (TEL): 114.80.0.4 netmask 255.255.128 gateway 114.80.0.3
China Unicom IP (CNC): 112.65.0.2 netmask 255.255.255.0 gateway 112.65.0.1
1. Configure Nic Information
# Vi/etc/network/interfaces
Auto lo
Iface lo inet loopback
# The primary network interface
Auto eth0
Iface eth0 inet static
Address 114.80.0.4
Netmask 255.255.255.255.128
Gateway 114.80.0.3
# Dns-* options are implemented by the resolvconf package, if installed
Dns-nameservers 202.96.209.20.
Auto eth1
Iface eth1 inet static
Address 112.65.0.2
Netmask 255.255.255.0
Save configuration information and restart the NIC
#/Etc/init. d/networking restart
2. added two route tables: China Telecom: tel Unicom: cnc
# Vi/etc/iproute2/rt_tables
252 tel
251 cnc
Save and launch
3. Add routing rules
# Ip route flush table tel
# Ip route add default via 114.80.0.3 dev eth0 src 114.80.0.4 table tel
# Ip ruleadd from 114.80.0.4 table tel
In this example, the gateway of China Telecom is set up, and the telecom resources can be accessed only from the eth0 Nic.
# Ip route flush table cnc
# Ip route add default via 112.65.0.1 dev eth1 src 112.65.0.2 table cnc
# Ip rule add from 112.65.0.2 table cnc
The gateway of China Unicom is set up, and the access to Unicom resources is only available from the eth1 Nic.
4. Configure the networking STARTUP script file to add the following content before the end of exit 0
# Vi/etc/init. d/networking
Ip route flush table tel
Ip route add default via 114.80.0.3 dev eth0 src 114.80.0.4 table tel
Ip rule add from 114.80.0.4 table tel
Ip route flush table cnc
Ip route add default via 112.65.0.1 dev eth1 src 112.65.0.2 table cnc
Ip rule add from 112.65.0.2 table cnc
Exit 0
5. log out and restart the network.
#/Etc/init. d/networking restart
Then test the network conditions of the machine, and you will find that the addresses of both the Telecom and China Unicom can be accessed normally. This method also allows requests from the Telecom IP address to be returned by the telecom route, and requests from the Netcom IP address to be returned by the Netcom route.
Supplement: some experts on the Internet say that if the server is restarted or the network service is restarted, the above routing rules will become invalid. Therefore, you need to write the above command into the system startup script and network STARTUP script.
For ubuntu/debian, the system startup script is/etc/rc. local.
For RedHat/CentOS, the system startup script is/etc/rc. d/rc. local.
For ubuntu/debian, the network STARTUP script is/etc/init. d/networking.
For RedHat/centos, the network STARTUP script is/etc/rc. d/init. d/network.
The system startup script has not been changed but has changed the network STARTUP script. If you are interested, you can test it.