mortommy
Posts: 9
Joined: Mon Oct 23, 2017 8:30 am
Location: Switzerland

Unable to get an IP address from AP (Stretch)

Thu Jan 11, 2018 11:04 am

Hi guys,
I'm creating a new post about access point configuration on raspberry pi 3 with stretch ( 4.9.73-v7+). I have network on interface eth0 (static IP assigned by the router) and I'd like to setup an AP using the on board wifi with no internet access; I followed the suggestion in viewtopic.php?t=195377 topic and I was able to get the local wifi network, but when I try to connect to the network I get, from the dnsmasq service, the message:

Code: Select all

Jan 11 11:30:16 raspberrypi systemd[1]: Started dnsmasq - A lightweight DHCP and caching DNS server.
Jan 11 11:47:23 raspberrypi dnsmasq-dhcp[4596]: no address range available for DHCP request via wlan0
Jan 11 11:47:28 raspberrypi dnsmasq-dhcp[4596]: no address range available for DHCP request via wlan0
I didn't change the file /etc/network/interfaces that is:

Code: Select all

# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet manual

allow-hotplug wlan0
iface wlan0 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
I configured a static IP address for my wlan0 interface adding to the file /etc/dhcpcd.conf the lines:

Code: Select all

interface wlan0
static ip_address=192.168.4.1/24
static routers=192.168.4.1
then created the file /etc/dnsmasq.conf as:

Code: Select all

interface=wlan0
dhcp-range=192.168.4.2,192.168.4.20,255.255.255.0,12h
then changed /etc/hostapd/hostapd.conf as:

Code: Select all

interface=wlan0
driver=nl80211
ssid=MyWLAN
hw_mode=g
channel=7
wmm_enabled=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=*pass*
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
and the file /etc/default/hostapd:

Code: Select all

# Defaults for hostapd initscript
#
# See /usr/share/doc/hostapd/README.Debian for information about alternative methods of managing hostapd.
#
# Uncomment and set DAEMON_CONF to the absolute path of a hostapd configuration file and hostapd will be start$
# during system boot. An example configuration file can be found at
# /usr/share/doc/hostapd/examples/hostapd.conf.gz
#
DAEMON_CONF="/etc/hostapd/hostapd.conf"
# Additional daemon options to be appended to hostapd command:-
#       -d show more debug messages (-dd for even more) -K include key data in debug messages -t include
#       timestamps in some debug messages
#
# Note that -B (daemon mode) and -P (pidfile) options are automatically configured by the init.d script and mu$
# not be added to DAEMON_OPTS.
#
#DAEMON_OPTS=""
the result of ifconfig is:

