Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to quickly deploy NAT under Linux

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the relevant knowledge of "how to deploy NAT quickly under Linux". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "how to quickly deploy NAT under Linux" can help you solve the problem.

NAT (Network Address Translation), which means "network address translation" in Chinese, is an IETF (Internet Engineering Task Force, Internet Engineering Task Force) standard that allows a whole organization to appear on the Internet with a public IP (Internet Protocol) address. As the name implies, it is a technology that translates internal private network addresses (IP addresses) into legal network IP addresses. NAT allows internal networks that use private addresses to connect to Internet or other IP networks. When sending packets from the internal network to the public network, the NAT router translates the private address into a legitimate IP address in the header of the IP packet.

I. basic environment

1) Experimental environment

One Linux server (configured with two network cards) and one PC (one network card, IP of 10.0.0.10)

2) Network environment

As a NAT server, the Linux server is responsible for transferring the traffic from the internal network to the external network, so you need two network cards and configure two networks, hereinafter referred to as the external network and the internal network. The network in the intranet can be set to a static address or a DHCP server can be configured. In Linux, ens160 is the external network card, IP is the 172.18.72.183Linux, ens192 is the internal network card, IP is 10.0.0.1, firewall configuration

1) allow all data sent to the intranet Nic to pass

Iptables-A FORWARD-I ens192-j ACCEPT

Note: ens192 is a private network card.

2) modify data header information

Iptables-t nat-A POSTROUTING-s 10.0.0.0`` / 24``-o ens160-j MASQUERADE

Note: 10.0.0.0Compact 24 is the internal network segment, and ens160 is the external network card

Or

Iptables-t nat-A POSTROUTING-j SNAT-- to- ``source``172.18.72.183

Note: 172.18.72.183 is the address of the external network card.

3. Enable Linux routing function echo``1 > ``/ proc/sys/net/ipv4/ip_ routingd`` # Open routing function ``cat`` / proc/sys/net/ipv4/ip_ roud`` # check whether routing function is enabled. If 1 is enabled, 0 means it is not enabled. Fourth, check connectivity.

Set the static IP (10.0.0.10Candle 24) on the Windows and set the gateway to 10.0.0.1.

Ping``www.baidu.com

The test passed.

This is the end of the content about "how to quickly deploy NAT under Linux". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report