summaryrefslogtreecommitdiff
path: root/src/etc/dhcp/dhclient-enter-hooks.d/06-vyos-nodefaultroute
blob: 38f674276300add49ee0fc20de713f83db66e5e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# Don't add default route if no-default-route is configured for interface

# As configuration is not available to cli-shell-api at the first boot, we must use vyos.config, which contains a workaround for this
function get_no_default_route {
python3 - <<PYEND
from vyos.config import Config
import os

config = Config()
if config.exists('interfaces'):
    iface_types = config.list_nodes('interfaces')
    for iface_type in iface_types:
        if config.exists("interfaces {} {} dhcp-options no-default-route".format(iface_type, os.environ['interface'])):
            print("True")
PYEND
}

if [[ "$(get_no_default_route)" == 'True' ]]; then
    new_routers=""
fi