-1

I was working with Raspbian Jessie version to set a static IP address for eth0 port. As of my knowledge we can configure it with interfaces file but for jessie, there is new file for it and that is dhcpcd.conf .

When I search through google, all tutorials say that " if you wanna use /etc/network/interfaces file, you have to disable dhcpcd service".

But I do not done anything to dhcpcd service and dhcpcd.conf file. I just have modified the /etc/network/interfaces file to include the static IP as per below.

auto lo
iface lo inet loopback

#iface eth0 inet manual
auto eth0
iface eth0 inet static
    address 192.168.42.1
    netmask 255.255.255.0
    network 192.168.42.0
    broadcast 192.168.42.255

allow-hotplug wlan0
iface wlan0 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

Now eth0 get static IP after reboot and I haven't disabled the dhcpcd.conf. Is that any problem?

Whether there is any effect on dhcpcd and network interfaces working?

mcv
  • 73
  • 3
  • 9

3 Answers3

1

dhcpcd is used to obtain or set an IP address. You don't need to disable dhcpcd to effectively get a fixed IP address. dhcpcd is a good and reliable program, used now by most Linux distributions. There are reasons why it has displaced the earlier programs.

dhcpcd is controlled/configured by the file /etc/dhcpcd.conf. You should have a look at man dhcpcd and man dhcpcd.conf when you have a few. But this is what you should do to get a static IP address for eth0: Use the software as it's intended, instead of forcing the system, and violating the instructions. In this way you will avoid problems downstream, and be much less likely to have to return here, posting questions, because you've ignored best practices.

Edit the file /etc/dhcpcd.conf to add the following line:

inform 192.168.42.1

And that's it - that is all you need to do to effectively get a static IP. This approach also has another advantage: you will see your RPi host (192.168.42.1) in your router's DHCP table of leases.

This assumes that your network is otherwise operational and rationally configured.

Note that you can also add the CIDR and broadcast address if you like, but they are optional.

If you're interested in "why", please read this answer

Don't be tempted to use the static_ipaddress option in /etc/dhcpcd.conf; man dhcpcd.conf is specific about this:

For IPv4, you should use the inform ipaddress option instead of setting a static address.

Seamus
  • 23,558
  • 5
  • 42
  • 83
0

I don't see why there would be any problem with what you have done. You have set a manual address for the interface. It will not put out a DHCP request for that interface.

It's not clear whether the DHCP daemon you are talking about was supplying eth0 with an address previously. Was it? If it was then it may have been automatically associating that IP address with the name of eth0's host. That may cause a problem if something is asking that DHCP daemon for the IP address of that host.

joan
  • 71,852
  • 5
  • 76
  • 108
0

Is that the COMPLETE contents of /etc/network/interfaces? If it calls dhcp that would disable dhcpcd.

There is nothing to stop you using /etc/network/interfaces BUT dhcpcd may still allocate an address, resulting in duplicate addresses, and potential routing problems.

Frankly, I don't understand why so many Pi users want static IP addresses!

Milliways
  • 62,573
  • 32
  • 113
  • 225