Implement port mappings on Linux or Windows

Source: Internet
Author: User




Usually the server will have many blocks of network cards, so it may also be connected to a different network, in the isolated network, some services may need to communicate, when the server is configured to assume the ability to forward the packet.




One, implementing port mappings under Windows Server


1. Querying the port mapping situation

netsh interface portproxy show v4tov4


2. Querying all port mappings for an IP

netsh interface portproxy show v4tov4 | Find "[Destination IP]"

Example: netsh interface portproxy show v4tov4 | Find "192.168.1.1"


3. Add a port mapping

netsh interface portproxy add v4tov4 listenaddress=[extranet IP] listenport=[extranet port] connectaddress=[intranet IP] connectport=[intranet port]

Example: netsh interface portproxy add v4tov4 listenaddress=2.2.2.2 listenport=8080 connectaddress=192.168.1.50 connectport= 80


4. Delete a port mapping

netsh interface portproxy delete v4tov4 listenaddress=[extranet IP] listenport=[external network port]

Example: netsh interface portproxy delete v4tov4 listenaddress=2.2.2.2 listenport=8080





Second, the implementation of port mapping under Linux


1. Allow packet forwarding:

Echo 1 >/proc/sys/net/ipv4/ip_forward
Iptables-t nat-a Postrouting-j Masquerade


2. Set Port forwarding:

Iptables-t nat-a prerouting-p tcp-m TCP--dport [external network port]-j DNAT--to-destination [Intranet address]:[intranet port]

Example: Iptables-t nat-a prerouting-p tcp-m tcp--dport 6080-j DNAT--to-destination 10.0.0.100:6090


3. Save the configuration. If not saved, this mapping will expire after reboot

Service Iptables Save




Implement port mappings on Linux or Windows

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.