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.