1
24.1 Legacy Series / Strange behaviour of dhclient-script
« on: July 13, 2024, 04:55:29 am »
Hello all,
today after an update and reboot of my OPNsense installation the IPv4 connection was gone. IPv6 still worked fine. After digging somewhat in that problem I found that the default route for the WAN interface wasn't set.
Starting dhclient manually from the shell resolved that issue until the next reboot. After digging somewhat deeper the only configuration difference I could find was in the dhclient-script from OPNsense. I assume, when starting manually from the command line the original /sbin/dhclient-script is used and in the dhclient configuration from OPNsense is the one under /usr/local/opnsense/scripts/interfaces/dhclient-script is used.
So out of curiosity I patched the add_new_routes function in the OPNsense script with the one from the original script and after a reboot, my IPv4 connection was back up
Since I'm be no means a network guy this was probably caused by a misconfiguration on my part somewhere. But in any case here is the source code from what I've done.
Some facts:
OPNsense 24.1.10_2-amd64
ISP: Vodafone Germany Cable (if it matters)
Best regards,
Frank
today after an update and reboot of my OPNsense installation the IPv4 connection was gone. IPv6 still worked fine. After digging somewhat in that problem I found that the default route for the WAN interface wasn't set.
Starting dhclient manually from the shell resolved that issue until the next reboot. After digging somewhat deeper the only configuration difference I could find was in the dhclient-script from OPNsense. I assume, when starting manually from the command line the original /sbin/dhclient-script is used and in the dhclient configuration from OPNsense is the one under /usr/local/opnsense/scripts/interfaces/dhclient-script is used.
So out of curiosity I patched the add_new_routes function in the OPNsense script with the one from the original script and after a reboot, my IPv4 connection was back up
Since I'm be no means a network guy this was probably caused by a misconfiguration on my part somewhere. But in any case here is the source code from what I've done.
Code: [Select]
add_new_routes()
{
# RFC 3442: If the DHCP server returns both a Classless Static
# Routes option and a Router option, the DHCP client MUST ignore
# the Router option.
#
# DHCP clients that support this option (Classless Static Routes)
# MUST NOT install the routes specified in the Static Routes
# option (option code 33) if both a Static Routes option and the
# Classless Static Routes option are provided.
if [ -n "$new_classless_routes" ]; then
fill_classless_routes "$new_classless_routes"
$LOGGER "New Classless Static Routes ($interface): $classless_routes"
set $classless_routes
while [ $# -gt 1 ]; do
if [ "0.0.0.0" = "$2" ]; then
route add "$1" -iface "$interface"
else
route add "$1" "$2"
fi
shift; shift
done
return
fi
for router in $new_routers; do
# Here comes the copy 'n pasted part
if is_default_interface; then
if [ "$new_ip_address" = "$router" ]; then
route add default -iface $router >/dev/null 2>&1
else
if [ "$new_subnet_mask" = "255.255.255.255" ]; then
route add "$router" -iface "$interface" >/dev/null 2>&1
fi
route add default $router >/dev/null 2>&1
fi
fi
# /usr/local/sbin/ifctl -i ${interface} -4rd -a ${router} # This is the original line from the opnsense script, which i commented out
...
And of course the is_default_interface function was also pasted in.Some facts:
OPNsense 24.1.10_2-amd64
ISP: Vodafone Germany Cable (if it matters)
Best regards,
Frank