summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthew Kobayashi <matthew@kobayashi.au>2025-04-22 12:06:04 +1000
committerMatthew Kobayashi <matthew@kobayashi.au>2025-04-22 12:20:30 +1000
commit2ff0981bfe1231fc430507b4b5f8031c05005db1 (patch)
tree3286aece3a95ee8bff46e35ec39809c9bff0048f /src
parent39e2a908e5d141911820c20bb1a5a5b1b96fa457 (diff)
downloadvyos-1x-2ff0981bfe1231fc430507b4b5f8031c05005db1.tar.gz
vyos-1x-2ff0981bfe1231fc430507b4b5f8031c05005db1.zip
dhclient: T6253: Respect `no-default-route`
Diffstat (limited to 'src')
-rw-r--r--src/etc/dhcp/dhclient-enter-hooks.d/06-vyos-nodefaultroute20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/etc/dhcp/dhclient-enter-hooks.d/06-vyos-nodefaultroute b/src/etc/dhcp/dhclient-enter-hooks.d/06-vyos-nodefaultroute
new file mode 100644
index 000000000..38f674276
--- /dev/null
+++ b/src/etc/dhcp/dhclient-enter-hooks.d/06-vyos-nodefaultroute
@@ -0,0 +1,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