-   Linux - Networking (
-   -   iptables script - How can I define a dynamic IPaddress (

theinfidel 12-25-2008 04:15 PM

iptables script - How can I define a dynamic IPaddress
Hi, all

in my iptables script I define the environment like this:

# Private interface

# Public Interface

My question is, if I give the IF_PUB interface the DYNAMIC IPaddress assigned by my ISP how can I define it in IP_PUB and also the NET_PUB so I can then use it for the firewall rules.

exemple rule:

iptables -t nat -A POSTROUTING -s $NET_PRV -o $IF_PUB -j SNAT --to $IP_PUB
thanks you for any help

Berhanie 12-25-2008 05:44 PM


... -j SNAT --to $IP_PUB
You can use this instead:

An alternative is to parse the dhcp client database (e.g. /var/lib/dhclient/ for the assigned IP address,
and to use SNAT.

theinfidel 12-26-2008 11:47 AM

I guess what I am trying to figure out is how to UPDATE THE IPADDRESS in the iptables script, AUTOMATICALY.
Parsing dhcp.leases is ok as a way to get the address.
Probably complicated ?

Does anyone know if I can call it (the address) from the iptables script or maybe have dhclient write it there.

Thanks a bunch!

All times are GMT -5. The time now is 09:58 PM.