Nat example, Enabling nat at bootup, Nat example -7 – Moxa Technologies EM-1240-LX User Manual

Page 40: Enabling nat at bootup -7

Advertising
background image

EM-1240-LX User’s Manual

Configuring EM-1240-LX

4-7

NAT

NAT (Network Address Translation) protocol translates IP addresses used on one network into
different IP addresses used on another network. One network is designated the inside network and
the other is the outside network. Typically, the EM-1240-LX connects several devices on a
network and maps local inside network addresses to one or more global outside IP addresses, and
remaps the global IP addresses on incoming packets back into local IP addresses.

NOTE

Click the following link for more information about iptables and NAT:

http://www.netfilter.org/documentation/HOWTO/NAT-HOWTO.html

NAT Example

The IP addresses of all packets leaving LAN1 are changed to 192.168.3.127 (you will need to load
the module ipt_MASQUERADE):

1.

#echo 1 > /proc/sys/net/ipv4/ip_forward

2.

#iptables -t nat –A POSTROUTING –o eth0 –j SNAT --to-source 192.168.3.127

or

3.

#iptables –t nat –A POSTROUTING –o eth0 –j MASQUERADE

Enabling NAT at Bootup

In most real world situations, you should use a simple shell script to enable NAT when the
EM-1240-LX boots up, as indicated by the following:

1. setting iptables
2. iptables-save > /home/xxx.file (xxx.file is the user defined file name)
3. vi /etc/rc
4. Append echo 1 > /proc/sys/net/ipv4/ip_forward
5. Append iptables-restore /home/xxx.file (xxx.file is the user defined file name)

Advertising