summaryrefslogtreecommitdiff
path: root/scripts/vyatta-tunnel-dhcp.pl
diff options
context:
space:
mode:
authorCarl Byington <carl@five-ten-sg.com>2015-05-04 15:54:41 -0700
committerDaniil Baturin <daniil@baturin.org>2015-06-13 19:01:46 +0200
commit0dcde1edee1b6c84feb7a4dc0b690909a7b5d498 (patch)
tree0d80ab1094a21be43955638f02f02a24e010fb5c /scripts/vyatta-tunnel-dhcp.pl
parent593881742424f3499f32cc75d86786e7f948b2a1 (diff)
downloadvyatta-cfg-system-0dcde1edee1b6c84feb7a4dc0b690909a7b5d498.tar.gz
vyatta-cfg-system-0dcde1edee1b6c84feb7a4dc0b690909a7b5d498.zip
allow dhcp interface for the local end of a tunnel
Signed-off-by: Daniil Baturin <daniil@baturin.org>
Diffstat (limited to 'scripts/vyatta-tunnel-dhcp.pl')
-rw-r--r--scripts/vyatta-tunnel-dhcp.pl25
1 files changed, 25 insertions, 0 deletions
diff --git a/scripts/vyatta-tunnel-dhcp.pl b/scripts/vyatta-tunnel-dhcp.pl
new file mode 100644
index 00000000..4283b30a
--- /dev/null
+++ b/scripts/vyatta-tunnel-dhcp.pl
@@ -0,0 +1,25 @@
+#!/usr/bin/perl
+use Getopt::Long;
+use strict;
+
+my ($iface, $dhcp, $tunnel, $nip, $oip, $reason);
+GetOptions("interface=s" => \$iface,
+ "dhcp=s" => \$dhcp,
+ "tunnel=s" => \$tunnel,
+ "new_ip=s" => \$nip,
+ "old_ip=s" => \$oip,
+ "reason=s" => \$reason);
+
+# check if an update is needed
+exit(0) if (($iface ne $dhcp) || ($oip eq $nip) || ($reason ne "BOUND"));
+logger("DHCP address on $iface updated to $nip from $oip: Updating tunnel $tunnel configuration.");
+system("sudo ip tunnel change $tunnel local $nip");
+
+sub logger {
+ my $msg = pop(@_);
+ my $FACILITY = "daemon";
+ my $LEVEL = "notice";
+ my $TAG = "tunnel-dhclient-hook";
+ my $LOGCMD = "logger -t $TAG -p $FACILITY.$LEVEL";
+ system("$LOGCMD $msg");
+}