3

How can I use wifi connections as an access point while at the same time connecting to an existing wifi network ?

My experiment:

sudo iw dev wlan0 interface add uap0 type __ap
service dnsmasq restart
sysctl net.ipv4.ip_forward=1
sudo hostapd /etc/hostapd/hostapd.conf

Output:

Configuration file: /etc/hostapd/hostapd.conf
Failed to create interface mon.uap0: -95 (Operation not supported)
uap0: Could not connect to kernel driver
Using interface uap0 with hwaddr b8:27:a1:0f:00:00 and ssid "TESTAP"
Failed to set beacon parameters
uap0: Could not connect to kernel driver
Interface initialization failed
uap0: interface state UNINITIALIZED->DISABLED
uap0: AP-DISABLED
uap0: Unable to setup interface.
uap0: interface state DISABLED->DISABLED
uap0: AP-DISABLED
hostapd_free_hapd_data: Interface uap0 wasn't started
nl80211: deinit ifname=uap0 disabled_11b_rates=0

/etc/hostapd/hostapd.conf:

interface=uap0
ssid=TESTAP
hw_mode=g
channel=10
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=123456789a
wpa_key_mgmt=WPA-PSK
wpa_pairwise=CCMP
wpa_group_rekey=86400
ieee80211n=1
wme_enabled=1
a.gulcan
  • 153
  • 1
  • 4

1 Answers1

4

You have to do three steps:

  1. create a virtual interface ap0 for the access point
  2. start access point daemon hostapd using interface ap0
  3. start wpa_supplicant for wifi client using interface wlan0

You have to do it exactly in this order otherwise the setup will fail. I have seen many attempts to achieve this including restarting services in order with special conditions. I prefer to use systemd because you can define dependencies when services have to start. So you can configure it in a clean order. How to do this in detail you can look at Access point as WiFi repeater, optional with bridge.

Ingo
  • 42,961
  • 20
  • 87
  • 207