diff options
| author | Jan Tuomi <jan@jantuomi.fi> | 2025-07-10 12:11:58 +0300 |
|---|---|---|
| committer | Jan Tuomi <jan@jantuomi.fi> | 2025-07-10 12:11:58 +0300 |
| commit | 95466bf02741b67134ccb34163659a7a9c299c43 (patch) | |
| tree | d08c6fa3f20fef9fcbcd5f9eae0c1d88edd090d6 | |
| parent | ffd25cdb04f6a40bc9b95afd507042717b2f7fc5 (diff) | |
Fix wan0 dhcp issues by removing defaultrouter sysrc
| -rw-r--r-- | tasks/network.yml | 12 | ||||
| -rw-r--r-- | templates/etc_crontab.j2 | 2 | ||||
| -rw-r--r-- | templates/etc_rc.conf.j2 | 1 | ||||
| -rw-r--r-- | templates/usr_local_bin_gen_dhclient_conf.sh.j2 | 38 |
4 files changed, 4 insertions, 49 deletions
diff --git a/tasks/network.yml b/tasks/network.yml index dbfa43c..d582d0c 100644 --- a/tasks/network.yml +++ b/tasks/network.yml @@ -7,6 +7,10 @@ mode: "0644" register: resolv_conf +- name: Make resolv.conf immutable + shell: chflags schg /etc/resolv.conf + when: resolv_conf.changed + - name: Restart networking if interface configuration changed shell: service netif restart && service routing restart when: rc_conf.changed or resolv_conf.changed @@ -142,11 +146,3 @@ name: do_dyndns state: restarted when: not do_dyndns_start.changed and (do_dyndns_sh.changed or do_dyndns_rc.changed) - -- name: Install gen_dhclient_conf.sh - template: - src: usr_local_bin_gen_dhclient_conf.sh.j2 - dest: /usr/local/bin/gen_dhclient_conf.sh - owner: root - group: wheel - mode: "0755" diff --git a/templates/etc_crontab.j2 b/templates/etc_crontab.j2 index cdd34a4..f7a59d9 100644 --- a/templates/etc_crontab.j2 +++ b/templates/etc_crontab.j2 @@ -20,5 +20,3 @@ PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin # Adjust the time zone if the CMOS clock keeps local time, as opposed to # UTC time. See adjkerntz(8) for details. 1,31 0-5 * * * root adjkerntz -a -# Generate /etc/dhclient.conf -*/15 * * * * root sh -c 'gen_dhclient_conf.sh | logger -t gen_dhclient_conf' diff --git a/templates/etc_rc.conf.j2 b/templates/etc_rc.conf.j2 index 8d21ff6..641125b 100644 --- a/templates/etc_rc.conf.j2 +++ b/templates/etc_rc.conf.j2 @@ -8,7 +8,6 @@ moused_nondefault_enable="NO" # Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable dumpdev="AUTO" zfs_enable="YES" -defaultrouter="{{ lan_ipv4_gateway }}" ifconfig_igc0_name="lan0" ifconfig_igc1_name="wan0" ifconfig_lan0="inet {{ lan_ipv4_cidr }}" diff --git a/templates/usr_local_bin_gen_dhclient_conf.sh.j2 b/templates/usr_local_bin_gen_dhclient_conf.sh.j2 deleted file mode 100644 index 8c05f70..0000000 --- a/templates/usr_local_bin_gen_dhclient_conf.sh.j2 +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh - -set -eu - -IP=$(ifconfig wan0 | awk '/inet / {print $2}' | head -n1) -HOSTNAME=$(hostname) -CONFFILE=/etc/dhclient.conf -NEWFILE=$(mktemp) -if [ -f "${CONFFILE}" ]; then - OLDHASH=$(md5 -q "${CONFFILE}") -else - OLDHASH="doesnotexist" -fi - -cat <<EOF > "${NEWFILE}" -# This file is generated by $0 periodically. -# Changes will be overwritten. - -interface "wan0" { - send host-name "${HOSTNAME}"; -EOF - -if [ ! -z "$IP" ]; then -cat <<EOF >> "${NEWFILE}" - send dhcp-requested-address $IP; -EOF -fi - -echo "}" >> "${NEWFILE}" - -mv "${NEWFILE}" "${CONFFILE}" - -# If changed, restart dhclient wan0 -md5 -c "${OLDHASH}" "${CONFFILE}" 1>/dev/null 2>/dev/null -if [ ! "$?" = 0 ]; then - echo "Generated ${CONFFILE} has changed, restarting dhclient on wan0 (IP: ${IP})" - service dhclient restart wan0 -fi |
