Re: Handling static ip address configuration using /etc/network/interface
Roy Marples
Wed Jan 28 07:36:38 2015
Hi Amit
On Tuesday 27 Jan 2015 18:08:59 Amit Uttamchandani wrote:
> Finally got around to working on this. Here is the hook I made on
> to handle static IP:
>
> /etc/dhcpcd.enter-hook/03-static:
>
> # If interface is configured as static, don't run dhcpcd
>
> if [ "$reason" = CARRIER -a -e "/etc/network/interfaces" ]; then
> # Search for a static entry
> if grep "iface $interface inet static" /etc/network/interfaces
> then
> syslog info "$interface is configured as static...exiting
> dhcpcd" dhcpcd -k $interface
> fi
> fi
>
> What do you think of this?
I think it's a good idea, novel and works!
Two points.
You should test for PREINIT, not CARRIER as you only want to check once really
and as fast as possible.
Also, use dhcpcd -x and not -k. If the user wants to release all the time,
specify that in dhcpcd.conf, don't assume you know better by forcing it in a
script.
Otherwise looks very good!
Roy
Archive administrator: postmaster@marples.name