PDA

View Full Version : [SOLVED] Setting up access point with hostapd



levk
July 12th, 2011, 04:53 AM
I'm having trouble setting up an access point using hostapd on a Natty server. Well I can set up the access point and connect to it, but I don't get an IP address or an internet connection.

All the guides on the matter point me to making a bridge between my NIC and my WiFi card, however I can't do that. I think it's a recent kernel development - can't add wireless interfaces to a bridge.

I faintly read something concerning this on the Gentoo forums - that hostapd is supposed to do that for me starting version 7.1, so I downloaded the latest source and compiled but I don't see anything pointing to my problem in their sample conf file.

levk@tortuga:~$ grep -v '^#' hostapd.conf | grep -v '^$'
interface=wlan1
logger_syslog=-1
logger_syslog_level=2
logger_stdout=-1
logger_stdout_level=2
dump_file=/tmp/hostapd.dump
ctrl_interface=/var/run/hostapd
ctrl_interface_group=0
ssid=<REMOVED>
hw_mode=g
channel=11
beacon_int=100
dtim_period=2
max_num_sta=255
rts_threshold=2347
fragm_threshold=2346
macaddr_acl=0
auth_algs=3
ignore_broadcast_ssid=0
wmm_enabled=1
wmm_ac_bk_cwmin=4
wmm_ac_bk_cwmax=10
wmm_ac_bk_aifs=7
wmm_ac_bk_txop_limit=0
wmm_ac_bk_acm=0
wmm_ac_be_aifs=3
wmm_ac_be_cwmin=4
wmm_ac_be_cwmax=10
wmm_ac_be_txop_limit=0
wmm_ac_be_acm=0
wmm_ac_vi_aifs=2
wmm_ac_vi_cwmin=3
wmm_ac_vi_cwmax=4
wmm_ac_vi_txop_limit=94
wmm_ac_vi_acm=0
wmm_ac_vo_aifs=2
wmm_ac_vo_cwmin=2
wmm_ac_vo_cwmax=3
wmm_ac_vo_txop_limit=47
wmm_ac_vo_acm=0
ieee80211n=1
ht_capab=[HT40-][SHORT-GI-40][DSSS_CCK-40]
eapol_key_index_workaround=0
eap_server=0
own_ip_addr=127.0.0.1
wpa=2
wpa_passphrase=<REMOVED>
wpa_pairwise=TKIP CCMP
levk@tortuga:~$ ./trash/hostapd-0.7.3/hostapd/hostapd -v
hostapd v0.7.3
User space daemon for IEEE 802.11 AP management,
IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator
Copyright (c) 2002-2010, Jouni Malinen <j@w1.fi> and contributors
levk@tortuga:~$ uname -a
Linux tortuga 2.6.38-8-server #42-Ubuntu SMP Mon Apr 11 03:49:04 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux

I have a feeling I'm doing something wrong anyway, I'm trying to set up a fairly complicated environment here, the box in question has two WiFi cards and a wired ethernet, one of the wireless cards connects to a router in another room and gets to the internet and shares the connection via the wired interface. There's NAT set up with a firewall through iptables and everything I just said works just fine. What I'm trying to do is further share the connection via a wireless access point using a different SSID while getting IP addresses on the same subnet as everything connected through the wired interface.

Here are the related config files:

levk@tortuga:~$ grep -v '^#' /etc/network/interfaces | grep -v '^$'
auto lo
iface lo inet loopback
auto wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/<REMOVED>.conf
auto eth0
iface eth0 inet static
address 192.168.8.1
netmask 255.255.255.0
broadcast 192.168.8.0
network 192.168.8.0
up ifconfig eth0 up
levk@tortuga:~$ cat /etc/iptables.sav
# Generated by iptables-save v1.4.10 on Mon May 16 00:31:42 2011
*nat
:PREROUTING ACCEPT [24:1503]
:INPUT ACCEPT [5:354]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
-A POSTROUTING -j MASQUERADE
COMMIT
# Completed on Mon May 16 00:31:42 2011
# Generated by iptables-save v1.4.10 on Mon May 16 00:31:42 2011
*filter
:INPUT ACCEPT [40:3084]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [2:80]
-A FORWARD -s 192.168.8.0/24 -i eth0 -o wlan0 -m conntrack --ctstate NEW -j ACCEPT
-A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
COMMIT
# Completed on Mon May 16 00:31:42 2011
levk@tortuga:~$ iwconfig
lo no wireless extensions.

eth0 no wireless extensions.

wlan0 IEEE 802.11bgn ESSID:<REMOVED>
Mode:Managed Frequency:2.462 GHz Access Point: <REMOVED>
Bit Rate=108 Mb/s Tx-Power=27 dBm
Retry long limit:7 RTS thr:off Fragment thr:off
Power Management:off
Link Quality=50/70 Signal level=-60 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:1970 Invalid misc:283 Missed beacon:0

wlan1 IEEE 802.11abgn ESSID:off/any
Mode:Managed Access Point: Not-Associated Tx-Power=0 dBm
Retry long limit:7 RTS thr:off Fragment thr:off
Power Management:off

vboxnet0 no wireless extensions.

I'm trying to set up the access point on wlan1. Also I can't use an old kernel because of unrelated reasons - this is a Sandy Bridge system, nothing will work.

Any pointers are greatly appreciated, thanks in advance.

levk
July 12th, 2011, 06:42 PM
Bump

I've tried without bridge by adding the line to iptables for routing and adding the interface to dnsmasq - I use that for DHCP server - to no avail. I can connect with a macbook pro, but do not get an IP address, my Android phone attempts to obtain an address, eventually times out and retries.

levk
July 13th, 2011, 03:58 PM
I solved this problem without making the bridge, I added a route to my iptables for the access point interface. The reason I wasn't getting an IP before is because I forgot to add that part to my DHCP server (I'm using DNS masq)