diff options
author | Carl Byington <carl@five-ten-sg.com> | 2015-01-12 16:28:40 -0800 |
---|---|---|
committer | Daniil Baturin <daniil@baturin.org> | 2015-05-03 19:16:23 +0200 |
commit | 9655fecdaaafe5887617d6f3d97a76a24e00e413 (patch) | |
tree | 7fec88617aac6a3eafa1b21db141f7f276d58cd6 /scripts | |
parent | 3f28021c87ecc1c9849925efe6e87627b4ef8b62 (diff) | |
download | vyatta-cfg-quagga-9655fecdaaafe5887617d6f3d97a76a24e00e413.tar.gz vyatta-cfg-quagga-9655fecdaaafe5887617d6f3d97a76a24e00e413.zip |
allow dhcp-interface for the next-hop on static routes
Signed-off-by: Daniil Baturin <daniil@baturin.org>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/vyatta-static-dhcp.pl | 22 | ||||
-rwxr-xr-x | scripts/vyatta-update-static-route.pl | 2 |
2 files changed, 17 insertions, 7 deletions
diff --git a/scripts/vyatta-static-dhcp.pl b/scripts/vyatta-static-dhcp.pl index 2bec6043..91a4696d 100755 --- a/scripts/vyatta-static-dhcp.pl +++ b/scripts/vyatta-static-dhcp.pl @@ -2,25 +2,35 @@ use Getopt::Long; use strict; -my ($iface, $dhcp, $route, $table, $nip, $oip, $reason); +my ($iface, $dhcp, $route, $table, $nip, $oip, $nrouters, $orouters, $reason); GetOptions("interface=s" => \$iface, "dhcp=s" => \$dhcp, "route=s" => \$route, "table=s" => \$table, + "new_ip=s" => \$nip, + "old_ip=s" => \$oip, "new_routers=s" => \$nrouters, "old_routers=s" => \$orouters, "reason=s" => \$reason); # check if an update is needed -exit(0) if (($iface ne $dhcp) || ($orouters eq $nrouters) || ($reason ne "BOUND")); -logger("DHCP address on $iface updated to $nip from $oip: Updating static route $route in table $table."); +exit(0) if (($iface ne $dhcp) || (($oip eq $nip) && ($orouters eq $nrouters)) || ($reason ne "BOUND")); +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") { - $table = ""; + $tab = ""; } else { - $table = "table $table"; + $tab = "table $table"; +} +if ($orouters ne $nrouters) { + 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 = 0x7ffffff + $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"); } -system("vtysh -c 'configure terminal' -c 'ip route $route $nrouters $table' "); sub logger { my $msg = pop(@_); diff --git a/scripts/vyatta-update-static-route.pl b/scripts/vyatta-update-static-route.pl index 5ac98fcd..557b2011 100755 --- a/scripts/vyatta-update-static-route.pl +++ b/scripts/vyatta-update-static-route.pl @@ -17,7 +17,7 @@ my $dhcp_hook = ''; if ($option eq 'create') { $dhcp_hook =<<EOS; #!/bin/sh -/opt/vyatta/bin/sudo-users/vyatta-static-dhcp.pl --interface=\"\$interface\" --dhcp=\"$iface\" --route=\"$route\" --table=\"$table\" --new_routers=\"\$new_routers\" --old_routers=\"\$old_routers\" --reason=\"\$reason\" +/opt/vyatta/bin/sudo-users/vyatta-static-dhcp.pl --interface=\"\$interface\" --dhcp=\"$iface\" --route=\"$route\" --table=\"$table\" --new_ip=\"\$new_ip_address\" --old_ip=\"\$old_ip_address\" --new_routers=\"\$new_routers\" --old_routers=\"\$old_routers\" --reason=\"\$reason\" EOS } |