dhcpcd-discuss

Re: Understanding dhcpcd on Raspbian

Roy Marples

Mon Jun 01 12:11:28 2015

Hi

On 2015-06-01 08:37, I Binnie wrote:
I have installed the new `raspberrypi-net-mods` using `dhcpcd`. This
works, but I am trying to understand why and how.
I have read the `dhcpcd` and `interfaces` `man` pages but these do not
seem to apply to the actual interface.
I have asked questions on a few RaspberryPi and Linux forums and not
received any sensible comments, although there see to be others who
are confused.

The `/etc/network/interfaces` used to contain `iface eth0 inet dhcp`
which has been replaced by `iface eth0 inet manual`
Boot messages with dhcp show
	[FAIL] Not running dhcpcd client because /etc/network/interfaces
defines some services that use a DHCP client.
I presume this is from `resolvconf` or similar.

Where does the IP address come from? This seems to allocate the same
IP reservation from my router.

Is `/etc/network/interfaces` involved in the `dhcpcd` process?

Using the supplied `raspberrypi-net-mods` configuration both my
Ethernet and WiFi seem to be active (although the router seems to
think they have the same MAC). Previously using `wpa-roam` in
`/etc/network/interfaces` only activated WiFi if Ethernet was not
connected, but this no longer seems to work.

I cannot provide any support for dhcpcd on platforms I don't have, sorry.
I can tell you that resolvconf is probably not to blame.

I am trying to work out a configuration which will let my Pi work
normally with my home network, but allocate a `static` address so I
can connect to the Pi over Ethernet (or ad-hoc WiFi) to my Mac in a
remote environment with no router or internet access.

As you're asking on the dhcpcd mailing list, I'll provide a dhcpcd way of doing it :)

cat /etc/dhcpcd.exit-hook
aliasip=
if $if_up; then
   # Wireless alias
   case "$ifssid" in
   YOURSSIDHERE) aliasip="192.168.1.10/24";;
   esac

   # Ethernet alias
   case "$interface" in
   eth0) aliasip="192.168.10.10/24";;
   esac

   if [ -n "$aliasip" ]; then
      echo "Adding alias of $aliasip to $interface"
      # BSD - ifconfig "$interface" inet alias "$aliasip"
      # Linux below
      ip a a "$aliasip" dev "$interface"
   fi
fi

Untested, but should work.
Replace YOURSSIDHERE with the SSID that wants the static alias.
Replace 192.168.1.10/24 with the actual static alias you need.
Same for the ethernet segment.
I'm pretty sure you're talking about a Linux machine rather than a BSD one, so I put the linux command to add aliased ip addresses in the code the the BSD way commented out.

This is all documented in dhcpcd-run-hooks(8).

Thanks

Roy

References:
Understanding dhcpcd on RaspbianI Binnie
Archive administrator: postmaster@marples.name