In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
Most people do not understand the knowledge points of this article "linux port mapping", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "linux port mapping" article.
Port mapping, also known as port forwarding, refers to mapping the port of the IP address of an external host to a computer in the Intranet. When a user accesses this port of the external network IP, the server automatically maps the request to the machine within the corresponding local area network; it can be achieved by using dynamic or fixed public network IP routing ADSL broadband router.
The operating environment of this tutorial: linux5.9.8 system, Dell G3 computer.
In the process of development, because of the network environment, it is necessary to access some ports of other servers through a certain server, which involves the problem of linux port mapping. On linux servers, linux port mappings below 1024 are prohibited for non-root users. So if you want to use port 80 to access tomcat, change the port of conf/server.xml to 80, then you can only use root users; but linux port mapping for security, generally use other users to start tomcat, you can use port mapping, such as mapping ports 80 to 8080.
What is linux port mapping?
Linux port mapping, also known as port forwarding, is to map the port of the IP address of an external host to a computer in Intranet to provide the corresponding service.
When the user accesses this port of the external network IP, the server automatically maps the request to the machine inside the corresponding local area network.
Port mapping can be achieved by using dynamic or fixed public network IP routing ADSL broadband routers. The ADSL connects directly to a hub or switch to allow computers to share the Internet.
When a user accesses the port of a linux host that provides a mapped port, the server sends a request to the host in the LAN that provides this particular service. Multiple ports of an external IP address machine can also be mapped to different ports on different computers in the internal network. Port mapping can also perform specific proxy functions.
Port mapping is divided into dynamic and static. Dynamic port mapping: if a computer in the private network wants to visit the website, it will send a packet to the NAT gateway. The packet header includes the other website IP, port and local IP, port. The NAT gateway will replace the local IP and port with its own public network IP and an unused port, and will write down this mapping relationship for future packet forwarding.
How to do port mapping
You can use iptables for port mapping at will:
Step 1: turn on the port mapping function:
Method 1: (allow packet forwarding)
Sudo echo'1' > / proc/sys/net/ipv4/ip_forward
Method 2:
Vim / etc/sysctl.conf removes the gaze from the line; net.ipv4.ip_forward = 0, and changes 0 to 1. The modified result is: net.ipv4.ip_forward = 1
Step 2: map:
DNAT
Iptables-t nat-A PREROUTING-d native IP-p tcp-- dport native port-j DNAT-- to-destination target IP: target port
SNAT
Iptables-t nat-A PREROUTING-d native IP-p tcp-- dport native port-j SNAT-- to-destination target IP: the above target port is about "how linux ports are mapped". I believe everyone has a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.