rtr7 / router7

router7 is a small home internet router completely written in Go. It is implemented as a gokrazy appliance.
https://router7.org
Apache License 2.0
2.69k stars 110 forks source link

dhcp4: remove old IP address from interface when getting a new one #57

Closed stapelberg closed 4 years ago

stapelberg commented 4 years ago

Currently, when the upstream DHCP4 server hands out a new IP address, we end up having two addresses on uplink0:

4: uplink0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq qlen 1000
    inet 212.51.156.82/24 brd 212.51.156.255 scope global uplink0
       valid_lft forever preferred_lft forever
    inet 212.51.156.17/24 brd 212.51.156.255 scope global secondary uplink0
       valid_lft forever preferred_lft forever

We should ensure that any IP addresses that dhcp4 added to the interface will be removed when a different IP address is obtained. We don’t need to immediately remove addresses when we no longer have the lease (it might still work!), though.

This improvement was prompted by DHCP4 outage https://as13030.net/status/?ticket=OPS-32 ;)

stapelberg commented 4 years ago

Stream recording: https://youtu.be/NiMh4CdL8hM