Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am trying to set up a wifi hotspot using brctl and hostapd on Debian GNU/Linux but it seems it does not work. The steps I follow are the following:

echo 1 > /proc/sys/net/ipv4/ip_forward
brctl addbr br0
brctl addif br0 eth0
dhclient br0

Until now it works and I am able to surf the web using the wired connection. Then, I launch hostapd. It adds wlan0 to the bridge and the wired conncetion stops to work: I am not able to surf the web and the smartphone (with Android) is able to authenticate with the hotspot but does not get an IP address and says "Limited conncetion".

I have read several guides and howtos but I cannot find a solution. Any suggestion?

share|improve this question
    
Would a /etc/networks based answer with bridging be alright? I have a functional config I can share –  Journeyman Geek Feb 1 '14 at 3:52
    
I prefer to set it manually by console but post your config here, thx. –  Gilberto T. Feb 1 '14 at 3:57

2 Answers 2

There are a few key points to consider:

  1. You must disable network manager:

    sudo service network-manager stop
    
  2. You must start hostapd before the bridge:

    sudo hostapd -B /etc/hostapd/hostapd.conf
    
  3. Now you just add eth0 to an existing bridge:

    sudo brctl addif br0 eth0
    
  4. and you put your bridge onto the network:

    sudo dhclient br0
    
  5. Now you have to check that your routing table is working:

    sudo add -net 0.0.0.0/0 gw IP_address_of_your_router dev br0
    sudo del -net 0.0.0.0/0 gw IP_address_of_your_router dev eth0
    
  6. Now you add nameservers to /etc/resolv.conf: as sudo,

    echo nameserver 8.8.8.8 >> /etc/resolv.conf
    echo nameserver 8.8.4.4 >> /etc/resolv.conf
    

Mine works as above: I am writing through it just now.

share|improve this answer
    
assuming he uses network manager. I also seem to think he may need to include wlan0 in the bridge wouldn't he? –  Journeyman Geek Feb 1 '14 at 4:38
    
@JourneymanGeek No he wouldn't: the configuration file for hostapd mmust contain an instruction, bridge=br0, which will create the bridge for him. And of course, the same conf file will contain an instruction interface=wlan0. But it already does, because the OP claims the hostap service is correctly started , and clients can connect. –  MariusMatutiae Feb 1 '14 at 4:48
    
I've tried. In this case "dhclient br0" does not work. –  Gilberto T. Feb 1 '14 at 4:53
    
@GilbertoT. What do you mean by it does not work? You do not get a DHCP offer? –  MariusMatutiae Feb 1 '14 at 5:07
    
Yes, I do not get a DHCP offer for br0. –  Gilberto T. Feb 1 '14 at 5:09

I ended up choosing another way to doing the same thing, based off the guide here - using /hosts/networks is probably better if you need an always on hostapd AP, but probably less use otherwise.

Here's my /etc/networks file - I've set wlan0 as manual , and bridged eth0.

# wireless wlan0
allow-hotplug wlan0
iface wlan0 inet manual

# eth0 connected to the ISP router
allow-hotplug eth0
iface eth0 inet manual
#iface eth0 inet6 auto
# Setup bridge
iface br0 inet static
    bridge_ports wlan0 eth0
    address 192.168.1.127
    netmask 255.255.255.0
    network 192.168.1.0
    gateway 192.168.1.1
    dns-nameservers 192.168.1.1

Your hostapd.conf might also be of interest there - this is a stripped down version of mine, since I chose to edit the 'stock' one. I suspect its pretty likely your problem might be there.

### Wireless network name ###
interface=wlan0
### Set your bridge name ###
bridge=br0
driver=nl80211

###CHANGE ANYTHING BELOW THIS TO SUIT!###

### (IN == INDIA, UK == United Kingdom, US == United Stats and so on ) ###
country_code=SG
hw_mode=g
channel=6
wpa=2
## Key management algorithms ##
wpa_key_mgmt=WPA-PSK

## Set cipher suites (encryption algorithms) ##
## TKIP = Temporal Key Integrity Protocol
## CCMP = AES in Counter mode with CBC-MAC
wpa_pairwise=TKIP
rsn_pairwise=CCMP

## Shared Key Authentication ##
auth_algs=1

## Accept all MAC address ###
macaddr_acl=0
share|improve this answer
    
I don't use "country_code=" "macaddr_acl=". The rest of the configuration file is similar. –  Gilberto T. Feb 1 '14 at 5:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.