Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
iptables and multiple 1 to 1 NATs
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
njcwotx
Guru
Guru


Joined: 25 Feb 2005
Posts: 587
Location: Texas

PostPosted: Sat Jun 20, 2015 9:08 pm    Post subject: iptables and multiple 1 to 1 NATs Reply with quote

I have a natting question.

I have a Gentoo box with iptables acting as a firewall.
eth0 - 12.33.44.254 (12.33.44.0/24 is network)
eth1 - 192.168.3.253 ( 192.168.0.0/22 is network)

under normal circumstances internal traffic is natted as the 12.33.44.254 address.

However, I need to have several outside addresses mapped internally.
for example:
12.33.44.250 maps to 192.168.2.222
12.33.44.249 maps to 192.168.3.33
12.33.44.24888 maps to 192.168.1.48

this is where it gets tricky, and I am trying to figure out how this sets up.

I am familiar with mapping a PORT forward to different internal addresses like this...
iptables -t nat -I PREROUTING -p tcp -i eth0 -d 12.33.44.254 --dport 80 -j DNAT --to 192.168.1.33
iptables -t nat -I PREROUTING -p tcp -i eth0 -d 12.33.44.254 --dport 443 -j DNAT --to 192.168.2.111

can I do this for multiples?
iptables -t nat -I PREROUTING -i eth0 -d 12.33.44.249 -j DNAT --to 192.168.1.33
iptables -t nat -I PREROUTING -i eth0 -d 12.33.44.248 -j DNAT --to 192.168.2.111

(how does the eth0 know to answer up? Multihoming?)

I am attempting to try this but if someone is out there with experience with this, I could use a little help. Thanks.
_________________
Drinking from the fountain of knowldege.
Sometimes sipping.
Sometimes gulping.
Always thirsting.


Last edited by njcwotx on Sat Jun 20, 2015 10:21 pm; edited 1 time in total
Back to top
View user's profile Send private message
njcwotx
Guru
Guru


Joined: 25 Feb 2005
Posts: 587
Location: Texas

PostPosted: Sat Jun 20, 2015 9:41 pm    Post subject: Reply with quote

Got it work like this. Answered my own question as I was writing up my question!

ipconfig eth0:0 12.33.44.253 netmask 255.255.255.0
ipconfig eth0:1 12.33.44.249 netmask 255.255.255.0
ipconfig eth0:2 12.33.44.248 netmask 255.255.255.0
iptables -t nat -I PREROUTING -i eth0 -d 12.33.44.249 -j DNAT --to 192.168.1.33
iptables -t nat -I PREROUTING -i eth0 -d 12.33.44.248 -j DNAT --to 192.168.2.111
_________________
Drinking from the fountain of knowldege.
Sometimes sipping.
Sometimes gulping.
Always thirsting.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum