Iptables + NAT + port ing (1)

Source: Internet
Author: User

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 ######################################## #


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.