conrad9900
Posts: 21
Joined: Wed Dec 09, 2015 9:50 am

Re: Configuring dhcpcd in Raspbian Stretch

Thu Apr 12, 2018 9:58 am

I know this is old but i was hoping someone could help me too.
I am trying to get a static address on my pi for wlan0, i have tried all the methods here, adding the following to my /etc/dhcpcd.conf
# Example static IP configuration
interface wlan0
static ip_address=192.168.10.13/24
static routers=192.168.10.21
static domain_name_servers=192.168.10.21

It still resorts to a dhcp address

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5673
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

Re: Configuring dhcpcd in Raspbian Stretch

Thu Apr 12, 2018 10:11 am

Is /etc/network/interfaces clean?

conrad9900
Posts: 21
Joined: Wed Dec 09, 2015 9:50 am

Re: Configuring dhcpcd in Raspbian Stretch

Thu Apr 12, 2018 10:37 am

ShiftPlusOne wrote:
Thu Apr 12, 2018 10:11 am
Is /etc/network/interfaces clean?
Thankfully I resolved the issue.
I started with a fresh file in /boot/wpa-supplicant.txt
and entered my wifi details in the following way


network={
ssid="Net"
psk="Pr01"
}

I then added the following to /etc/dhcpcd.conf

interface wlan0
static ip_address=192.168.10.14/24
static routers=192.168.10.21

sudo reboot

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5673
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

Re: Configuring dhcpcd in Raspbian Stretch

Thu Apr 12, 2018 10:49 am

/boot/wpa-supplicant.txt isn't used in any way.

n67
Posts: 939
Joined: Mon Oct 30, 2017 4:55 pm

Re: Configuring dhcpcd in Raspbian Stretch

Thu Apr 12, 2018 11:11 am

ShiftPlusOne wrote:
Thu Apr 12, 2018 10:49 am
/boot/wpa-supplicant.txt isn't used in any way.
Which is strange, when you think about it.

Given that the accommodation is made for "ssh.txt", why not also "wpa_supplicant.txt"?

And, as I've pointed out many times, we really need to support "ssh.docx" and "wpa_supplicant.docx" for the Word users out there.

And "ssh.xlsx" and "wpa_supplicant.xlsx" for the Excel users.

And ...
"L'enfer, c'est les autres"

G fytc hsqr rum umpbq rm qyw rm rfc kmbq md rfgq dmpsk:

Epmu Sn!

J lnacjrw njbruh-carppnanm vxm rb mnuncrwp vh yxbcb!

damonh
Posts: 28
Joined: Tue Aug 15, 2017 9:31 pm

Re: Configuring dhcpcd in Raspbian Stretch

Tue May 01, 2018 5:46 pm

Hey all. I know this is old, BUT, my use case is to use RPI 3B as a standalone unit that has both and AP and a wifi Client.

I've been really struggling with Stretch to get this working, BUT, I may have finally made it work.

My /etc/dhcpcd.confg

Code: Select all

interface wlan1
    static ip_address=192.168.4.1/24
denyinterfaces wlan1
nohook wpa_supplicant
My /etc/dnsmasq.conf:

Code: Select all

interface=wlan1      # Use the require wireless interface - usually wlan0
  dhcp-range=192.168.4.2,192.168.4.20,255.255.255.0,24h
My /etc/hostapd/hostapd.conf

Code: Select all

# This is the name of the WiFi interface we configured
interface=wlan1

# Use the nl80211 driver with brcnfnac
driver=nl80211

# This is the name of the network
ssid=falconGPS

# use the 2.4Ghz band
hw_mode=g

#Use channel 6
channel=6

#Enable 802.11n
ieee80211n=1

#Enable WMM
wmm_enabled=1

# Enable 40MHz channels with 20ns guard interval
ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40]

# Accept all MAC addresses
macaddr_acl=0

# Use WPA authentication
auth_algs=1

# Require clients to know the network name
ignore_broadcast_ssid=0

# Use WPA2
wpa=2

