Milliways
Posts: 229
Joined: Fri Apr 25, 2014 12:18 am

Configuring Network using dhcpcd

Sat May 30, 2015 2:57 am

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.

The `/etc/network/interfaces` used to contain `iface eth0 inet dhcp` which has been replaced by `iface eth0 inet manual`

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

(I am trying to work out a configuration which will let my Pi work normally with dhcp on 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.)
Last edited by Milliways on Sat May 30, 2015 11:42 pm, edited 1 time in total.

morgon
Posts: 68
Joined: Sun Dec 22, 2013 1:10 pm

Re: Configuring Network using dhcpcd

Sat May 30, 2015 10:55 pm

Maybe I don't understand your posting (and I may have one beer too many) but if you want to use a static ip then use "static" in your stanza and not "manual".

e.g.:

Code: Select all

iface eth0 inet static
        address 10.10.10.2
        netmask 255.255.255.0
        gateway 10.10.10.1

User avatar
rpdom
Posts: 11569
Joined: Sun May 06, 2012 5:17 am
Location: Essex, UK

Re: Configuring Network using dhcpcd

Sun May 31, 2015 4:59 am

morgon wrote:Maybe I don't understand your posting (and I may have one beer too many)
How many is too many? ;)

The new dhcpd seems to ignore the normal /etc/network/interfaces settings and just do its own thing. I might have a look at the reasoning for this and how to configure it one day, but for now I'm sticking with the old one that has worked since forever.

(I think the new one may need some GUI stuff to configure it? I run headless, so no idea)

morgon
Posts: 68
Joined: Sun Dec 22, 2013 1:10 pm

Re: Configuring Network using dhcpcd

Sun May 31, 2015 4:41 pm

I am sober again but I still don't quite understand your posting...
rpdom wrote: The new dhcpd seems to ignore the normal /etc/network/interfaces settings and just do its own thing.
dhcpd is the dhcp-SERVER. It is normally configured in /etc/dhcp/dhcpd.conf. This configuration has nothing at all to do with what is in /etc/network/interfaces.

When you see an "dhcp"-entry in /etc/network/interfaces it means that the interface should be configured via a dhcp-CLIENT.

So I guess there are 3 scenarios:

If you want a static (hardcoded) ip for your interface use "static" in the stanza in /etc/network/interfaces.
If you want an ip via dhcp then use "dhcp".
If you want an ip via dhcp but need to ensure that a system always gets the same ip from the dhcp-server you need to configure the dhcp-server on the machine where it runs on to map a specific mac-adress to a specific ip.

I don't know if this was of any help at all..

User avatar
rpdom
Posts: 11569
Joined: Sun May 06, 2012 5:17 am
Location: Essex, UK

Re: Configuring Network using dhcpcd

Sun May 31, 2015 4:51 pm

morgon wrote:I am sober again but I still don't quite understand your posting...
rpdom wrote: The new dhcpd seems to ignore the normal /etc/network/interfaces settings and just do its own thing.
dhcpd is the dhcp-SERVER. It is normally configured in /etc/dhcp/dhcpd.conf. This configuration has nothing at all to do with what is in /etc/network/interfaces.

When you see an "dhcp"-entry in /etc/network/interfaces it means that the interface should be configured via a dhcp-CLIENT.

So I guess there are 3 scenarios:

If you want a static (hardcoded) ip for your interface use "static" in the stanza in /etc/network/interfaces.
If you want an ip via dhcp then use "dhcp".
If you want an ip via dhcp but need to ensure that a system always gets the same ip from the dhcp-server you need to configure the dhcp-server on the machine where it runs on to map a specific mac-adress to a specific ip.

I don't know if this was of any help at all..
dhcpcd is the Client daemon. Not the server. It seems to ignore the "dhcp" entries and use "manual" instead.

User avatar
koudstaald
Posts: 5
Joined: Mon Dec 16, 2013 4:53 pm

Re: Configuring Network using dhcpcd

Mon Jun 01, 2015 2:11 am

