Problem of setting Intranet access for Ubuntu dual-nic

Source: Internet
Author: User
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 UbuntuLinux server and set 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

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 Ubuntu Linux server, with different ip addresses and gateways (intranet and Internet) configured. The Internet is accessed through the Internet Nic, and the Intranet is 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 eth0
Iface eth0 inet dhcp
Post-up iptables-restore </etc/iptables. up. rules

# The second eth1
Auto eth1
Iface eth1 inet static
Address 192.168.0.1
Netmask 255.255.255.0

Note that no gateway is set for eth1 (internal network.

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.