You are not logged in.

#1 2019-08-06 17:00:01

leonixyz
Member
Registered: 2014-07-12
Posts: 40

[SOLVED] software access point

I am trying to setup a software access point with dhcpd but cannot understand what is going on...

My hostapd config is:

/etc/hostapd/hostapd.conf

interface=wlan0
ssid=MySSID
driver=nl80211
country_code=US
hw_mode=g
channel=7
max_num_sta=5
wpa=2
auth_algs=1
rsn_pairwise=CCMP
wpa_key_mgmt=WPA-PSK
wpa_passphrase=MyPassphrase
logger_stdout=-1
logger_stdout_level=2

I followed instructions to setup dhcpd to listen just on one interface

Created and enabled /etc/systemd/system/dhcpd4@.service on interface wlan0

[Unit]
Description=IPv4 DHCP server on %I
Wants=network.target
After=network.target

[Service]
Type=forking
PIDFile=/run/dhcpd4.pid
ExecStart=/usr/bin/dhcpd -4 -q -cf /etc/dhcpd.conf -pf /run/dhcpd4.pid %I
KillSignal=SIGINT

[Install]
WantedBy=multi-user.target

/etc/dhcpd.conf

# wlan0 - my software ap interface
subnet 10.0.0.0 netmask 255.255.255.0 {
  option domain-name-servers 10.0.0.1;
  option subnet-mask 255.255.255.0;
  option routers 10.0.0.1;
  range 10.0.0.2 10.0.0.254;
}

# no dhcpd on eth0
subnet 192.168.1.0 netmask 255.255.255.0 {
}

Now, I don't understand how do I configure wlan0? I suppose it should have a static IP address assigned - 10.0.0.1. Unfortunately, using the "Connection=ethernet" directive does not work

/etc/netctl/wlan0

Description='A static IP for my wireless interface acting as an AP'
Interface=wlan0
Connection=ethernet
IP=static
Address='10.0.0.1/24'
Gateway='10.0.0.1'
DNS=('10.0.0.1')

I suppose "Connection=ethernet" is just for wired interfaces... and in fact netctl fails to start profile wlan0

# journalctl --unit=netctl@wlan0

Aug 06 09:02:32 elderberry systemd[1]: Starting Networking for netctl profile wlan0...
Aug 06 09:02:33 elderberry network[217]: Starting network profile 'wlan0'...
Aug 06 09:02:41 elderberry network[217]: No connection found on interface 'wlan0' (timeout)
Aug 06 09:02:41 elderberry network[217]: Failed to bring the network up for profile 'wlan0'
Aug 06 09:02:41 elderberry systemd[1]: netctl@wlan0.service: Main process exited, code=exited, status=1/FAILURE
Aug 06 09:02:41 elderberry systemd[1]: netctl@wlan0.service: Failed with result 'exit-code'.

When dhcpd starts, this is what I get:

# journalctl -f --unit=dhcpd4@wlan0

Aug 06 16:50:46 elderberry systemd[1]: Starting IPv4 DHCP server on wlan0...
Aug 06 16:50:47 elderberry dhcpd[515]: Not searching LDAP since ldap-server, ldap-port and ldap-base-dn were not specified in the config file
Aug 06 16:50:47 elderberry dhcpd[515]: Source compiled to use binary-leases
Aug 06 16:50:47 elderberry dhcpd[515]: Wrote 0 leases to leases file.
Aug 06 16:50:47 elderberry dhcpd[515]: 
Aug 06 16:50:47 elderberry dhcpd[515]: No subnet declaration for wlan0 (no IPv4 addresses).
Aug 06 16:50:47 elderberry dhcpd[515]: ** Ignoring requests on wlan0.  If this is not what
Aug 06 16:50:47 elderberry dhcpd[515]:    you want, please write a subnet declaration
Aug 06 16:50:47 elderberry dhcpd[515]:    in your dhcpd.conf file for the network segment
Aug 06 16:50:47 elderberry dhcpd[515]:    to which interface wlan0 is attached. **
Aug 06 16:50:47 elderberry dhcpd[515]: 
Aug 06 16:50:47 elderberry dhcpd[515]: 
Aug 06 16:50:47 elderberry dhcpd[515]: Not configured to listen on any interfaces!
Aug 06 16:50:47 elderberry dhcpd[515]: 
Aug 06 16:50:47 elderberry dhcpd[515]: If you think you have received this message due to a bug rather
Aug 06 16:50:47 elderberry dhcpd[515]: than a configuration issue please read the section on submitting
Aug 06 16:50:47 elderberry systemd[1]: dhcpd4@wlan0.service: Control process exited, code=exited, status=1/FAILURE
Aug 06 16:50:47 elderberry dhcpd[515]: bugs on either our web page at www.isc.org or in the README file
Aug 06 16:50:47 elderberry dhcpd[515]: before submitting a bug.  These pages explain the proper
Aug 06 16:50:47 elderberry dhcpd[515]: process and the information we find helpful for debugging.
Aug 06 16:50:47 elderberry dhcpd[515]: 
Aug 06 16:50:47 elderberry dhcpd[515]: exiting.
Aug 06 16:50:47 elderberry systemd[1]: dhcpd4@wlan0.service: Failed with result 'exit-code'.
Aug 06 16:50:47 elderberry systemd[1]: Failed to start IPv4 DHCP server on wlan0.

It seems dhcpd started by systemd does not read my config file /etc/dhcpd.conf

I tried to start dhcpd manually, using the command found in the systemd unit file, but it exits with status 1 without giving any output:

# /usr/bin/dhcpd -4 -q -cf /etc/dhcpd.conf -pf /run/dhcpd4.pid wlan0

I'm out of ideas...

Thanks in advance for your help

Last edited by leonixyz (2019-08-12 20:54:11)

Offline

#2 2019-08-12 20:53:54

leonixyz
Member
Registered: 2014-07-12
Posts: 40

Re: [SOLVED] software access point

My setup did not work because netctl fails to assign an ip address to wlan0 if it is not already connected to a wireless network. But since wlan0 is used by hostapd to actually "create" the network, i have to force netctl to assign an ip address to wlan0.

adding this line to /etc/netctl/wlan0 did the trick

SkipNoCarrier=yes

Offline

Board footer

Powered by FluxBB