1. Configure intranet IP: ifcfg-eno1
TYPE="Ethernet" BOOTPROTO="none" DEFROUTE="yes" IPV4_FAILURE_FATAL="no" IPV6INIT="yes" IPV6_AUTOCONF="yes" IPV6_DEFROUTE="yes" IPV6_FAILURE_FATAL="no" NAME="eno1" UUID="e4f6837c-e6a0-44ed-a8bf-0145d87a3493" DEVICE="eno1" ONBOOT="yes" IPADDR="128.0.3.251" PREFIX="21" GATEWAY="128.0.3.1" DNS1="内网DNS" IPV6_PEERDNS="yes" IPV6_PEERROUTES="yes" IPV6_PRIVACY="no"
2. Configure the external network IP: ifcfg-eno2
TYPE="Ethernet" BOOTPROTO="none" DEFROUTE="yes" NAME="eno2" UUID="2eaf6606-516b-44d7-bb94-23f0f66dae0a" DEVICE="eno2" IPV4_FAILURE_FATAL="no" IPV6INIT="yes" IPV6_AUTOCONF="yes" IPV6_DEFROUTE="yes" IPV6_FAILURE_FATAL="no" ONBOOT="yes" IPADDR="121.126.29.242" GATEWAY="121.126.29.241" DNS1="外网DNS" IPV6_PEERDNS="yes" IPV6_PEERROUTES="yes" IPV6_PRIVACY="no" NETMASK="255.255.255.252" HWADDR="fc:15:b4:10:ca:55" NM_CONTROLLED=yes
3. Configure routing: this step is the key
route add -net 128.0.0.0 netmask 255.255.248.0 gw 128.0.3.1 eno1 route add -net 121.126.29.240 netmask 255.255.255.252 ge 121.126.29.241 eno2 route add default gw 121.126.29.241 eno2
The last sentence of the default gateway is the point
4. The configuration takes effect permanently: /etc/rc.local
route add -net 128.0.0.0 netmask 255.255.248.0 gw 128.0.3.1 eno1 route add -net 121.126.29.240 netmask 255.255.255.252 ge 121.126.29.241 eno2 route add default gw 121.126.29.241 eno2
5. Debugging process:
》 1. Unplug the external network cable and test whether the internal network is connected
》 2. Unplug the internal network cable and test whether the external network is connected
》3, plug in the internal and external network cables at the same time, network connectivity
> 4, view the routing table:
netstat -rn
> 5, delete the routing table:
route del -net default netmask 0.0.0.0 gw 128.0.3.1 eno1