summaryrefslogtreecommitdiff
path: root/scripts/vyatta-static-dhcp.pl
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/vyatta-static-dhcp.pl')
-rwxr-xr-xscripts/vyatta-static-dhcp.pl11
1 files changed, 8 insertions, 3 deletions
diff --git a/scripts/vyatta-static-dhcp.pl b/scripts/vyatta-static-dhcp.pl
index cf72930c..33afe3bb 100755
--- a/scripts/vyatta-static-dhcp.pl
+++ b/scripts/vyatta-static-dhcp.pl
@@ -14,7 +14,7 @@ GetOptions("interface=s" => \$iface,
"reason=s" => \$reason);
# check if an update is needed
-exit(0) if (($iface ne $dhcp) || (($oip eq $nip) && ($orouters eq $nrouters)) || ($reason ne "BOUND"));
+exit(0) if (($iface ne $dhcp) || (($oip eq $nip) && ($orouters eq $nrouters)));
logger("DHCP address on $iface updated to $nip,$nrouters from $oip,$orouters: Updating static route $route in table $table.");
my $tab;
if ($table eq "main") {
@@ -28,8 +28,13 @@ if ($orouters ne $nrouters) {
}
if (($oip ne $nip) && ($table ne "main") && ($route eq "0.0.0.0/0")) {
my $mark = 0x7fffffff + $table;
- system("sudo /sbin/iptables -t mangle -D OUTPUT -s $oip/32 -j MARK --set-mark $mark");
- system("sudo /sbin/iptables -t mangle -A OUTPUT -s $nip/32 -j MARK --set-mark $mark");
+ if ($oip ne "") {
+ system("sudo /sbin/iptables -t mangle -D OUTPUT -s $oip/32 -j MARK --set-mark $mark");
+ }
+ if ($nip ne "") {
+ system("sudo /sbin/iptables -t mangle -D OUTPUT -s $nip/32 -j MARK --set-mark $mark");
+ system("sudo /sbin/iptables -t mangle -A OUTPUT -s $nip/32 -j MARK --set-mark $mark");
+ }
}
sub logger {