Page MenuHomePhabricator

/etc/hosts is not updated when using hostfile-update on dhcp server in rc5
Closed, ResolvedPublicBUG

Description

I have just upgraded to vyos 1.2.0-rc5 and have an issue with /etc/hosts not being updated:

The vyos DHCP server config chunk:

shared-network-name VLAN101 {
    subnet 172.16.101.0/24 {
        default-router 172.16.101.254
        dns-server 172.16.101.254
        domain-name guest.domain.co.uk
        lease 3600
        range 0 {
            start 172.16.101.1
            stop 172.16.101.250
        }
    }
}

Creates in /etc/dhcp/dhcpd.conf

shared-network VLAN101 {
    
    subnet 172.16.101.0 netmask 255.255.255.0 {
        option domain-name-servers 172.16.101.254;
        option routers 172.16.101.254;
        option domain-name "guest.domain.co.uk";
        default-lease-time 3600;
        max-lease-time 3600;
        range 172.16.101.1 172.16.101.250;
        on commit { set shared-networkname = "VLAN101"; }
    }
}

Unfortunately, the on commit within this shared network instantiation overrides the global on commit that is used to update /etc/hosts when a new lease is handed out. This causes addresses handed out by DHCP to not be available in DNS.

I have removed the line on commit { set shared-networkname = "VLAN101"; } from my dhcpd config and the functionality seems to work correctly, but this will be overwritten any time anything in the dhcp server is changed and the file is regenerated.

For comparison, here is the chunk of dhcpd.conf generated by our old vyos system, version 1.2.0-rolling-201806081250

shared-network VLAN101 {

	subnet 172.16.101.0 netmask 255.255.255.0 {
		option domain-name-servers 172.16.101.254;
		option routers 172.16.101.254;
		option domain-name "guest.domain.co.uk";
		default-lease-time 3600;
		max-lease-time 3600;
		range 172.16.101.1 172.16.101.250;
	}
}

Is the shared-networkname being set for a reason, or can we just remove line 213 of dhcp_server.py at https://github.com/vyos/vyos-1x/blame/current/src/conf_mode/dhcp_server.py#L213

Details

Commits
Restricted Diffusion Commit
Difficulty level
Unknown (require assessment)
Version
1.2.0-rc5
Why the issue appeared?
Will be filled on close

It looks like this change was made in https://phabricator.vyos.net/T726 before the python rewrite.

syncer triaged this task as Low priority.Nov 7 2018, 4:59 PM
hagbard claimed this task.Nov 8 2018, 5:20 PM

Hi @thinkl33t ,

can you please share the part of your config addressing this issue? ('show config comm').
Thx.

I've done a bit of fiddling with this today on a test VyOS 1.2.0-rc6, Attempting to set a custom option and pass it through to the leases file. Unfortunately I wasn't successful.

What did work was moving the *entire* on commit from the top-level into the shared-network itself. Its a bit of a hack, but so was the thing we're trying to work around.

https://github.com/vyos/vyos-1x/pull/57 implements this

Diffusion closed this task as Resolved by committing Restricted Diffusion Commit.Nov 8 2018, 6:42 PM
Diffusion added a commit: Restricted Diffusion Commit.