How to set Port ing using iptables

Source: Internet
Author: User
Map the IP ports of the two WAN ports to the same intranet Port. the IP addresses of the two WAN ports on the server are 192.168.30.155 and 192.168.80.155. The intranet IP address is 192.168.1.1. the client IP address is 192.168.1.138 (eth1) port 8080 to port 21 iptables-tnat-APREROUTING-d192.168.30.155 maps the IP ports of two WAN ports to the same intranet Port
The IP addresses of two WAN ports on the server are 192.168.30.155 and 192.168.80.155, and the intranet IP address is 192.168.1.1.
The client IP address is 192.168.1.138 (eth1)

Port 8080 to port 21
Iptables-T nat-a prerouting-d 192.168.30.155-p tcp -- dport8080-j DNAT -- to-destination 192.168.1.138: 21
Iptables-t nat-a prerouting-d 192.168.80.155-p tcp -- dport 8080-j DNAT -- to-destination 192.168.1.138: 21
Iptables-t nat-a postrouting-d 192.168.1.138-p tcp -- dport 21-j SNAT -- to 192.168.1.1
Iptables-a forward-o eth1-d 192.168.1.138-p tcp -- dport 21-jACCEPT
Iptables-a forward-I eth1-s 192.168.1.138-p tcp -- sport 21-jACCEPT

In the linux command line, enter the following command to configure the route from which interface to which: (configure the policy route)
Ip route add default via 192.168.30.1 dev eth0 src 192.168.30.155table 1
Ip rule add from 192.168.30.155 table 1
Ip route add default via 192.168.80.1 dev eth2 src 192.168.80.155table 2
Ip rule add from 192.168.80.155 table 2

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.