Expand LAN to 10.0.0.0/22 with static/reserved/dynamic/spare zones
Splits the LAN into four /24 zones: 10.0.0.0/24 static (no DHCP, DNS only), 10.0.1.0/24 fixed DHCP reservations by MAC, 10.0.2.0/24 dynamic DHCP pool, 10.0.3.0/24 spare/unused. ipadm now derives the required subnet from whether a host has a MAC, auto-assigns free IPs, and auto-migrates a host's IP when its MAC is added/removed. Migrated the existing archerc80 reservation from 10.0.0.2 to 10.0.1.2. Also fixes a latent bug found while doing this: dnsmasq's SIGHUP (`systemctl reload`) only re-reads /etc/hosts, not the conf-dir files ipadm writes to, so config changes were silently not applied on reload. ipadm now restarts dnsmasq instead. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
+10
-5
@@ -35,7 +35,7 @@ func renderDnsmasqConfig(hosts []Host) string {
|
||||
}
|
||||
|
||||
// applyDnsmasqConfig writes the generated config to path, validates the full
|
||||
// dnsmasq configuration, and on success reloads the dnsmasq service. On
|
||||
// dnsmasq configuration, and on success restarts the dnsmasq service. On
|
||||
// validation failure the previous file content is restored and the service
|
||||
// is left untouched.
|
||||
func applyDnsmasqConfig(path string, content string) error {
|
||||
@@ -62,8 +62,8 @@ func applyDnsmasqConfig(path string, content string) error {
|
||||
return fmt.Errorf("dnsmasq config invalid, change rolled back: %w", err)
|
||||
}
|
||||
|
||||
if err := reloadDnsmasq(); err != nil {
|
||||
return fmt.Errorf("%s written, but reload failed: %w", path, err)
|
||||
if err := restartDnsmasq(); err != nil {
|
||||
return fmt.Errorf("%s written, but restart failed: %w", path, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -76,8 +76,13 @@ func runDnsmasqTest() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func reloadDnsmasq() error {
|
||||
out, err := exec.Command("systemctl", "reload", "dnsmasq").CombinedOutput()
|
||||
// restartDnsmasq does a full restart rather than `systemctl reload`
|
||||
// (SIGHUP): dnsmasq's SIGHUP handler only re-reads /etc/hosts and a few
|
||||
// specific hosts-file options, not the conf-dir files this generated
|
||||
// hosts.conf lives in, so a reload would silently keep serving the old
|
||||
// host-record/dhcp-host entries.
|
||||
func restartDnsmasq() error {
|
||||
out, err := exec.Command("systemctl", "restart", "dnsmasq").CombinedOutput()
|
||||
if err != nil {
|
||||
return fmt.Errorf("%s", strings.TrimSpace(string(out)))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user