Re: Handling static ip address configuration using /etc/network/interface
Amit Uttamchandani
Wed Jan 28 02:09:03 2015
On Tue, Nov 04, 2014 at 08:01:42PM +0000, Roy Marples wrote:
> On 04/11/2014 17:45, Amit Uttamchandani wrote:
> > OK, I will try to do this and if it is clean, I will send you the patch
> > for review.
>
> I don't maintain the debian stuff anymore, best sent it upstream.
>
> >>> What is the recommended way to ignore this interface when it is
> >>> configured statically?
> >>
> >> Add this to /etc/dhcpcd.conf, right at the top
> >> denyinterfaces eth0
> >
> > Thanks. Would it make sense to have /etc/dhcpcd.d? In this way, we can
> > create minor configuration files on the fly in there that will be
> > included by dhcpcd. This is similar to /etc/sudoers.d or /etc/cron.d.
>
> Yes, no, maybe :)
>
> In hindsight, a directory would have been better - we have dhcpcd.duid
> and dhcpcd.secret that live in /etc as well.
>
> However, dhcpcd.conf is designed to be parsed top down. We could load
> the files in a lexical order, but that would mess with dhcpcd-{gtk,qt}
> editing the configuration sanely.
>
> Roy
Hi Roy,
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?
Thanks,
Amit
Archive administrator: postmaster@marples.name