Dual-nic for Intranet forwarding in Ubuntu

Source: Internet
Author: User
When the Internet IP address is not enough or DHCP on the Internet leads to an old IP address, which is inconvenient to share printers and files, you may want to build a static IP address intranet. We don't have to worry about advanced, simple dual-nic, one Internet, one Intranet gateway. 1. Basic Requirements System: Ubuntu server (dual Nic): eth0 automatic IP (Internet) eth11900000.1 & n

When the Internet IP address is not enough or DHCP on the Internet leads to an old IP address, which is inconvenient to share printers and files, you may want to build a static IP address intranet.
We don't have to worry about advanced, simple dual-nic, one Internet, one Intranet gateway.

1. Basic Requirements
System: Ubuntu
Server (dual Nic ):
Eth0 automatic IP (Internet)
Eth1 192.168.0.1 (Intranet)
Intranet client:
Eth0 192.168.0. * (Intranet)

2. Server Configuration
Basic Idea: Enable IP Forwarding and set iptables rules.

2. 1. Enable IP Forwarding
Two methods,
Temporary: echo "1">/proc/sys/net/ipv4/ip_forward
Fixed: Modify/etc/sysctl. conf to cancel the comments of this line:
Net. ipv4.ip _ forward = 1
Then restart the network.

2. Set iptables rules
Temporary: iptables-t nat-a postrouting-j MASQUERADE
Fixed:
Or write the above to a STARTUP script. There is another version:
Iptables-F
Iptables-P INPUT ACCEPT
Iptables-P FORWARD ACCEPT
Iptables-t nat-a postrouting-s 192.168.0.0/24-o eth1-j MASQUERADE
It is said that "the first sentence is to clear all previous iptables rules, the second sentence is to allow receiving and sending data packets, and the fourth sentence is to NAT on the eth1 network port", just a few more nonsense words than above, and finally specify what Nic parameters, have not tried. The usage of iptables is still easy to learn.

3. Client settings
Set the default gateway to 192.168.0.1.

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.