Description: The server has two network cards: eth0 and eth1, eth0 is configured with internal IP: 192.168.1.1/24, eth1 is configured with external IP: 10.1.1.1/24; 192.168.0.0/16 is required The segment takes the network card eth0, the gateway is 192.168.1.254, and the rest of the network segments take the network card eth1, and the gateway is 10.1.1.254;
1. Configure the network card IP
vi /etc/sysconfig/network-scripts/ifcfg-eth0 // Configure network card 1
NAME=”eth0″
ONBOOT=”yes”
IPADDR=”192.168.1.1″
PREFIX=”24″
#GATEWAY=”192.168. 1.254″ There can only be one default route. NIC 2 is the default route, so please comment it out here
vi /etc/sysconfig/network-scripts/ifcfg-eth1 //Configure NIC 2
NAME=”eth1″
ONBOOT=”yes”
IPADDR=”10.1.1.1″
PREFIX=”24″
GATEWAY0=”10.1.1.254″
II. Add intranet access route
vi /etc/sysconfig/network-scripts/route-eth0 //Configure network card 1 route
ADDRESS0=192.168.0.0
NETMASK0=255.255.0.0
GATEWAY0=192.168.1.254
The following configuration is the same
192.168.0.0/16 via 192.168.1.254 dev eth01 3. Restart the network service and take effect immediately systemctl restart network.service 4. , View the routing table ip route list