diff options
author | Christian Poessinger <christian@poessinger.com> | 2020-08-15 10:44:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-15 10:44:02 +0200 |
commit | e8d97cf67c539454e05feb74d404df9c239d7ad1 (patch) | |
tree | f52d734917f311e607133d0b845a3b612d7965f8 /src | |
parent | 9a85c946e5f4d125276da432bb3055d1369d47fd (diff) | |
parent | 93fb90b4f1eca5a9d1828714e06123bb22a7a219 (diff) | |
download | vyos-1x-e8d97cf67c539454e05feb74d404df9c239d7ad1.tar.gz vyos-1x-e8d97cf67c539454e05feb74d404df9c239d7ad1.zip |
Merge pull request #525 from sever-sever/T2277
dhclient: T2277: Hook for default route in vrf
Diffstat (limited to 'src')
-rw-r--r-- | src/etc/dhcp/dhclient-enter-hooks.d/03-vyos-ipwrapper | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/etc/dhcp/dhclient-enter-hooks.d/03-vyos-ipwrapper b/src/etc/dhcp/dhclient-enter-hooks.d/03-vyos-ipwrapper index f1167fcd2..60e001af7 100644 --- a/src/etc/dhcp/dhclient-enter-hooks.d/03-vyos-ipwrapper +++ b/src/etc/dhcp/dhclient-enter-hooks.d/03-vyos-ipwrapper @@ -20,6 +20,7 @@ function iptovtysh () { local VTYSH_NETADDR="" local VTYSH_GATEWAY="" local VTYSH_DEV="" + local VTYSH_VRF_NAME=$(ip -d link show dev $interface | grep $interface | awk '{print $9}') # convert default route to 0.0.0.0/0 if [ "$4" == "default" ] ; then VTYSH_NETADDR="0.0.0.0/0" @@ -40,7 +41,14 @@ function iptovtysh () { elif [ "$7" == "dev" ]; then VTYSH_DEV=$8 fi - VTYSH_CMD="ip route $VTYSH_NETADDR $VTYSH_GATEWAY $VTYSH_DEV tag $VTYSH_TAG $VTYSH_DISTANCE" + + # check if vrf is present + if [ $(ip -d link show dev $interface | grep vrf | wc -l) -eq 0 ]; then + VTYSH_CMD="ip route $VTYSH_NETADDR $VTYSH_GATEWAY $VTYSH_DEV tag $VTYSH_TAG $VTYSH_DISTANCE" + elif [ $(ip -d link show dev $interface | grep vrf | wc -l) -eq 1 ]; then + VTYSH_CMD="ip route $VTYSH_NETADDR $VTYSH_GATEWAY $VTYSH_DEV tag $VTYSH_TAG $VTYSH_DISTANCE vrf $VTYSH_VRF_NAME" + fi + # delete route if the command is "del" if [ "$3" == "del" ] ; then VTYSH_CMD="no $VTYSH_CMD" |