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 192.168.1.205/24. The settings of the wireless router are something on the order of:
IP 192.168.1.254
Gateway 192.168.1.1
DNS 8.8.8.8 192.168.1.1
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=192.168.1.7/24
static routers=192.168.1.1
static domain_name_servers=8.8.8.8 192.168.1.1
Nothing elaborate. I then edited my wpa_supplicant file like this:
Network={
ssid=’my_network_name’
psk=’my_network_password
}
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.
- 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.
- 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.