Page MenuHomeVyOS Platform

Ability to ignore default-route from dhcpcd per interface
Closed, ResolvedPublicFEATURE REQUEST

Description

Based upon https://phabricator.vyos.net/T173#3019 it should be possible to make a per interface setting configurable. According to http://manpages.ubuntu.com/manpages/trusty/man8/dhclient-script.8.html the variable $interface should contain the interface to match on.

Details

Difficulty level
Easy (less than an hour)
Version
-
Is it a breaking change?
Perfectly compatible
Issue type
Feature (new functionality)

Event Timeline

I wrote this hook script
Any available options ignoring this code

Create and edit hook script file

nano /etc/dhcp/dhclient-enter-hooks.d/ignore-options

Copy and Paste this code into ignore-options hook script

confdir="/etc/dhcp/ignore_options"

if [ -f ${confdir}/${interface} ]
then
    case ${reason} in
        BOUND|RENEW|REBIND|REBOOT)
            options=$(cat ${confdir}/${interface} | grep -v "^#")
            for option in ${options}
            do
                eval "var=\$${option}"
                if [ -n "${var}" ]; then
                    unset ${option}
                fi
            done
        ;;
    esac
fi

Create directory

mkdir /etc/dhcp/ignore_options

Create interface file and edit

nano /etc/dhcp/ignore_options/eth0

then add line by line options into interface conf file
for examle.

new_routers
new_static_routes
new_rfc3442_classless_static_routes
new_domain_name
new_domain_name_servers
new_netbios_name_servers
new_ntp_servers

ALL available options

new_alias_ip_address
new_ip_address 
new_host_name 
new_network_number 
new_subnet_mask
new_broadcast_address 
new_routers 
new_static_routes
new_rfc3442_classless_static_routes
new_domain_name 
new_domain_search 
new_domain_name_servers
new_netbios_name_servers 
new_netbios_scope
new_ntp_servers
new_ip6_address 
new_ip6_prefix ip6_prefixlen
new_dhcp6_domain_search 
new_dhcp6_name_servers

I'm sorry for the belated response. This is great. Thanks for your contribution @fatihusta! Once testing checks out I'll add this to my CLI integration todo.

syncer changed the subtype of this task from "Task" to "Feature Request".Oct 19 2018, 9:27 AM
Viacheslav claimed this task.
Viacheslav added a subscriber: Viacheslav.

Fixed in T2997

set interfaces ethernet eth1 address 'dhcp'
set interfaces ethernet eth1 dhcp-options no-default-route
erkin set Is it a breaking change? to Unspecified (possibly destroys the router).
erkin set Issue type to Feature (new functionality).
dmbaturin changed Is it a breaking change? from Unspecified (possibly destroys the router) to Perfectly compatible.
dmbaturin removed a subscriber: VyOS 1.2 Crux.