Ubuntu dual-nic NAT

Source: Internet
Author: User
It turns out that firestarter is playing a strange role. It is no wonder that the ping via the network cable will fail, affecting the judgment. Generally, you can configure an IP address, such as static or DHCP, by using the network tool provided by Ubuntu after inserting the network adapter. You do not need to manually modify the interfaces file. After plugging in the network cable, you can set the IP address of the corresponding Nic to ping each other from the client and the dual Nic host. If the ping fails, first check whether the firewall is installed and then check the network cable and interface. The main problem is how to achieve Internet sharing.

It turns out that firestarter is playing a strange role. It is no wonder that the ping via the network cable will fail, affecting the judgment.

Generally, you can configure an IP address, such as static or DHCP, by using the network tool provided by Ubuntu after inserting the network adapter. You do not need to manually modify the interfaces file.

After plugging in the network cable, you can set the IP address of the corresponding Nic to ping each other from the client and the dual Nic host. If the ping fails, first check whether the firewall is installed and then check the network cable and interface.

The main problem is how to achieve Internet sharing:

1. Modify the/etc/rc. local file and add

Iptables-F
Iptables-P INPUT ACCEPT
Iptables-P FORWARD ACCEPT
Iptables-t nat-a postrouting-s 192.168.0.0/24-o eth0-j MASQUERADE

The first sentence is to clear all previous iptables rules, the third sentence is to allow receiving and sending data packets, and the fourth sentence is to NAT on the eth0 network port. Note: Perform NAT on the network port with an external IP address.

2. Modify/etc/sysctl. conf and add the following line to the file: net. ipv4.ip _ forward = 1. NAT is enabled here. 1 indicates forwarding. If it is set to 0, it is not forwarded.

After reboot, connect to the Internet first, and then try the client to access the Internet.

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.