A wifi AP with a single NIC

8

2

I am trying to use my pc wireless card as an AP, while being connected to my wifi network thru the very same card, but I have a problem. What I am trying to achieve is the equivalent of Windows' Virtual Wi-fi technology. In line of principle, it's very simple:

service network-manager stop
iw dev wlan0 del
iw phy phy0 interface add new0 type station
service network-manager start
iw phy phy0 interface add new1 type __ap
hostapd -B /etc/hostapd.conf

with a suitable configuration for hostapd:

cat /etc/hostapd/hostapd.conf 
interface=new1
driver=nl80211
logger_syslog=-1
logger_syslog_level=2
logger_stdout=-1
logger_stdout_level=2
ssid=XXXX
country_code=us
hw_mode=g
channel=1
macaddr_acl=0
auth_algs=3
ignore_broadcast_ssid=0
eap_server=0
wpa=2
wpa_passphrase=XXXX
wpa_pairwise=TKIP CCMP
rsn_pairwise=TKIP CCMP

However, the driver nl80211 refuses to put the virtual IF new1 into AP mode. Here comes the interesting bit: the output of iw list contains

Supported interface modes:
         * IBSS
         * managed
         * AP
         * AP/VLAN
         * monitor
software interface modes (can always be added):
         * AP/VLAN
         * monitor
valid interface combinations:
         * #{ managed } <= 1, #{ AP } <= 1,
           total <= 2, #channels <= 1, STA/AP BI must match
         * #{ managed } <= 2,
           total <= 2, #channels <= 1

It is obvious my wifi card (an Intel Centrino Advanced-N 6235 [8086:088e] under iwlwifi) supports AP mode (I have tested it), and I had interpreted the "valid interface combinations" to mean that I could have at most 1 managed and 1 AP vifs on this card at the same time. But then I noticed the mysterious-looking constraint, STA/AP BI must match.

Does anyone know what this means, and whether this is what is thwarting my attempts at using two vifs on my card, one in station the other in AP mode? Cheers

MariusMatutiae

Posted 2013-09-23T15:20:42.147

Reputation: 41 321

Same question: http://superuser.com/questions/615664/creating-wifi-access-point-on-a-single-interface-in-linux

– imz -- Ivan Zakharyaschev – 2013-12-15T21:04:48.500

1@imz--IvanZakharyaschev You are quite right, thank you. But my question ws also about the meaning of STA/AP BI must match, which seems to provide some kind of constraint which I have not yet deciphered. – MariusMatutiae – 2013-12-15T21:09:38.470

I'm sorry I haven't taken this detail into account. You are right. But this particular problem isn't obvious from the title, which made me think that having one WiFi adapter is the only problem here... – imz -- Ivan Zakharyaschev – 2013-12-15T21:11:56.263

Answers

5

In case anyone comes here to identify "STA/AP BI must match":

The kernel source in include/net/cfg80211.h, in particular struct ieee80211_iface_combination, says

 * @beacon_int_infra_match: In this combination, the beacon intervals
 *  between infrastructure and AP types must match. This is required
 *  only in special cases.

So BI is the beacon interval, and getting that to match shouldn't be a big problem.

dirkt

Posted 2013-09-23T15:20:42.147

Reputation: 11 627

6

Actually, the mysterious sentence

STA/AP BI must match

seems to have nothing to do with my setup not working. It turns out instead that

 #channels <= 1

was the key to make it work. I eventually understood it means I can use only one channel when I have two vif's on the same physical device (my Intel Centrino, at any rate), one in AP, the other in Station mode. So I switched the channel in the hostapd conf file, to the same I was trying to connect to, and I had no error messages.

At this point I configured iptables, started dnsmasq, then hostapd by means of

echo 1 >/proc/sys/net/ipv4/ip_forward
iptables --table nat --append POSTROUTING --out-interface new0 -j MASQUERADE
iptables --append FORWARD --in-interface new1 -j ACCEPT
dnsmasq 
/usr/local/bin/hostapd /etc/hostapd/hostapd.conf

and then I had it, a single wifi card working symultaneously as Access Point and client to a network connected to the Internet.

MariusMatutiae

Posted 2013-09-23T15:20:42.147

Reputation: 41 321