I'm looking for feedback on the following patch, which is designed to
keep the entry in /etc/hosts for the current DHCP IP address up to date.

Without a valid entry in /etc/hosts for the hostname, various tools fail
to work properly (one of which is pppd when used as a server rather than
a client, and when it needs to auto-allocate the local end address for a
PtP link).

Any objections to this patch?

> Index: package/base-files/files/usr/share/udhcpc/default.script
> ===================================================================
> --- package/base-files/files/usr/share/udhcpc/default.script    (revision 
> 15429)
> +++ package/base-files/files/usr/share/udhcpc/default.script    (working copy)
> @@ -37,6 +37,9 @@
>         deconfig)
>                 ifconfig $interface 0.0.0.0
>                 hotplug_event ifdown
> +
> +               hostname=$(cat /proc/sys/kernel/hostname)
> +               sed -i -e "/ $hostname"'$/d' /etc/hosts
>         ;;
>         renew|bound)
>                 ifconfig $interface $ip \
> @@ -77,6 +80,10 @@
>                         hotplug_event ifup
>                 fi
> 
> +               hostname=$(cat /proc/sys/kernel/hostname)
> +               sed -i -e "/ $hostname"'$/d' /etc/hosts
> +               echo "$ip $hostname" >> /etc/hosts
> +
>                 # user rules
>                 [ -f /etc/udhcpc.user ] && . /etc/udhcpc.user
>         ;;

-- Rod
_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to