# The network passphrase     
wpa_passphrase=<supersecretsecret>
# Use a pre-shared key       
wpa_key_mgmt=WPA-PSK         
#wpa_pairwise=TKIP           
rsn_pairwise=CCMP        
I initially tried doing wlan0 as the AP and wlan1 as the client, but, that just gave me nightmares.
After about 25 reboots and a couple of shutdowns and cold restarts, it "seems" that everything is working as expected.

I see falcongps ssid in my available wifi list on devices and can connect.
I can ping urls once connected.

The next step is to get pass-through from AP to wlan1. Really has been a nightmare with Stretch.

damonh
Posts: 28
Joined: Tue Aug 15, 2017 9:31 pm

Re: Configuring dhcpcd in Raspbian Stretch

Wed May 02, 2018 1:58 pm

I may have spoken too soon.
While the above configuration has work, it's random. Initial boot I get my AP on wlan1 as expected.
I can reboot a few times and it no longer gets setup. Try rebooting several times and eventually it will setup.
I've even switched from wlan1 to wlan0 as the AP. Same result.

If I try to restart hostapd the following error is in the journalctl -xe output:

Code: Select all

-- Unit hostapd.service has begun shutting down.
May 02 13:56:23 fgps-lab002 hostapd[1464]: Stopping advanced IEEE 802.11 management: hostapd.
May 02 13:56:23 fgps-lab002 systemd[1]: Stopped LSB: Advanced IEEE 802.11 management daemon.
-- Subject: Unit hostapd.service has finished shutting down
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- Unit hostapd.service has finished shutting down.
May 02 13:56:23 fgps-lab002 systemd[1]: Starting LSB: Advanced IEEE 802.11 management daemon...
-- Subject: Unit hostapd.service has begun start-up
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- Unit hostapd.service has begun starting up.
May 02 13:56:23 fgps-lab002 kernel: IPv6: ADDRCONF(NETDEV_UP): wlan1: link is not ready
May 02 13:56:23 fgps-lab002 kernel: IPv6: ADDRCONF(NETDEV_UP): wlan1: link is not ready
May 02 13:56:23 fgps-lab002 hostapd[1470]: Starting advanced IEEE 802.11 management: hostapd failed!
May 02 13:56:23 fgps-lab002 systemd[1]: Started LSB: Advanced IEEE 802.11 management daemon.
-- Subject: Unit hostapd.service has finished start-up
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- Unit hostapd.service has finished starting up.
--
-- The start-up result is done.
May 02 13:56:23 fgps-lab002 sudo[1458]: pam_unix(sudo:session): session closed for user root
I have been banging my head on this for a couple of days now. This inconsistency is unacceptable for production.
The USB dongal I am using is CanaKIT as recommended by Raspberry Pi org.

Any ideas folks?

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

Re: Configuring dhcpcd in Raspbian Stretch

Wed May 02, 2018 2:29 pm

I use usb wifi modules with the onboard as an AP. I had to assign interface names so they would boot with the correct names.

Create file /etc/udev/rules.d/72-static-name.rules
Add this:

Code: Select all

ACTION=="add", SUBSYSTEM=="net", DRIVERS=="?*",
ATTR{address}=="00:c0:ca:96:d8:8b", KERNEL=="w*",NAME="wlan0"

ACTION=="add", SUBSYSTEM=="net", DRIVERS=="?*",
ATTR{address}=="b8:27:eb:1e:56:52", KERNEL=="w*",NAME="wlan1"
Change the mac addresses to suit your setup.

If the ap doesn't start on boot, try stopping the service , wait a few seconds, then restart it

Code: Select all

sudo service hostapd stop
Wait 5 seconds

Code: Select all

sudo service hostapd start

damonh
Posts: 28
Joined: Tue Aug 15, 2017 9:31 pm

Re: Configuring dhcpcd in Raspbian Stretch

Wed May 02, 2018 2:58 pm

Thanks for the info. Tried that but no-joy.

I Have two sd cards. Both with the same configuration for AP/Client.
The difference? On one I have docker installed.
The one without docker boots every time in the expected configuration.
The one with docker randomly starts in the expected configuration. My suspicion is that docker is interfering in hostapd start up. Trying to figure out how to delay docker.service from loading until AFTER hostapd starts.

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

