summaryrefslogtreecommitdiff
path: root/templates/protocols/static
diff options
context:
space:
mode:
Diffstat (limited to 'templates/protocols/static')
-rw-r--r--templates/protocols/static/route/node.def6
-rw-r--r--templates/protocols/static/route/node.tag/dhcp-interface/node.def23
-rw-r--r--templates/protocols/static/route/node.tag/next-hop/node.def8
-rw-r--r--templates/protocols/static/table/node.tag/route/node.def6
-rw-r--r--templates/protocols/static/table/node.tag/route/node.tag/dhcp-interface/node.def26
-rw-r--r--templates/protocols/static/table/node.tag/route/node.tag/next-hop/node.def2
6 files changed, 62 insertions, 9 deletions
diff --git a/templates/protocols/static/route/node.def b/templates/protocols/static/route/node.def
index 682ca944..e86812db 100644
--- a/templates/protocols/static/route/node.def
+++ b/templates/protocols/static/route/node.def
@@ -3,5 +3,7 @@ type: ipv4net
help: Static route
syntax:expression: exec "${vyatta_sbindir}/check_prefix_boundary $VAR(@)"
-commit:expression: $VAR(./next-hop/) != "" || $VAR(./blackhole/) != ""; \
- "Must add either a next-hop or blackhole for route $VAR(@)"
+commit:expression: $VAR(./next-hop/) != "" || $VAR(./blackhole/) != "" || $VAR(./dhcp-interface/) != ""; \
+ "Must add either a next-hop or blackhole or dhcp-interface for route $VAR(@)"
+commit:expression: $VAR(./next-hop/) == "" || $VAR(./dhcp-interface/) == ""; \
+ "Must configure only one of next-hop or dhcp-interface for route $VAR(@)"
diff --git a/templates/protocols/static/route/node.tag/dhcp-interface/node.def b/templates/protocols/static/route/node.tag/dhcp-interface/node.def
new file mode 100644
index 00000000..4942bf5f
--- /dev/null
+++ b/templates/protocols/static/route/node.tag/dhcp-interface/node.def
@@ -0,0 +1,23 @@
+type: txt
+help: DHCP interface that supplies the next-hop IP address for this static route
+allowed:
+ local -a array ;
+ array=( /var/lib/dhcp3/eth* /var/lib/dhcp3/br* /var/lib/dhcp3/bond* ) ;
+ echo -n ${array[@]##*/}
+create:
+ sudo /opt/vyatta/sbin/vyatta-update-static-route.pl --interface=$VAR(@) --route=$VAR(../@) --table=main --option=create
+ RIP=$(/opt/vyatta/sbin/vyatta-dhcp-helper.pl --interface=$VAR(@) --want=router)
+ vtysh -c "configure terminal" \
+ -c "ip route $VAR(../@) $RIP"
+update:
+ sudo /opt/vyatta/sbin/vyatta-update-static-route.pl --interface=$VAR(@) --route=$VAR(../@) --table=main --option=create
+ RIP=$(/opt/vyatta/sbin/vyatta-dhcp-helper.pl --interface=$VAR(@) --want=router)
+ vtysh -c "configure terminal" \
+ -c "ip route $VAR(../@) $RIP"
+delete:
+ sudo /opt/vyatta/sbin/vyatta-update-static-route.pl --interface=$VAR(@) --route=$VAR(../@) --table=main --option=delete
+ RIP=$(/opt/vyatta/sbin/vyatta-dhcp-helper.pl --interface=$VAR(@) --want=router)
+ if [ "$RIP" != "127.0.0.1" ]; then
+ vtysh -c "configure terminal" \
+ -c "no ip route $VAR(../@) $RIP"
+ fi
diff --git a/templates/protocols/static/route/node.tag/next-hop/node.def b/templates/protocols/static/route/node.tag/next-hop/node.def
index f5d5d417..e5106b02 100644
--- a/templates/protocols/static/route/node.tag/next-hop/node.def
+++ b/templates/protocols/static/route/node.tag/next-hop/node.def
@@ -1,17 +1,17 @@
tag:
type: ipv4
-help: Next-hop router [REQUIRED]
+help: Next-hop router
end:
if [[ -z "$VAR(./disable)" ]]
- then
+ then
if [[ ${COMMIT_ACTION} = 'DELETE' ]]
- then
+ then
if ! ${vyatta_sbindir}/vyatta-next-hop-check $VAR(../@) ipv4 address; then
exit 1;
fi
if ${vyatta_sbindir}/vyatta-gateway-static_route-check.pl \
"$VAR(../@)" "$VAR(@)"
- then
+ then
vtysh -c "configure terminal" \
-c "no ip route $VAR(../@) $VAR(@)"
fi
diff --git a/templates/protocols/static/table/node.tag/route/node.def b/templates/protocols/static/table/node.tag/route/node.def
index 682ca944..e86812db 100644
--- a/templates/protocols/static/table/node.tag/route/node.def
+++ b/templates/protocols/static/table/node.tag/route/node.def
@@ -3,5 +3,7 @@ type: ipv4net
help: Static route
syntax:expression: exec "${vyatta_sbindir}/check_prefix_boundary $VAR(@)"
-commit:expression: $VAR(./next-hop/) != "" || $VAR(./blackhole/) != ""; \
- "Must add either a next-hop or blackhole for route $VAR(@)"
+commit:expression: $VAR(./next-hop/) != "" || $VAR(./blackhole/) != "" || $VAR(./dhcp-interface/) != ""; \
+ "Must add either a next-hop or blackhole or dhcp-interface for route $VAR(@)"
+commit:expression: $VAR(./next-hop/) == "" || $VAR(./dhcp-interface/) == ""; \
+ "Must configure only one of next-hop or dhcp-interface for route $VAR(@)"
diff --git a/templates/protocols/static/table/node.tag/route/node.tag/dhcp-interface/node.def b/templates/protocols/static/table/node.tag/route/node.tag/dhcp-interface/node.def
new file mode 100644
index 00000000..177d153a
--- /dev/null
+++ b/templates/protocols/static/table/node.tag/route/node.tag/dhcp-interface/node.def
@@ -0,0 +1,26 @@
+type: txt
+help: DHCP interface that supplies the next-hop IP address for this static route
+allowed:
+ local -a array ;
+ array=( /var/lib/dhcp3/eth* /var/lib/dhcp3/br* /var/lib/dhcp3/bond* ) ;
+ echo -n ${array[@]##*/}
+create:
+ [ -n "$VAR(../../../table/@)" ] && table="table $VAR(../../../table/@)"
+ sudo /opt/vyatta/sbin/vyatta-update-static-route.pl --interface=$VAR(@) --route=$VAR(../@) --table=$VAR(../../@) --option=create
+ RIP=$(/opt/vyatta/sbin/vyatta-dhcp-helper.pl --interface=$VAR(@) --want=router)
+ vtysh -c "configure terminal" \
+ -c "ip route $VAR(../@) $RIP $table"
+update:
+ [ -n "$VAR(../../../table/@)" ] && table="table $VAR(../../../table/@)"
+ sudo /opt/vyatta/sbin/vyatta-update-static-route.pl --interface=$VAR(@) --route=$VAR(../@) --table=$VAR(../../@) --option=create
+ RIP=$(/opt/vyatta/sbin/vyatta-dhcp-helper.pl --interface=$VAR(@) --want=router)
+ vtysh -c "configure terminal" \
+ -c "ip route $VAR(../@) $RIP $table"
+delete:
+ [ -n "$VAR(../../../table/@)" ] && table="table $VAR(../../../table/@)"
+ sudo /opt/vyatta/sbin/vyatta-update-static-route.pl --interface=$VAR(@) --route=$VAR(../@) --table=$VAR(../../@) --option=delete
+ RIP=$(/opt/vyatta/sbin/vyatta-dhcp-helper.pl --interface=$VAR(@) --want=router)
+ if [ "$RIP" != "127.0.0.1" ]; then
+ vtysh -c "configure terminal" \
+ -c "no ip route $VAR(../@) $RIP $table"
+ fi \ No newline at end of file
diff --git a/templates/protocols/static/table/node.tag/route/node.tag/next-hop/node.def b/templates/protocols/static/table/node.tag/route/node.tag/next-hop/node.def
index 5fb54a8b..17f1f0dc 100644
--- a/templates/protocols/static/table/node.tag/route/node.tag/next-hop/node.def
+++ b/templates/protocols/static/table/node.tag/route/node.tag/next-hop/node.def
@@ -1,6 +1,6 @@
tag:
type: ipv4
-help: Next-hop router [REQUIRED]
+help: Next-hop router
end:
if [[ -n "$VAR(../../../table/@)" ]]
then