2

Raspberry Pi-3 running Stretch.

There are dozens of posts here and on other forums about how to set a static IP for the Pi. My problem is the other direction.

I have several Pi's, esp switches and a couple of computers on my home LAN. Since an IP scan shows 42 devices, managing them with static IP is becoming a burden. (Static IP is an old habit from decades ago, but I have learned my lesson.)

To set a static IP, I added the static IP information to dhcpd.conf:

# Custom static IP address for eth0.
interface eth0
static ip_address=192.168.1.114/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1

# Custom static IP address for wlan0.
interface wlan0
static ip_address=192.168.0.115/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1

I also added the network credentials to wpa_supplicant.conf:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=US
network={
        ssid="kaywinnet"
        psk="80619xyzzy"
        key_mgmt=WPA-PSK
}

Now, here's my question. if I take those lines out of dhcpcd.conf and wpa_supplicant.conf then reboot, eth0 does get an IP address via DHCP (from my router), but not wlan0 (on a Pi3 running Stretch).

sudo iwlist wlan0 scan | grep SSID shows the network I want to connect to (Kaywinnet), so I know that wlan0 is working hardware.

sudo ifup wlan0 shows that "interface wlan0 is already configured"

sudo service --status-all shows that dhcpcd is running ([ + ] dhcpcd)

I am pretty certain that my router is providing IP addresses from a DHCP request because many of my esp8266 nodes, my Arduinos and at least my wife's PC (plus my TV, Blu-Ray player and other devices) are all getting IP over DHCP.

Just as an exercise, I flashed the latest Jessie on a new SD card, and it also does not get an IP for the WiFi.

So, I am at a loss to why it appears that my WiFi can't connect using DHCP but it does with static IP.

Any tips of where to look would be appreciated. Also would be appreciated if you don't yell at me for asking the same question on the Pi Foundation forums.

Thanks

user3573562
  • 289
  • 2
  • 6
  • 15
  • See How to set up networking/WiFi You should post the CURRENT contents of your files which are not working and the output of ip a Incidentally the the settings you posted are on different subnets. – Milliways Feb 16 '18 at 05:25
  • Thanks-
    3: wlan0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000 link/ether b8:27:eb:9b:58:ae brd ff:ff:ff:ff:ff:ff
    – user3573562 Feb 18 '18 at 06:28
  • Thanks- 'ip a' returns (partially): 3: wlan0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000 link/ether b8:27:eb:9b:58:ae brd ff:ff:ff:ff:ff:ff --- I caught the subnet error after posting, it's 192.168.1.xxx, and as I said, the static IP works fine. It's interesting that 'man ip' doesn;t show an option of a, so I'll assume that means 'all'. I only posted the wlan0 line because the whole 'ip a' result is too long to post here. – user3573562 Feb 18 '18 at 06:37
  • @user3573562 To reply to the answer below, you can click 'add a comment' to notify the user who answered your question instead of suggesting an edit; edits aren't really meant for replying to other people's answers. – Aurora0001 Feb 18 '18 at 10:12
  • @user3573562 ip a is a shortcut for ip address. It`s only understandable for those who often use this command ;-) – Ingo Feb 18 '18 at 12:33
  • My dhcpcd.conf is as above with the net credentials. My question is why does the DHCP server not get a request for an IP address? – user3573562 Feb 19 '18 at 16:25

2 Answers2

2

You wrote:

if I take those lines out of dhcpcd.conf and wpa_supplicant.conf then reboot, eth0 does get an IP address via DHCP (from my router), but not wlan0 (on a Pi3 running Stretch).

Don*t remove the entries in /etc/wpa_supplicant/wpa_supplicant.conf. They are still needed for wifi even for DHDP. They are used for authentication to connect to your wlan.

Ingo
  • 42,107
  • 20
  • 85
  • 197
  • @user3573562 I rejected your comment in my answer and put it here. You wrote: Thanks, but there is no file: "/etc/wpa_supplicant/wpa_supplicant-wlan0.conf". It appears that the problem is that wlan0 is not asking for an IP from the DHCP server (looking for DHCP lines in the log file). Figuring this out is above my pay grade. – Ingo Feb 18 '18 at 12:09
  • Sorry, that was my fault. It was a typical copy and paste error. Of course you have to edit /etc/wpa_supplicant/wpa_supplicant.conf. I`ve corrected it in my answer. wlan0 never ask for anything if it is not authenticated to your wifi. Otherwise everyone could connect to your wifi ... – Ingo Feb 18 '18 at 12:17
1

Most strange, but this fixed this particular issue:

Remove the quotes from the wifi password in the file wpa_supplicant.conf

user3573562
  • 289
  • 2
  • 6
  • 15