Linux Dual LAN configuration

method one

IP network is: 192.168.4.213, network gateway: 192.168.4.1

WAN IP is: 58.200.200.15 subnet mask: 255.255.255.128 gateway: 58.200.200.1

1. When configured as a server within the network and external network IP IP way, set just outside the network IP gateway, do not set the network IP gateway.

As follows:

vi /etc/network/interfaces

Inside modified as follows

auto eth0
iface eth0 inet static
address 192.168.4.213
netmask 255.255.255.0
 
auto eth1
iface eth1 inet static
address 58.200.200.15
netmask 255.255.255.128
gateway 58.200.200.1

Note: We do not set the gateway to eth0 (internal network), save and exit

2. Restart card, Ubuntu restart card command is:

/etc/init.d/networking restart

3. Routing manually set the server

route add -net 192.168.4.0/24 gw 192.168.4.1 dev eth0

Note: manually add routes, does not take effect after server restart

Method Two

vi /etc/network/interfaces

Modifications are as follows

auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 211.x.x.x
netmask 255.255.255.x
gateway 211.x.x.x
dns-nameservers 114.114.114.114 119.29.29.29
auto eth1
iface eth1 inet static
address 10.16.16.15
netmask 255.255.255.0
up route add -net 10.0.0.0 netmask 255.0.0.0 gw 10.16.16.254 eth1

**

Only set one gateway, the gateway using another route, and a network interface specifies the gateway ip

**

Published 15 original articles · won praise 0 · Views 285

Guess you like

Origin blog.csdn.net/weixin_44478009/article/details/103868954