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 /templates | |
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 'templates')
-rw-r--r-- | templates/protocols/static/table/node.tag/route/node.tag/dhcp-interface/node.def | 49 |
1 files changed, 36 insertions, 13 deletions
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 index 177d153a..a1b1d08c 100644 --- 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 @@ -5,22 +5,45 @@ allowed: 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) + ifc="$VAR(@)" + route="$VAR(../@)" + table="$VAR(../../@)" + sudo /opt/vyatta/sbin/vyatta-update-static-route.pl --interface=$ifc --route=$route --table=$table --option=create + RIP=$(/opt/vyatta/sbin/vyatta-dhcp-helper.pl --interface=$ifc --want=router) vtysh -c "configure terminal" \ - -c "ip route $VAR(../@) $RIP $table" + -c "ip route $route $RIP table $table" + if [ "$route" == "0.0.0.0/0" ]; then + LIP=$(/opt/vyatta/sbin/vyatta-dhcp-helper.pl --interface=$ifc --want=local) + MARK=$(dc 0x7fffffff $table + p) + sudo /sbin/iptables -t mangle -A OUTPUT -s $LIP/32 -j MARK --set-mark $MARK + fi 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) + ifc="$VAR(@)" + route="$VAR(../@)" + table="$VAR(../../@)" + sudo /opt/vyatta/sbin/vyatta-update-static-route.pl --interface=$ifc --route=$route --table=$table --option=create + RIP=$(/opt/vyatta/sbin/vyatta-dhcp-helper.pl --interface=$ifc --want=router) vtysh -c "configure terminal" \ - -c "ip route $VAR(../@) $RIP $table" + -c "ip route $route $RIP table $table" + if [ "$route" == "0.0.0.0/0" ]; then + LIP=$(/opt/vyatta/sbin/vyatta-dhcp-helper.pl --interface=$ifc --want=local) + MARK=$(dc 0x7fffffff $table + p) + sudo /sbin/iptables -t mangle -A OUTPUT -s $LIP/32 -j MARK --set-mark $MARK + fi 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) + ifc="$VAR(@)" + route="$VAR(../@)" + table="$VAR(../../@)" + sudo /opt/vyatta/sbin/vyatta-update-static-route.pl --interface=$ifc --route=$route --table=$table --option=delete + RIP=$(/opt/vyatta/sbin/vyatta-dhcp-helper.pl --interface=$ifc --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 + -c "no ip route $route $RIP table $table" + fi + if [ "$route" == "0.0.0.0/0" ]; then + LIP=$(/opt/vyatta/sbin/vyatta-dhcp-helper.pl --interface=$ifc --want=local) + if [ "$LIP" != "127.0.0.1" ]; then + MARK=$(dc 0x7fffffff $table + p) + sudo /sbin/iptables -t mangle -D OUTPUT -s $LIP/32 -j MARK --set-mark $MARK + fi + fi |