summaryrefslogtreecommitdiff
path: root/data/templates/pppoe/ip-down.script.tmpl
blob: 9e6bd2a8e5164fadbdac4de022d88d903f29288d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/sh

# As PPPoE is an "on demand" interface we need to re-configure it when it
# becomes up
if [ "$6" != "{{ intf }}" ]; then
    exit
fi

# add some info to syslog
DIALER_PID=$(cat /var/run/{{ intf }}.pid)
logger -t pppd[$DIALER_PID] "executing $0"

{% if not on_demand %}
# See https://phabricator.vyos.net/T2248. Determine if we are enslaved to a
# VRF, this is needed to properly insert the default route.
VRF_NAME=""
if [ -d /sys/class/net/{{ intf }}/upper_* ]; then
    # Determine upper (VRF) interface
    VRF=$(basename $(ls -d /sys/class/net/{{ intf }}/upper_*))
    # Remove upper_ prefix from result string
    VRF=${VRF#"upper_"}
    # Populate variable to run in VR context
    VRF_NAME="vrf ${VRF_NAME}"
fi

# Always delete default route when interface goes down
vtysh -c "conf t" ${VRF_NAME} -c "no ip route 0.0.0.0/0 {{ intf }} ${VRF_NAME}"
{%   if ipv6_enable %}
vtysh -c "conf t" ${VRF_NAME} -c "no ipv6 route ::/0 {{ intf }} ${VRF_NAME}"
{%   endif %}
{% endif %}

{% if dhcpv6_pd_interfaces %}
# Start wide dhcpv6 client
systemctl stop dhcp6c@{{ intf }}.service
{% endif %}