System Environment: centos Linux
Network Environment: two IP addresses, 192.168.0.10 and 10.10.30.2, mask 255.255.255.0,
The Gateway addresses of the two subnets are 192.168.0.1 and 10.10.30.1.
1.Configure the IP address 192.168.0.10 for the network adapter eth0 and the IP address 10.10.30.2 for the network adapter eth1. The configuration file is:
/Etc/sysconfig/network-scripts/ifcfg-eth0
/Etc/sysconfig/network-scripts/ifcfg-eth1
2.Set the default gateway to any one. This default gateway determines the interface used when the system takes the initiative to use the network.
Configuration File:/etc/sysconfig/Network
Modify the following content
Networking = Yes (indicates whether the system uses the network, which is generally set to yes. If it is set to no, the network cannot be used)
Hostname = centos (set the Host Name of the local machine. The host name set here must correspond to the host name set in/etc/hosts)
Gateway = 192.168.0.1 (set the IP address of the default gateway connected to the local machine .)
3.Edit route table
1. Modify/etc/iproute2/rt_tables and add the following content:
252 net2
251 net3
2. #/etc/rc. Local Add the original return route
IP Route flush table net2
IP Route add default via 192.168.0.1 Dev eth0 SRC 192.168.0.10 table net2
IP rule add from 192.168.0.10 table net2
IP Route flush table net3
IP Route add default via 10.10.30.1 Dev eth1 SRC 10.10.30.2 table net3
IP rule add from 10.10.30.2 table net3