i am trying to modify the dhcpcd.conf on my raspberry to remove the part where the static ip address is, however, after editing and saving the file using

sudo nano /etc/dhcpcd.conf

the changes does not take effect and after i reboot the pi, the original content of dhcpcd.conf with static ip address is back, not the one after i modified it.

here is the dhcpcd.conf looks like before modifying (please check the last part of the file where the interface eth0 starts)

# A sample configuration for dhcpcd.
# See dhcpcd.conf(5) for details.

# Allow users of this group to interact with dhcpcd via the control socket.
#controlgroup wheel

# Inform the DHCP server of our hostname for DDNS.

# Use the hardware address of the interface for the Client ID.
# or
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 ClientID as per RFC4361.

# Persist interface configuration when dhcpcd exits.

# Rapid commit support.
# Safe to enable by default because it requires the equivalent option set
# on the server to actually work.
option rapid_commit

# A list of options to request from the DHCP server.
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
# Most distributions have NTP support.
option ntp_servers
# Respect the network MTU.
# Some interface drivers reset when changing the MTU so disabled by default.
#option interface_mtu

# A ServerID is required by RFC2131.
require dhcp_server_identifier

# Generate Stable Private IPv6 Addresses instead of hardware based ones
slaac private

# A hook script is provided to lookup the hostname if not set by the DHCP
# server, but it should not be run by default.
nohook lookup-hostname

interface eth0
static ip_address=

static routers=
static domain_name_servers=

I want to remove or comment this part

interface eth0
static ip_address=

static routers=
static domain_name_servers=

but after modifying and saving the file, the changes does not take effect and after rebooting the raspberry the original dhcpcd.conf remains the same with the static ip address part.

interface eth0
static ip_address=

static routers=
static domain_name_servers=

Am I missing something? I have been searching online for several hours for solution but nothing works. Please let me know if you need additional info.

  • 1
    Did you check that the changes are actually saved by opening the file again after saving and exiting the editor? If changes are undone after boot then your SD card may be in read-only mode, meaning it's most likely dead. I would test this by creating a simple file in the home directory, rebooting and seeing if it's still there after reboot. – Dirk Nov 25 '18 at 13:52
  • yes i did reopen the file to see if i really did the changes. just the fact that it reverts back to original content after rebooting. and i did what you suggested to see if the SD is dead. i created a test.py file in the home directory, and it disappears after rebooting. what does this mean? – Johnnyempire Nov 25 '18 at 14:28
  • That normally means the SD card has problems it cannot recover from and is basically end of life. AFAIK you cannot recover from that and you will have to use a different card (you can still read it to recover any files you want to save) – Dirk Nov 25 '18 at 15:07
  • Thanks Dirk for your feedback. I guess this is the case. I checked other directories by creating files. After rebooting they also disappear. I did not notice this since most of the time i work in the usb mounted drive which until now is working fine. – Johnnyempire Nov 25 '18 at 16:26
  • Maybe the SD card is not functioning very well.... However, it's also not meaningful... and perhaps not possible... to set a link-local IP address. Link-local addresses are not routable and are always dynamically set. – RubberStamp Nov 25 '18 at 20:34

You need to use sudo nano /etc/dhcpcd.conf as all files in /etc are owned by root and can only be updated by a UID 0 user.

If you're using sudo, then your SDCard is toast and needs to be replaced with a new one.

  • Please read the question again. The OP says:"... after editing and saving the file using sudo nano /etc/dhcpcd.conf, the changes does not take effect ...". – Ingo Nov 25 '18 at 19:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.