Ubuntu iptables Intranet Port mapping firewall

Source: Internet
Author: User
Tags iptables server port

Network configuration file Settings: http://www.cnblogs.com/LJ-fish/archive/2010/05/17/1737674.html


There are many places to work with Ubuntu iptables , such as: intranet Port mapping

1. System Environment

Intranet Two servers:

A 172.16.119.128

B 172.16.119.129

You want to map the 80 port of a machine to the 8013 port of the B machine.

 2. Set Steps

2.1./etc/sysctl.conf Configuration file Modification

Delete "#" in front of the "# Net.ipv4.ip_forward = 1" line. The line is commented out by default.

2.2. View existing configuration information

Iptables-l

If the display reads as follows:

Chain INPUT (Policy ACCEPT)

Target Prot opt source destination

Chain FORWARD (Policy ACCEPT)

Target Prot opt source destination

Chain OUTPUT (Policy ACCEPT)

Target Prot opt source destination

Indicates no settings, you can continue to the next step.

Otherwise execute:

Iptalbes-f

Iptalbes-x

Iptalbes-z

2.3. Set Port Mappings

Execute separately:

Iptables-t nat-a prerouting-d 172.16.119.128-p tcp--dport 80-j dnat--to-destination 172.16.119.129:8013

Iptables-t nat-a postrouting-d 172.16.119.129-p tcp--dport 8013-j SNAT--to 172.16.119.128

Iptables-a forward-o eth0-d 172.16.119.129-p tcp--dport 8013-j ACCEPT

Iptables-a forward-i eth0-s 172.16.119.129-p tcp--sport 8013-j ACCEPT

2.4. Verify Port Mappings

At this point, access to http://172.16.119.128/abc.htm, should be able to access the corresponding 129 server port to 8013 Web site abc.htm page.

3. Set the boot automatically load iptables configuration file

3.1 Save Configuration

To execute a command:

# Iptables-save >/etc/init.d/iptables.up.rules

Save the current configuration in Iptables.up.rules file, the filename can be determined by itself.

3.2 To modify the NIC configuration file

At the end of the network card IP profile/etc/network/interfaces (/etc/init.d/iptables.up.rules can be changed to its own defined configuration file location and name)

Pre-up Iptables-restore </etc/init.d/iptables.up.rules

3.3 Reboot Server Authentication

Shutdown-r now

Through the introduction of the three steps of the text, we clearly know the formation of the Ubuntu iptables Intranet port mapping. I hope it works for you.

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.