( MASQ and Dynamic IPs ) - Does IP Masquerade work with dynamically assigned IP addresses?

Linux IP Masquerade HOWTO
Prev | Chapter 7. Frequently Asked Questions | Next

# 7.8. ( MASQ and Dynamic IPs ) - Does IP Masquerade work with dynamically assigned IP addresses?

Yes, it works with either dynamic IP addressed assigned by your ISP via either PPP or a DHCP server (common for Cablemodem and DSL users). As long as you have a valid Internet IP address, it should work. Of course, static IPs work too. If you plan on implementing a strong IPTABLES, IPCHAINS, or IPFWADM ruleset and/or plan on using a Port forwarder, your ruleset will have to be re-executed everytime your IP address changes.

So, re-running the rc-firewall-* ruleset really depends on which method you get your IP addresses:

- PPP: The /etc/ppp/ip-up script is always run when a PPP connection comes up. Because of this, we can make the rc.firewall-* go get the new PPP IP address and update the firewall ruleset. If the /etc/ppp/ip-up file doesn't exist or if does exists, simply edit that file and append a line containing the name of your chosen firewall ruleset. For example, to run the SIMPLE IPTABLES ruleset:

      /etc/rc.d/rc.firewall-iptables

- DHCP: If you get your IP address via DHCP, common for Cablemodem and DSL users, it's easy get the rc.firewall-* ruleset to run when you get a new IP lease. How this happens depends on what DHCP client your distribution uses:

  - dhclient : Most modern Linux distributions use dhclient from ISC. To re-run your specific rc-firewall-* script when your system gets a new IP address, add the following line to the /etc/dhclient-exit-hooks file. Please note that this example is loging the SIMPLE IPTABLES ruleset. Please use the correct rc.firewall-* name for your specific setup:

        /etc/rc.d/rc.firewall-iptables

  - pump : Many older Redhat distributions use this DHCP client. To re-run the rc-firewall-* script when your system gets a new IP address, add the following line to the /etc/pump.conf file. Please note that this example is loading the SIMPLE IPTABLES ruleset. Please use the correct rc.firewall-* name for your specific setup:

        script /etc/rc.d/rc.firewall-iptables

  - dhcpcd : Many older distros use this DHCP client. To re-run the rc-firewall-* script when your system gets a new IP address depends on which verion of dhcpcd you're using.

    For newer dhcpcd client versions, append the following line to the /etc/dhcpcd-[interface].exe file. Please note that you have to replace the [interface] text with the name of your Interface connecting to the Internet. For this example, we are going run the SIMPLE IPTABLES ruleset against the eth0 interface by editing the /etc/dhcpc/dhcpcd-eth0.exe file:

        /etc/rc.d/rc.firewall-iptables

    For old dhcpcd client versions, you need to figure out what script starts up dhcpcd (depends on the Linux distribution and it's version). From there, you need to replace the specific dhcpcd line with the folling line with the correct Internet-facing interface name. For this example, dhcpcd will run the SIMPLE IPTABLES ruleset against the eth0 interface:

        dhcpcd -c /etc/rc.d/rc.firewall eth0

Please also see the top of TrinityOS - Section 10 for additional help with strong firewall rulesets and Dynamic IP addresses.

Prev | Home | Next
( GUI ) - Are there any GUI firewall creation/management tools? | Up | ( MASQ and various networks ) - Can I use a cable modem (both bi-directional and with modem returns), DSL, satellite link, etc. to connect to the Internet and use IP Masquerade?