Just throw this into your iptables script and it will retrieve your IP 
address and set it ti $external_ip.  I have a firewall which is dhcp and I 
find this works great.  

external_ip=`/sbin/ifconfig $external | grep inet | cut -d : -f 2 | cut -d \  -f 1`

iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to $external_ip


Cheers,


Daryl Martin
Computer Engineering
Memorial University
[EMAIL PROTECTED]


On Sun, 3 Mar 2002, JD Rogers wrote:

> 
> Greetings all,
> 
> When @home went under I lost my static IP and  my cable company forced me
> to switch to DHCP.  Over the past few weeks, I have been trying to sort
> out the consequences.  
> 
> Everything seams to be working fine  if I use:
> iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to my.ip.address
> 
> But since my ip changes occasionally now, I thought I should be using:
> iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
> 
> When I do this, however, my machines on the internal network can't see the
> rest of the world.
> 
> I hope I am not misinterpreting the documentation.  Please let me know
> what the best way to fix this is, or even how to truble shoot it.  I'm not
> getting any error messages.
> 
> System: linux 2.4.16
>       debian testing
>       dhclient 2.0pl5
> 
> Thanks,
> JD
> 
> 
> 


Reply via email to