I'm using an RPI3B+ to learn about dhcp servers. I've hit a snag I can't figure out. Please bear with me. I want to explain what's happening in detail so you can understand it better.

I booted my pi with a fresh install of Raspi-lite. The pi was not connected to my network switch at the time. I configured everything in raspi-config, including the wifi.

I ran ip addr show. The lan interface, enxb827ebcgfa21, had no ip address (as expected) and the wlan0 interface had an IP address from the wireless router of The settings of the wireless router are something on the order of:

IP range is 192.168.2 - 254

It also connect to the internet and a DHCP server is running on it. There is no other DHCP server running on the subnet. The only other computer connected to my switch is my Window desktop.

I could ping google.com so I knew the wifi was working.

Now I went to set a static ip address. I edited the /etc/dhcpcd.conf like this:

interface enxb827ebc6fa21
static ip_address=
static routers=
static domain_name_servers=

Nothing elaborate. I then edited my wpa_supplicant file like this:


After I rebooted I ran ip addr show again. The enxbxxxxx interface had picked up the static ip address from the dhcpcd.conf file. And the wlan0 still had the same ip address it picked up from the router the first time and still connected to the internet. Everything looked good.

But then I rebooted and connected the pi to my switch. This time, the lan interface still had the static IP from the dhcpcd.conf file. But the wlan0 interface no longer had an address and would no longer connect to the internet. Only Unplugging the ethernet cable and rebooting doesn't help.

I went back to the dhcpcd.conf file, removed my static ip changes and rebooted. This time the lan IP address was an odd 169.254.225/16. The wlan0 still had no IP address and still wouldn’t connect to the internet. Only reverting settings in dhcpcd.conf helps.

  1. So why does the wlan0 interface stop working after a static ip address is set and the switch is connected? What's causing that to happen.
  2. Where is this 169.254 IP address coming from? It’s not from the router so it must be coming from the OS, but where?

Thanks in advance.

  • You write "... had an IP address from the wireless router ..." and "My other router settings ...". Do you have two router running? Your other router has the ip address but its gateway is Does the wireless router has and connects to the internert? On what router is the DHCP server running? Is it possible that a DHCP server is enabled on both router? If you unplug the ethernet cable from the switch and reboot, what then is the situation? Where is the switch connected?
    – Ingo
    Nov 15, 2018 at 13:50
  • 1
    Sorry for the confusion.No, I don't have two routers just my Asus RT-AC88U wireless router. Yes, the wireless router connects to the internet. The DHCP server is running on the router. Everything works until I set a static lan ip address in the dhcpcd.conf file. Unplugging the cable and rebooting doesn't help. The only thing that helps is removing my edit of the dhcpcd.conf file. The only other computer connected to my switch is my Window desktop.
    – ResearchRn
    Nov 16, 2018 at 2:01
  • The switch is connected with an ethernet cable to a port on the wifi router, isn't it? I will make an answer after Sunday (I'm busy now) but there is something unclear for me. The wifi router has an ip address and a default gateway of Usually it should point to a gateway from your internet provider mostly a public ip address. This should not matter for DHCP on the local network but may be a reason for the strange behavior in general. What device on your local area network has ip address
    – Ingo
    Nov 16, 2018 at 9:53

2 Answers 2


It is difficult to completely understand your network environment because lack of answers to my questions (where is the switch connected, what has So I can only give general information about how DHCP is working but it may help you to find what's going wrong with your setup.

There are mainly three ways to give an interface an ip address in this priority:

  1. setup static ip address will overwrite any other settings
  2. getting an ip address from a DHCP server on the network
  3. autoconfigure a link-local address if nothing others is used

When using a static ip address and a DHCP server is also running on the network you should ensure that the ip address is outside the range that the DHCP server will give to devices. The DHCP server may check this conflict by pinging the address and avoid to give the same ip address from its pool to another device. But this only works if the conflicting device is just online. More detailed answers to this feature you will find at Does dhcpcd prevent a remote DHCP server serving an IP address that is declared static?. You are always on the save side if you use a static ip address outside the pool from the DHCP server. The pool on your DHCP server is set from to (I guess because you write IP range is 192.168.2 - 254). You should set it for example from to ( is used for the wifi router itself).

If a device has DHCP lookup enabled and it does not have an ip address it will broadcast into the subnet it is connected to and request for an address. You have to ensure that only one DHCP server is running on your broadcast domain (subnet without router connection). Otherwise each DHCP server will response to a request from a device with a different ip address from its different pool. It is obvious that this cannot work.

If the interface does not have a static ip address and if it does not find a DHCP server on the subnet it is connected to then the avahi daemon will give it an ip address from the reserved ip address block (Link-local addresses). This are 65536 ip addresses. avahi ensures that the ip address it gives to the interface will be unique on the broadcast domain. If you use a static ip address from this address block you violate specification. Never do it. Link-local addresses work ad hoc on (small) networks without a DHCP server. avahi will also give a DNS name to the ip address from the also reserved DNS domain .local, for example raspberrypi.local.


See How to set up networking/WiFi and How to set up Static IP Address

List the full contents of /etc/dhcpcd.conf and /etc/wpa_supplicant/wpa_supplicant.conf (you can obscure the values of SSID & psk)

169.254 is a Link-local address

  • I've read the sources you mentioned. I'm pretty sure I configured the dhcpcd.conf file the way they say to do it.
    – ResearchRn
    Nov 16, 2018 at 2:37
  • One thing I added was a modification to the /boot/cmdline.txt to enable use of eth0 instead enxb827ebc6fa21. Which is much easier to use.
    – ResearchRn
    Nov 16, 2018 at 2:44
  • Could use some help, being a newbie. Is there a way to copy code from my pi and paste into comments? Thanks for your reply.
    – ResearchRn
    Nov 16, 2018 at 3:31
  • @ResearchRn there are many people who are willing to help, BUT if you ignore requests for further information you are unlikely to get help. DO NOT paste detail into Comments EDIT your question You should also include FULL detail of data like ip a NOT selected extracts.
    – Milliways
    Nov 16, 2018 at 5:38
  • @ResearchRn There are ways to copy and paste output from your RasPis terminal. But it is the best you make a new question for this. I'm sure you will get quick and good answers. Maybe there is also an answer?
    – Ingo
    Nov 16, 2018 at 10:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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