Re: Configuring dhcpcd in Raspbian Stretch

Wed May 02, 2018 3:28 pm

Have you tried stopping the docker service, then stopping and restarting the hostapd, service, then restart docker? If it works, you can put all that into /etc/rc.local.

damonh
Posts: 28
Joined: Tue Aug 15, 2017 9:31 pm

Re: Configuring dhcpcd in Raspbian Stretch

Wed May 02, 2018 3:35 pm

Yup. No joy. :(
This is very frustrating.

damonh
Posts: 28
Joined: Tue Aug 15, 2017 9:31 pm

Re: Configuring dhcpcd in Raspbian Stretch

Wed May 02, 2018 4:16 pm

Yup. I've confirmed for certain Docker screws up Wifi AP loading.
I took an image that works consistently with setting up AP/Client and then added Docker. After Docker was installed AP doesn't always setup.

damonh
Posts: 28
Joined: Tue Aug 15, 2017 9:31 pm

Re: Configuring dhcpcd in Raspbian Stretch

Thu May 03, 2018 5:53 pm

RESOLVED.
So after much consternation and frustrating head banging it all comes down to a driver issue.
I stripped down to a simple hostapd setup that I knew worked. Loaded docker and problems started.

THEN! I thought while looking at a generic usb wifi dongal why not try it with that? After all that is the one I started with many months ago.
What do you know? It worked. Consistently setting up the AP with docker loading.

So, I started digging and it turns out there has been some issues with the CanaKIT usb wifi dongal and hostapd as posted else where in this forum.

So, I edited the hostapd.conf and commented out the driver=nl80211 statement. Rebooted with the CanaKIT dongal. Seems that I can now consistently get this to boot in the configuration with AP consistently with docker starting as well.

So lesson learned..again... look at drivers when things go wonky.

GST_iGus
Posts: 1
Joined: Fri May 25, 2018 3:06 pm

Re: Configuring dhcpcd in Raspbian Stretch

Mon May 28, 2018 8:42 pm

SurferTim wrote:
Wed Aug 30, 2017 1:34 pm
I have my RPi3 working as an AP with one caveat. The dnsmasq service will not start on boot.
Edit: Fixed boot problem. See new /etc/dnsmasq.conf below.

DO NOT MODIFY /etc/network/interfaces FILE!

My /etc/dhcpcd.conf addition:

Code: Select all

interface wlan0
static ip_address=192.168.4.1/24
static routers=192.168.4.1
static domain_name_servers=8.8.8.8
My /etc/dnsmasq.conf file

Code: Select all

interface=wlan0
domain-needed
bogus-priv
dhcp-range=192.168.4.8,192.168.4.250,12h
My /etc/hostapd/hostapd.conf file

Code: Select all

interface=wlan0
driver=nl80211
ssid=RPiNet
hw_mode=g
channel=7
wmm_enabled=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=mypassphrase
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
Edit /etc/default/hostapd and change this:

Code: Select all

DAEMON_CONF="/etc/hostapd/hostapd.conf"
The next section is required only if you are wanting to access the internet through the ethernet connection.

Edit /etc/sysctl.conf and uncomment

Code: Select all

net.ipv4.ip_forward=1
My iptables rules. Replace ethX with your ethernet interface name from ifconfig.

Code: Select all

sudo iptables -t nat -A  POSTROUTING -o ethX -j MASQUERADE
sudo iptables -A FORWARD -i ethX -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i wlan0 -o ethX -j ACCEPT
Edit: Changed masquerade to MASQUERADE.
I tried this before doing the bridge for Internet connection.

Same struggling with this instructions:
https://www.raspberrypi.org/documentati ... s-point.md

Using it as a Stand Alone and when reboot the WiFi signal doesn't appears. Combining with your files.

I'm using Stretch 04-18.

I already made work the RaspPi with this tutorial:

https://thepi.io/how-to-use-your-raspbe ... ess-point/

But My need is that I need to set a Static Range of PI addresses and other range with Dynamic ones connected to the RaspPi and this one give them Internet.

Return to “Networking and servers”