You are not logged in.

#1 2014-03-26 09:02:56

geekinthesticks
Member
From: England
Registered: 2011-09-21
Posts: 143
Website

[solved] hostapd and Assigning IP to Wireless Interface.

I am using a raspberrypi as a portable WiFi hotspot. This has been working fine until a recent update and I am not sure why it is broken. I have a service that assigns and IP address to the wlan0 interface before hostapd starts:

[Unit]
Description=Add static ip for wireless
Before=hostapd.service
After=network.service

[Service]
Type=oneshot
ExecStart=/usr/sbin/ip addr add 10.0.0.1/24 dev wlan0 brd + dev wlan0

[Install]
WantedBy=multi-user.target

However, when I get the following when I look at the logs:

journalctl -u wifi-hostapd.service

Jan 01 01:00:15 routerpi ip[139]: Cannot find device "wlan0"

If I run the service manually after booting it starts correctly and wlan0 is assigned an ip address. I am assuming that I am starting the service at the wrong time.

Last edited by geekinthesticks (2014-03-27 08:29:49)

Offline

#2 2014-03-27 01:35:36

Tarqi
Member
From: Ixtlan
Registered: 2012-11-27
Posts: 179
Website

Re: [solved] hostapd and Assigning IP to Wireless Interface.

Add

BindsTo=sys-subsystem-net-devices-wlan0.device

to the Unit section.

Note: Did not test it, maybe you need to vary the expression.

Last edited by Tarqi (2014-03-27 01:53:39)


Knowing others is wisdom, knowing yourself is enlightenment. ~Lao Tse

Offline

#3 2014-03-27 08:33:30

geekinthesticks
Member
From: England
Registered: 2011-09-21
Posts: 143
Website

Re: [solved] hostapd and Assigning IP to Wireless Interface.

Thanks, I found this post which has lots of helpful information. My systemd unit now looks like:

[Unit]
Description=Add static ip for wireless
Before=hostapd.service
Wants=network.target
Before=network.target
BindsTo=sys-subsystem-net-devices-wlan0.device
After=sys-subsystem-net-devices-wlan0.device


[Service]
Type=oneshot
ExecStart=/usr/sbin/ip addr add 10.0.0.1/24 dev wlan0 brd + dev wlan0

[Install]
WantedBy=multi-user.target

Offline

Board footer

Powered by FluxBB