View previous topic :: View next topic |
Author |
Message |
njcwotx Guru
![Guru Guru](/images/ranks/rank_rect_3.gif)
![](images/avatars/2613710048d26fe72d3e4.png)
Joined: 25 Feb 2005 Posts: 587 Location: Texas
|
Posted: Sat Jun 20, 2015 9:08 pm Post subject: iptables and multiple 1 to 1 NATs |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
njcwotx Guru
![Guru Guru](/images/ranks/rank_rect_3.gif)
![](images/avatars/2613710048d26fe72d3e4.png)
Joined: 25 Feb 2005 Posts: 587 Location: Texas
|
Posted: Sat Jun 20, 2015 9:41 pm Post subject: |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
|