On 08/07/2017 01:45 PM, Matt Darfeuille wrote:
> Hi,
> 
> My net interface gets it's ip address dinamically asigned by a dhcp server.
> Sometime I need that address for SNAT, DNAT rules and so on...
> I use a variable throughout Shorewall that is defined in the params file.
> Everytime that this ip change, I need to change it manually.
> 
> I'm currently testing the following to let Shorewall know about that new ip:
> 
> I have a script in /etc/dhcp/dhclient-exit-hooks that do:
> 
> case $reason in
>     bound)
>         echo $new_ip_address > /etc/shorewall/current_net_ip
>         shorewall reload
>         ;;
> esac
> 
> then in /etc/shorewall/params:
> 
> CURRENT_NET_IP=$(cat /etc/shorewall/current_net_ip)
> 
> then I can use 'CURRENT_NET_Ip' throughout Shorewall.
> 
> I could clearly asign a fix address but for the sake of understanding...
> Is there a better way to let shorewall know when my net interface gets a
> new ip or fix address is the way to go?

The best way is to use an address variable
(http://www.shorewall.org/configuration_file_basics.htm#AddressVariables).
You still need to use an exit-hook script though.

-Tom
-- 
Tom Eastep        \   Q: What do you get when you cross a mobster with
Shoreline,         \     an international standard?
Washington, USA     \ A: Someone who makes you an offer you can't
http://shorewall.org \   understand
                      \_______________________________________________

Attachment: signature.asc
Description: OpenPGP digital signature

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Shorewall-users mailing list
Shorewall-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/shorewall-users

Reply via email to