I wanted to use my desktop with a wired ethernet connection (eth0) to operate my "TP-LINK TL-WN722N" USB Wifi Adapter (wlan0) as a non-adhoc (infrastructure mode) access point for my Android to connect to.
After MUCH searching, I finally found a method (spread across many websites) that does most of what I need...
Dependencies:
hostapd
bridge-utils
I modified "/etc/network/interfaces"
sudo gedit /etc/network/interfaces
to contain:
# This file describes the network interfaces available on your system
# and how to activate them.
auto lo br0
iface lo inet loopback
allow-hotplug eth0
iface eth0 inet manual
allow-hotplug wlan0
iface wlan0 inet manual
# Bridge setup
# for dhcp address
iface br0 inet dhcp
bridge_ports eth0 wlan0
# for static ip
# iface br0 inet static
# bridge_ports eth0 wlan0
# adapt with your network settings
# address 192.168.1.250
# netmask 255.255.255.0
# network 192.168.1.0
# broadcast 192.168.1.255
# gateway 192.168.1.1
# dns-* options are implemented by the resolvconf package, if installed
# dns-nameservers 192.168.1.1
# dns-search localdomain
### Reference ###
# Creating a Wireless Access Point with Debian Linux « Agent Oss (October 31, 2011)
# https://agentoss.wordpress.com/2011/10/31/creating-a-wireless-access-point-with-debian-linux/
My "/etc/hostapd/hostapd.conf" (which I somehow managed to put together myself)
sudo gedit /etc/hostapd/hostapd.conf
contains:
### Guts ###
interface=wlan0
bridge=br0
driver=nl80211
### General ###
ssid=____________________
hw_mode=g
channel=1
### Security ###
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0 ## 0 visible # 1 hidden ##
wpa=2
wpa_passphrase=____________________
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
### Reference ###
## Created Tuesday, February 14, 2012 ## Ubuntu 11.10/12.04 ##
# Hostapd Linux Documentation Page
# http://linuxwireless.org/en/users/Documentation/hostapd
# Creating a Network Bridge on Ubuntu (January 16th, 2011)
# http://webserver.linuxportal.nl/?p=422
(I've edited out the security bits for this post)
All of that allows me to open up a Terminal and execute:
sudo hostapd -B /etc/hostapd/hostapd.conf
to have a functioning access point that my Android and all other WiFi devices can connect to.
Aside from sharing this method with others since info for this setup is so sparse; there are three problems that would be nice to fix:
- This configuration deactivates network manager and all of its functions. When you click it, it gives a "device not managed" message. (not essential, but a bit annoying to me)
- This method can struggle with IP addresses from time to time.
I must use a terminal to turn on Wifi. (Ok for me, but not family friendly).I figured out how to make a launcher using gksu and a simple script if anyone needs one...
- (Why can't network manager do this out-of-the-box??)
Thanks in advance! I hope all of this can help someone else; I've never written a tutorial before and know virtually nothing about networking...
Perhaps related to network bridge - without destroying network manager (among others).
Tested using Ubuntu 11.10, 12.04.
I'm not sure about how to do this without clobbering NM, but it is possible to run automatically at boot and get IP addresses to assign easily (at least I have managed this with the same wireless card). This requires the packages
hostapd
anddnsmasq
(notdnsmasq-base
)/etc/hostapd/hostapd.conf:
/etc/default/hostapd:
/etc/dnsmasq.conf (diff against maintainer's version):
/etc/network/interfaces:
/etc/sysctl.conf patch (run
sudo sysctl -p /etc/sysctl.conf
after changing):Finally, set up NAT in
iptables
:and add
iptables-restore < /etc/iptables.sav
aboveexit 0
in/etc/rc.local
.This setup was mostly implemented by reading this howto and staring at man pages scratching my head.
Most trouble occurs because of the Broadcom drivers in HP Laptops at least. If you have a broadcom network controller Check if your card is compatible with b43(link 1). If it is, awesome, keep reading. The default Broadcom sta driver (wl) will not support access point mode. So install b43 taking precautionary measure to be online by any means necessary. Turn it on using modprobe. Now follow instructions and try to set up access point.
I've finally got hostapd working with this and the sweet part is that my Nokia phone can detect the wifi so created (It can detect anything, adhoc or not). Now I have to play around with your file and see if I can get my playbook to detect.
Excellent answers above, however it's not just one or two chipsets that don't support hostapd or AP mode.
Here's how to see if your driver and hardware supports AP mode:
Look for the "supported interface modes" section. If it doesn't include "AP", you're out of luck. If it does say "AP", then proceed with the many good instructions already provided by other posters!