Code: Select all

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.178.40  netmask 255.255.255.0  broadcast 192.168.178.255
        inet6 fe80::ba27:ebff:fed1:7cbe  prefixlen 64  scopeid 0x20<link>
        ether b8:27:eb:d1:7c:be  txqueuelen 1000  (Ethernet)
        RX packets 19146  bytes 6764977 (6.4 MiB)
        RX errors 0  dropped 5  overruns 0  frame 0
        TX packets 4926  bytes 837550 (817.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1  (Local Loopback)
        RX packets 1688  bytes 107050 (104.5 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1688  bytes 107050 (104.5 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 169.254.80.90  netmask 255.255.0.0  broadcast 169.254.255.255
        inet6 fe80::ba27:ebff:fe84:29eb  prefixlen 64  scopeid 0x20<link>
        ether b8:27:eb:84:29:eb  txqueuelen 1000  (Ethernet)
        RX packets 1414  bytes 759240 (741.4 KiB)
        RX errors 0  dropped 2  overruns 0  frame 0
        TX packets 1082  bytes 201469 (196.7 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
that is making me thinking the IP assigned to the wlan0 has a class completely different from the static IP I defined and the IP ranges I defined. It can be that the issue? Do you have any idea how to fix it?

Thank you!

SurferTim
Posts: 1769
Joined: Sat Sep 14, 2013 9:27 am
Location: Miramar Beach, Florida

Re: Unable to get an IP address from AP (Stretch)

Thu Jan 11, 2018 11:44 am

You didn't follow the instructions on that page.

No entries in /etc/network/interfaces. This is the only uncommented entry in that file:

Code: Select all

# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
Do not assign a "routers" parameter to wlan0 in /etc/dhcpcd.conf.
Do not use a passphrase shorter than 8 characters in /etc/hostapd/hostapd.conf.

mortommy
Posts: 9
Joined: Mon Oct 23, 2017 8:30 am
Location: Switzerland

Re: Unable to get an IP address from AP (Stretch)

Thu Jan 11, 2018 1:47 pm

Hi,
thank you for your answer.
I had bad understood about the file /etc/network/interfaces.
So I changed the above file, deleted the "routers" option in /etc/dhcpcd.conf, no problem about passphrase; I made a couple of reboot but still no luck. I can't get an IP, I get the same message:

no address range available for DHCP request via wlan0

SurferTim
Posts: 1769
Joined: Sat Sep 14, 2013 9:27 am
Location: Miramar Beach, Florida

Re: Unable to get an IP address from AP (Stretch)

Thu Jan 11, 2018 1:56 pm

That response is normally due to a localnet network setting mismatch. Ensure the ip address/netmask assigned to wlan0 includes the dhcp_range in /etc/dnsmasq.conf.

Post the contents of your /etc/dhcpcd.conf and /etc/dnsmasq.conf.

To troubleshoot this:

Code: Select all

sudo service dnsmasq status
sudo service hostapd status
Both should show active (running).

Edit: run ifconfig to ensure your wlan0 interface is being assigned 192.168.4.1.

mortommy
Posts: 9
Joined: Mon Oct 23, 2017 8:30 am
Location: Switzerland

Re: Unable to get an IP address from AP (Stretch)

Thu Jan 11, 2018 2:22 pm

Thank you again for your help.
That's the point, the ip address/netmask assigned to wlan0 doesn't match what defined in /etc/dnsmasq.conf

Here's the /etc/dhcpcd.conf

Code: Select all

# 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.
hostname

# Use the hardware address of the interface for the Client ID.
clientid
# or
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 ClientID as per RFC4361.
# Some non-RFC compliant DHCP servers do not reply with this set.
# In this case, comment out duid and enable clientid above.
#duid

# Persist interface configuration when dhcpcd exits.
persistent

# 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. This is applied to DHCP routes.
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

# Example static IP configuration:
#interface eth0
#static ip_address=192.168.0.10/24
#static routers=192.168.0.1
#static domain_name_servers=192.168.0.1 8.8.8.8

# It is possible to fall back to a static IP if DHCP fails:
# define static profile
#profile static_eth0
#static ip_address=192.168.1.23/24
#static routers=192.168.1.1
#static domain_name_servers=192.168.1.1

# fallback to static profile on eth0
#interface eth0
#fallback static_eth0

interface wlan0
static ip_address=192.168.4.1/24
and /etc/dnsmasq.conf

Code: Select all

interface=wlan0
# Use the require wireless interface - usually wlan0
dhcp-range=192.168.4.2,192.168.4.20,255.255.255.0,12h
Both the services are (active)running

SurferTim
Posts: 1769
Joined: Sat Sep 14, 2013 9:27 am
Location: Miramar Beach, Florida

Re: Unable to get an IP address from AP (Stretch)

Thu Jan 11, 2018 2:29 pm

It appears your dhcpcd service isn't working. Are you certain there are no iface statements in /etc/network/interfaces?

Code: Select all

sudo service dhcpcd status
active (running)?

Edit: If your ifconfig is showing this:

Code: Select all

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 169.254.80.90  netmask 255.255.0.0  broadcast 169.254.255.255
...then your wlan0 is attempting to get a dhcp address.

mortommy
Posts: 9
Joined: Mon Oct 23, 2017 8:30 am
Location: Switzerland

Re: Unable to get an IP address from AP (Stretch)

Thu Jan 11, 2018 2:31 pm

yes. here's is the output:

Code: Select all

dhcpcd.service - dhcpcd on all interfaces
   Loaded: loaded (/lib/systemd/system/dhcpcd.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2018-01-11 14:40:25 CET; 50min ago
  Process: 393 ExecStart=/usr/lib/dhcpcd5/dhcpcd -q -b (code=exited, status=0/SUCCESS)
 Main PID: 400 (dhcpcd)
   CGroup: /system.slice/dhcpcd.service
           ├─400 /sbin/dhcpcd -q -b
           └─525 wpa_supplicant -B -c/etc/wpa_supplicant/wpa_supplicant.conf -iwlan0

Jan 11 14:40:33 raspberrypi dhcpcd[400]: eth0: leased 192.168.178.40 for 864000 seconds
Jan 11 14:40:33 raspberrypi dhcpcd[400]: eth0: adding route to 192.168.178.0/24
Jan 11 14:40:33 raspberrypi dhcpcd[400]: eth0: adding default route via 192.168.178.1
Jan 11 14:40:33 raspberrypi dhcpcd[400]: eth0: removing route to 192.168.178.0/24
Jan 11 14:40:36 raspberrypi dhcpcd[400]: wlan0: using IPv4LL address 169.254.80.90
Jan 11 14:40:36 raspberrypi dhcpcd[400]: eth0: adding route to 192.168.178.0/24
Jan 11 14:40:36 raspberrypi dhcpcd[400]: wlan0: adding route to 169.254.0.0/16
Jan 11 14:40:36 raspberrypi dhcpcd[400]: wlan0: removing route to 169.254.0.0/16
Jan 11 14:40:39 raspberrypi dhcpcd[400]: wlan0: no IPv6 Routers available
Jan 11 14:40:41 raspberrypi dhcpcd[400]: eth0: no IPv6 Routers available
and yes:

Code: Select all

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 169.254.80.90  netmask 255.255.0.0  broadcast 169.254.255.255
        inet6 fe80::ba27:ebff:fe84:29eb  prefixlen 64  scopeid 0x20<link>

SurferTim
Posts: 1769
Joined: Sat Sep 14, 2013 9:27 am
Location: Miramar Beach, Florida

Re: Unable to get an IP address from AP (Stretch)

Thu Jan 11, 2018 2:33 pm

Then something is wrong with your /etc/dhcpcd.conf entry. This is the indication:

Code: Select all

wlan0: using IPv4LL address 169.254.80.90
OR you have a iface entry in /etc/network/interfaces. Like this?

Code: Select all

iface wlan0 inet dhcp
OR you have a network section in /etc/wpa_supplicant/wpa_supplicant.conf

mortommy
Posts: 9
Joined: Mon Oct 23, 2017 8:30 am
Location: Switzerland

Re: Unable to get an IP address from AP (Stretch)

Thu Jan 11, 2018 3:01 pm

the /etc/network/interfaces file is:

Code: Select all

# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
and /etc/wpa_supplicant/wpa_supplicant.conf :

Code: Select all

country=CH
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
so it should be the /etc/dhcpcd.conf

SurferTim
Posts: 1769
Joined: Sat Sep 14, 2013 9:27 am
Location: Miramar Beach, Florida

Re: Unable to get an IP address from AP (Stretch)

Thu Jan 11, 2018 3:11 pm

The only thing I can think of is you need a linefeed after the "static ip_address" line in /etc/dhcpcd.conf.

mortommy
Posts: 9
Joined: Mon Oct 23, 2017 8:30 am
Location: Switzerland

Re: Unable to get an IP address from AP (Stretch)

Fri Jan 12, 2018 10:59 pm

I rewrote and reviewed the configuration files, I'm getting the same error message but now the external device can connect to the raspi network and get an IP (I'm still getting the same error message in the dnsmasq.service status: no address range available for DHCP request via wlan0; the message wlan0: using IPv4LL address 169.254.80.90 disappeared) but the IP assigned to the wlan0 interface is still 169.254.80.90, and the device get 169.254.80.27. I can't understand, it is like the static ip configuration is ignored.

lowrob
Posts: 4
Joined: Tue Feb 20, 2018 4:14 pm

Re: Unable to get an IP address from AP (Stretch)

Tue Feb 20, 2018 5:11 pm

Had you ever got the static IP on wlan0 to work? I am having the same problem you describe.

Josez
Posts: 11
Joined: Tue May 28, 2019 6:55 pm

Re: Unable to get an IP address from AP (Stretch)

Tue May 28, 2019 6:59 pm

Per: https://www.raspberrypi.org/documentati ... s-point.md

The configuration to get a static ip on wlan0 is:

Code: Select all

interface wlan0
static ip_address=192.168.4.1/24
nohook wpa_supplicant
I think you are missing the "nohook" directive.

I had the same issue, that directive fixed it.

After updating your dhcpcd.conf do:
systemctl daemon-reload
systemctl restart dhcpd.conf

I hope it helps.

Return to “Troubleshooting”