I am still at a loss what is going on. The dhcpcd.conf file is in /etc/ and not /etc/dhcp/
Looking at the dhcpcd.conf file I have no idea how the manual setting in /etc/network/interfaces can pick up the dynamic ip from my network.
Furthermore, I always understood that a manual setting should refer to either some options in the interfaces settings or a file path like the entries for wlan0 and wlan1 ( https://www.debian.org/doc/manuals/debi ... 05.en.html )
Also, when I replace in the interfaces line:
iface eth0 inet manual
with
iface eth0 inet dhcp
I do get errors during the bootup

AlecIs
Posts: 2
Joined: Mon Jun 24, 2013 1:20 am

Re: Configuring Network using dhcpcd

Tue Jun 02, 2015 1:43 am

I had a similar problem - my WLAN0 interface was being assigned both a static IP (because I configured it that way in /etc/networking/interfaces) and a DHCP address.

The fix was to edit /etc/dhcpcd.conf and change the entry so that the dhcp daemon uses clientid (aka MAC address) instead of duid.

I'm not sure why the OS is handling it like this - it's not anything I've seen before in Linux.

User avatar
koudstaald
Posts: 5
Joined: Mon Dec 16, 2013 4:53 pm

Re: Configuring Network using dhcpcd

Tue Jun 02, 2015 3:05 am

Thank you for your suggestion and changed from duid to clientid in dhcpcd.conf file.

My pi has a static ip and uses only the ethernet. WIFI is disabled in the interfaces configuration file.

The pi is still rebinding the leased ip address from my dhcp server and is also implementing my static ip.
I also can ping successfully both ip addresses on any computer on my LAN.
And of course I can access the pi via ssh on both ip addresses.

I can fix the problem by removing raspberrypi-net-mods but that options gives me lots of errors during boot.

Any suggestions to fix this problem without removing raspberrypi-net-mods?

I also have never seen this way of network management with my other linux desktops and servers.

knute
Posts: 283
Joined: Thu Oct 23, 2014 12:14 am

Re: Configuring Network using dhcpcd

Tue Jun 02, 2015 3:23 am

It's still not clear to me what "manual" means in the /etc/network/interfaces file. When I installed the raspberrypi-net-mods it overwrote my /etc/network/interfaces file that had my static IP setup in it. When I reboot it it still comes up with the old static IP address even though all of that is now missing from the /etc/network/interfaces file. I don't understand where it is getting the IP address from now.

User avatar
koudstaald
Posts: 5
Joined: Mon Dec 16, 2013 4:53 pm

Re: Configuring Network using dhcpcd

Tue Jun 02, 2015 4:14 am

knute wrote:It's still not clear to me what "manual" means in the /etc/network/interfaces file. When I installed the raspberrypi-net-mods it overwrote my /etc/network/interfaces file that had my static IP setup in it. When I reboot it it still comes up with the old static IP address even though all of that is now missing from the /etc/network/interfaces file. I don't understand where it is getting the IP address from now.
Have a look in this forum thread viewtopic.php?f=63&t=110606&p=768633#p768633

However, in that thread is not solution either to the issue of two IP addresses when creating a static IP in /etc/network/interfaces

User avatar
DougieLawson
Posts: 29790
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Configuring Network using dhcpcd

Tue Jun 02, 2015 9:09 am

koudstaald wrote:
Have a look in this forum thread viewtopic.php?f=63&t=110606&p=768633#p768633

However, in that thread is not solution either to the issue of two IP addresses when creating a static IP in /etc/network/interfaces
The two IP addresses seems to be a bug in dhcpcd5 and raspberrypi-net-mods.

I've purged those two (along with isc-dhcp*) and replaced them with network-manager & dhcpcd.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3

Please post ALL technical questions on the forum. Do not send private messages.

humberian
Posts: 20
Joined: Sun Mar 22, 2015 7:57 pm

Re: Configuring Network using dhcpcd

Sat Jun 06, 2015 2:33 pm

DougieLawson wrote:
koudstaald wrote: The two IP addresses seems to be a bug in dhcpcd5 and raspberrypi-net-mods.
I've purged those two (along with isc-dhcp*) and replaced them with network-manager & dhcpcd.
Would this also work for a OpenVPN environement since I need DHCP for the VPN clients?

Return to “Raspbian”

Who is online

Users browsing this forum: No registered users and 34 guests