summaryrefslogtreecommitdiff
path: root/templates/interfaces/tunnel/node.def
diff options
context:
space:
mode:
authorCarl Byington <carl@five-ten-sg.com>2015-05-11 15:52:55 -0700
committerDaniil Baturin <daniil@baturin.org>2015-06-13 19:01:57 +0200
commit45e88676db35ed80a7d7868fe6eb189c43419d0c (patch)
tree01552c08018ecfb0b25a4f3ca6d0dc3544273d52 /templates/interfaces/tunnel/node.def
parent3e91e4b9bfc804aefdf3eb252ab9830dfdfbe697 (diff)
downloadvyatta-cfg-system-45e88676db35ed80a7d7868fe6eb189c43419d0c.tar.gz
vyatta-cfg-system-45e88676db35ed80a7d7868fe6eb189c43419d0c.zip
allow dhcp interface for the local end of a tunnel
Signed-off-by: Daniil Baturin <daniil@baturin.org>
Diffstat (limited to 'templates/interfaces/tunnel/node.def')
-rw-r--r--templates/interfaces/tunnel/node.def55
1 files changed, 33 insertions, 22 deletions
diff --git a/templates/interfaces/tunnel/node.def b/templates/interfaces/tunnel/node.def
index 795168f6..5fbe205e 100644
--- a/templates/interfaces/tunnel/node.def
+++ b/templates/interfaces/tunnel/node.def
@@ -6,8 +6,10 @@ val_help: <tunN>; Tunnel interface name
syntax:expression: pattern $VAR(@) "^tun[0-9]+$" \
; "tunnel must be (tun0-tun999)"
-commit:expression: $VAR(./local-ip/) != "" ; \
- "Must configure the tunnel local-ip for $VAR(@)"
+commit:expression: $VAR(./local-ip/) != "" || $VAR(./dhcp-interface/) != ""; \
+ "Must configure either local-ip or dhcp-interface for tunnel $VAR(@)"
+commit:expression: $VAR(./local-ip/) == "" || $VAR(./dhcp-interface/) == ""; \
+ "Must configure only one of local-ip or dhcp-interface for tunnel $VAR(@)"
commit:expression: $VAR(./encapsulation/) != "" ; \
"Must configure the tunnel encapsulation for $VAR(@)"
commit:expression:
@@ -34,44 +36,53 @@ create:
if [ x$VAR(./multicast/@) == xenable ]; then
MC="multicast on allmulticast on";
fi
+ if [ -n "$VAR(./local-ip/@)" ]; then
+ LIP=$VAR(./local-ip/@)
+ else
+ LIP=$(/opt/vyatta/sbin/vyatta-dhcp-helper.pl --interface=$VAR(./dhcp-interface/@) --want=local)
+ fi
case "$VAR(./encapsulation/@)" in
"gre" | "ipip" | "sit")
- if [ -n "$VAR(./parameters/ip/bridge-group/)" ] ; then
- echo "interfaces tunnel $VAR(@): Tunnel encapsulation type must be gre-bridge if a bridge group is defined";
- exit 1;
- fi
- if [ -z "$VAR(./parameters/ip/tos/@)" ]; then
- TOS="tos inherit"
- fi
- if [ -z "$VAR(./parameters/ip/ttl/@)" ]; then
- TTL="ttl 255"
- fi
+ if [ -n "$VAR(./parameters/ip/bridge-group/)" ] ; then
+ echo "interfaces tunnel $VAR(@): Tunnel encapsulation type must be gre-bridge if a bridge group is defined";
+ exit 1;
+ fi
+ if [ -n "$VAR(./parameters/ip/tos/@)" ]; then
+ TOS="tos $VAR(./parameters/ip/tos/@)"
+ else
+ TOS="tos inherit"
+ fi
+ if [ -n "$VAR(./parameters/ip/ttl/@)" ]; then
+ TTL="ttl $VAR(./parameters/ip/ttl/@)"
+ else
+ TTL="ttl 255"
+ fi
if [ -n "$VAR(./parameters/ip/key/@)" ]; then
- KEY="key $VAR(./parameters/ip/key/@)";
+ KEY="key $VAR(./parameters/ip/key/@)"
fi
if [ "$VAR(./encapsulation/@)" == "gre" ] && [ -z $VAR(./remote-ip/) ]; then
- ip tunnel add $VAR(@) local $VAR(./local-ip/@) mode gre $KEY $TTL $TOS
+ ip tunnel add $VAR(@) local $LIP mode gre $KEY $TTL $TOS
else
- ip tunnel add $VAR(@) local $VAR(./local-ip/@) remote $VAR(./remote-ip/@) mode $VAR(./encapsulation/@) $KEY $TTL $TOS
+ ip tunnel add $VAR(@) local $LIP remote $VAR(./remote-ip/@) mode $VAR(./encapsulation/@) $KEY $TTL $TOS
fi
- if [ -z "`ip tun sh | grep $VAR(@)`" ]; then
- echo interfaces tunnel $VAR(@): error creating tunnel interface
- exit 1
+ if [ -z "`ip tunnel show | grep $VAR(@)`" ]; then
+ echo interfaces tunnel $VAR(@): error creating tunnel interface
+ exit 1
fi
;;
"gre-bridge")
- ip link add $VAR(@) type gretap local $VAR(./local-ip/@) remote $VAR(./remote-ip/@) ||
+ ip link add $VAR(@) type gretap local $LIP remote $VAR(./remote-ip/@) ||
echo "interfaces tunnel $VAR(@): error creating tunnel interface"
;;
"ipip6" | "ip6ip6")
- ip -6 tunnel add $VAR(@) local $VAR(./local-ip/@) remote $VAR(./remote-ip/@) mode $VAR(./encapsulation/@) ||
+ ip -6 tunnel add $VAR(@) local $LIP remote $VAR(./remote-ip/@) mode $VAR(./encapsulation/@) ||
echo "interfaces tunnel $VAR(@): error creating tunnel interface"
;;
esac
- ip link set $VAR(@) $MC up ||
+ ip link set $VAR(@) $MC up ||
echo "interfaces tunnel $VAR(@): error setting tunnel interface active"
-delete:
+delete:
/opt/vyatta/sbin/vyos-update-nhrp.pl --checkref --tun $VAR(@)
ip link set $VAR(@) down
case "$VAR(./encapsulation/@)" in