From 37ddd5f9f2fb584e467374b59ad89e49f0ff1b6f Mon Sep 17 00:00:00 2001 From: Carl Byington Date: Wed, 22 Apr 2015 11:12:34 -0700 Subject: remove old routes when dhcp gateway changes, avoid routing thru 127.0.0.1 Signed-off-by: Daniil Baturin --- scripts/vyatta-static-dhcp.pl | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/vyatta-static-dhcp.pl b/scripts/vyatta-static-dhcp.pl index 33afe3bb..fa4a7f62 100755 --- a/scripts/vyatta-static-dhcp.pl +++ b/scripts/vyatta-static-dhcp.pl @@ -24,14 +24,19 @@ else { $tab = "table $table"; } if ($orouters ne $nrouters) { - system("vtysh -c 'configure terminal' -c 'ip route $route $nrouters $tab' "); + if ($orouters ne "") { + system("vtysh -c 'configure terminal' -c 'no ip route $route $orouters $tab' "); + } + if (($nrouters ne "") && ($nrouters ne "127.0.0.1")) { + system("vtysh -c 'configure terminal' -c 'ip route $route $nrouters $tab' "); + } } if (($oip ne $nip) && ($table ne "main") && ($route eq "0.0.0.0/0")) { my $mark = 0x7fffffff + $table; if ($oip ne "") { system("sudo /sbin/iptables -t mangle -D OUTPUT -s $oip/32 -j MARK --set-mark $mark"); } - if ($nip ne "") { + if (($nip ne "") && ($nip ne "127.0.0.1")) { 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"); } -- cgit v1.2.3