############################################################################### # # # IPFire.org - A linux based firewall # # Copyright (C) 2007-2022 IPFire Team # # # # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # # the Free Software Foundation, either version 3 of the License, or # # (at your option) any later version. # # # # This program is distributed in the hope that it will be useful, # # but WITHOUT ANY WARRANTY; without even the implied warranty of # # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # # GNU General Public License for more details. # # # # You should have received a copy of the GNU General Public License # # along with this program. If not, see . # # # ############################################################################### . /etc/sysconfig/rc . $rc_functions . /etc/init.d/networking/functions.network eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings) dhcpcd_up() { set | grep "^new_" | sed "s|^new_||g" | \ sort > /var/ipfire/dhcpc/dhcpcd-$interface.info #Check if this was the Red device... if [ ! "$interface" == "$RED_DEV" ]; then exit 0; fi # Check if we have to restart the services at update [ ! -e "/var/ipfire/red/active" ] && update=1; if [ "$old_domain_name_service" != "$new_domain_name_service" ]; then update=1; fi if [ "$old_ip_address" != "$new_ip_address" ]; then update=1; fi if [ "$old_routers" != "$new_routers" ]; then update=1; fi # Get DNS from dhcp /etc/rc.d/helper/getdnsfromdhcpc.pl 1 > /var/run/dns1 /etc/rc.d/helper/getdnsfromdhcpc.pl 2 > /var/run/dns2 #Get IP Address echo -n "$new_ip_address" > /var/ipfire/red/local-ipaddress # Get default gateway if [ -n "${new_routers}" ]; then grep -v -E "\" /etc/hosts > /tmp/hosts echo "$new_routers gateway" >> /tmp/hosts mv /tmp/hosts /etc/hosts fi if [ $update ]; then # Consider RED being active touch /var/ipfire/red/active if [ -n "${new_routers}" ]; then echo -n "${new_routers}" > /var/ipfire/red/remote-ipaddress fi logger -p local0.info -t dhcpcd.exe[$$] "$interface has been (re)configured with IP=$new_ip_address" run_subdir ${rc_base}/init.d/networking/red.up/ fi } dhcpcd_down() { set | grep "^new_" | sed "s|^new_||g" | \ sort > /var/ipfire/dhcpc/dhcpcd-$interface.info # Remove DNS servers rm -f /var/run/dns1 /var/run/dns2 # Consider RED to be no longer active rm -f /var/ipfire/red/active if [ ! $reason == "PREINIT" ]; then logger -p local0.info -t dhcpcd.exe[$$] "${interface} has been brought down ($reason)" run_subdir ${rc_base}/init.d/networking/red.down/ fi # Remove any configured IP address from the device ip addr flush dev "${interface}" &>/dev/null return 0 } case "${reason}" in BOUND|INFORM|REBIND|REBOOT|RENEW|TIMEOUT|STATIC) dhcpcd_up ;; PREINIT|EXPIRE|FAIL|IPV4LL|NAK|RELEASE|STOP) dhcpcd_down ;; # Ignored events where we do not need to do anything STOPPED|CARRIER|NOCARRIER) ;; *) logger -p "local0.info" -t "dhcpcd.exe[$$]" "Unhandled DHCP event: ${reason}" ;; esac