Skip to contentSkip to conversation

iptable for multiple ip address

LARTC James Ma 4 participants 4 messages Sep 12, 2002 – Sep 14, 2002

lore
Share & tools
lore

James Ma

author
#0 lore raw

Hi, All,

So far, all the applications I have seen for Iptables are focusing on connecting a WAN with one IP address to a LAN and using NAT. My question is if the iptables support multiple IP address on WAN side? If so, how it works (you only have one NIC on WAN side)? Is static NAT (it might not be the right term, I mean a static and permanent connection between WAN IP address and LAN IP address) supported?

Thanks in advance,

James

#1 lore raw

A fecha Thu, Sep 12, 2002 at 09:35:51AM -0400, James Ma dijo:

Quoted 8 lines

So far, all the applications I have seen for Iptables are focusing on connecting a WAN with one IP address to a LAN and using NAT. My question is if the iptables support multiple IP address on WAN side? If so, how it works (you only have one NIC on WAN side)? Is static NAT (it might not be the right term, I mean a static and permanent connection between WAN IP address and LAN IP address) supported?

Yes, with iptables you can have more than one IP
address for each physical interface, both in "local" and "external" places, then you have to add them as aliases with ip, and do some NAT to connect each side, if there are private IPs involved.

_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

#2 lore raw
In reply to James Ma
Quoted 6 lines · Juan Antonio Morillas Cerezo

Yes, with iptables you can have more than one IP
address for each physical interface, both in "local" and "external" places, then you have to add them as aliases with ip, and do some NAT to connect each side, if there are private IPs involved.

I would add the following. If what the original poster wants is to somehow give a LAN with private IP addressing access to the Internet using not a simple public IP address, but a pool of them, you easily can. Just create an iptables rule with a SNAT target like this:

iptables -t nat -A POSTROUTING --out-interface $WAN_IF \
    --jump SNAT --to-source $START_PUB_IP-$END_PUB_IP

The only limitation I see with this approach is that IP addresses must be contiguous, but I think this is a typical scenario, because our ISP tend to give addresses in blocks :)

Hope this helps.

Signature · 5 lines
Jose Luis Domingo Lopez
Linux Registered User #189436     Debian Linux Woody (Linux 2.4.19-pre6aa1)
_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/
#3 lore raw
In reply to James Ma
Quoted 6 lines · Jose Luis Domingo Lopez
iptables -t nat -A POSTROUTING --out-interface $WAN_IF \
    --jump SNAT --to-source $START_PUB_IP-$END_PUB_IP

The only limitation I see with this approach is that IP addresses must be contiguous, but I think this is a typical scenario, because our ISP tend to give addresses in blocks :)

But you can put multiple --to-source so there's no limitation.

--
Eric Leblond
[email protected]

_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/