LearningIptablesWe should know the twoNAT,Port ingSomething. Now I will explain it to you!
Goals:
Use iptabels to implement NAT transparent proxy for the LAN, such as Internet cafes or Internet proxy servers of companies! At the same time, the Intranet WEB server port ing is realized! And solved the problem that the visitor IP address of the WEB server is the Proxy Server IP address! At the same time, both the Intranet and Internet can access the Intranet WEB server through a public IP! Goals:
Use iptabels to implement NAT transparent proxy for the LAN, such as Internet cafes or Internet proxy servers of companies! At the same time, the Intranet WEB server port ing is realized! And solved the problem that the visitor IP address of the WEB server is the Proxy Server IP address! At the same time, both the Intranet and Internet can access the Intranet WEB server through a public IP! (SQUID is not successfully added. Please try again !)
The software and hardware environment is as follows:
The OS is RHEL 4, 3 Com Nic, eth0 is an Internet Nic, IP: 221.222.111.10, eth1 is an intranet Nic, IP: 192.168.0.1, and Intranet WEB server IP: 192.168.0.200. Network Environment: China Telecom 10 m optical fiber, fixed IP!
The method is as follows:
First, I commented out all the original content of the iptables file, and then wrote the following content in the iptables file!
##################################### Start the Nat segment ######################################## #
* Nat
: Prerouting accept [0: 0]
: Output accept [0: 0]
: Postrouting accept [0: 0]
#
# ------------------------------ Web Server port ing ------------------------------
#192.168.0.200 port 80
######################
# Use DNAT for port ing! Note that the following commands must be in front of the NAT transparent proxy; otherwise, the command is invalid!
-A prerouting-I eth1-p tcp-d 221.222.111.10 -- dport 80-j DNAT -- to-destination 192.168.0.200: 80
-A prerouting-I eth0-p tcp-d 221.222.111.10 -- dport 80-j DNAT -- to-destination 192.168.0.200: 80
#
# ---------------------------- Iptables NAT transparent proxy ------------------------------
#
-A postrouting-s 192.168.0.0/255.255.255.0-j SNAT -- to 221.222.111.10
#
COMMIT
##################################### End of a Nat segment ######################################## #