Jump to content
Compatible Support Forums
RaMs

Iptables for different types of NAT

Recommended Posts

Hi

 

If anybody worked on Iptables,please help me in implementing each type of NAT

-Full Cone NAT

-Restricted Cone NAT

-Port Restricted Cone NAT

-Symmetric NAT

 

using IPTables.

 

 

Expalnation:

• Full Cone: A full cone NAT is one where all requests from the same internal IP address and port are mapped to the same external IP address and port. Furthermore, any external host can send a packet to the internal host, by sending a packet to the mapped external address.

 

• Restricted Cone: A restricted cone NAT is one where all requests from the same internal IP address and port are mapped to the same external IP address and port. Unlike a full cone NAT, an external host (with IP address X) can send a packet to the internal host only if the internal host had previously sent a packet to IP address X.

 

• Port Restricted Cone: A port restricted cone NAT is like a restricted cone NAT, but the restriction includes port numbers. Specifically, an external host can send a packet, with source IP address X and source port P, to the internal host only if the internal host had previously sent a packet to IP address X and port P.

 

• Symmetric: A symmetric NAT is one where all requests from the same internal IP address and port, to a specific destination IP address and port, are mapped to the same external IP address and port. If the same host sends a packet with the same source address and port, but to a different destination, a different mapping is used. Furthermore, only the external host that receives a packet can send a UDP packet back to the internal host.

 

 

On the netfilter mailinglist, Pedro Gonçalves suggested the following:

 

Using iptables, I set all policies to "ACCEPT" and I was able to setup two kinds of NAT: (192.168.2.170 is my "public" address and 10.0.0.1 is my "private" address

 

/-"Full Cone NAT", with the following rules:/

 

iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to-source 192.168.2.170

 

iptables -t nat -A PREROUTING -i eth0 -j DNAT --to-destination 10.0.0.1

/-"Port Restricted Cone NAT", with just a single rule:/

 

iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to-source 192.168.2.170

 

Please help me in implementing other NAT types.

 

 

 

Thanks in advance,

RaMs

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×