It is impossible for a dual-nic computer to have two gateways, because the default gateway can only be one. Install two NICs for the server, with different ip addresses and gateways (intranet and Internet) respectively. The Internet can be accessed through the Internet Nic, and the Intranet can be accessed through the Intranet Nic, it seems very easy to implement, but there are some problems, because the Default Gateway (defaultgateway) can only be one! Solution: 1. Set one network card (such as the Internet) to the default gateway, and the other network card eth1 to not set the gateway.
It is impossible for a dual-nic computer to have two gateways, because the default gateway can only be one. Install two NICs for the server, with different ip addresses and gateways (intranet and Internet) respectively. The Internet can be accessed through the Internet Nic, and the Intranet can be accessed through the Intranet Nic, it seems very easy to implement, but there are some problems, because the default gateway can only be one!
The solution is:
1. Set the default gateway for one network card (such as the Internet), and the other network card eth1 does not set the gateway.
Sudo vi/etc/network/interfaces
# The loopback network interface
Auto lo
Iface lo inet loopback
# The primary network interface
Auto eth1
Iface eth1 inet dhcp
Post-up iptables-restore </etc/iptables. up. rules
# The second eth1
Auto eth0
Iface eth0 inet static
Address 192.168.0.1
Netmask 255.255.255.0
Note that no gateway is set for eth1 (internal network.
If the NIC is set here, network-manager will not have the permission to read it for management. You can delete the wireless network adapter in the above configuration file to enable the network-manager
Convenience.
2. (Note: This step may be omitted for Ubuntu Systems) enter the command: route, if there is no line below:
192.168.0.0*255.255.255.0 U 0 0 0 eth1
Manually add a static route so that the data of another network segment (Intranet) passes through the second network card. Use the route command. The command example is as follows:
Reference command:
Sudo route add-net 192.168.0.0 netmask 255.255.255.0 dev eth1 (enable access to 192.168.0.0 to the eth1 Nic, followed by the subnet mask)
If you want the above command to run at startup, edit the following file to execute the above command and add the above command to the file before exit 0
Sudo vi/etc/rc. local