10/29/11 11:59 pm - Setting up a wireless router in Ubuntu Server 11.10I just spent all day figuring this out because none of the howto guides got it exactly right for my setup. I wanted to replace my unreliable wireless router with a PC running Linux. I needed two wired ethernet ports (one for WAN, one for LAN) and a wireless network adapter. Here's the kit I used, but of course there are other choices: CPU/Mobo - Intel E5700, Shuttle XG41 WiFi - Half Mini-PCI Atheros AR9287 The most useful guide was from the Voyage Linux network setup page because it was very close to what I was trying to do. Robert Heywood's blog post was very helpful too - cheers, Robert! I installed Ubuntu Server 11.10, and used apt-get to install the isc-dhcp-server package since I was replacing the existing DHCP server on my LAN. I also installed hostapd to provide the wireless access point function. sudo apt-get install isc-dhcp-server hostapd The magic incantations need to be stored in the following files: /etc/hostapd.conf - this is the configuration for hostapd, where you set up the WPA parameters. It failed to set up the bridge, though, which is where I had problems. I put this in /etc but you can put it where you like as long as you include the path in your hostapd command. /etc/network/interfaces - network interface parameters, and also a useful place to kick off the DHCP server and hostapd. I also needed to add the bridge configuration as a post-up command (none of the howto guides mentioned this). /etc/dhcp/dhcpd.conf - set up the scopes for serving DHCP addresses and options /etc/default/isc-dhcp-server - tells Ubuntu which subnets the DHCP server operates on (you'd think this would be in dhcpd.conf, wouldn't you?). /usr/local/bin/firewall.sh - a firewall configuration script I modified from the Voyage Linux howto page. This script also sets up IP Forwarding, so if you want to set up the router without a firewall you might want to do this as a post-up command in /etc/network/interfaces: echo "1" > /proc/sys/net/ipv4/ip_forward So, here's what I put in those files: /etc/hostapd.conf #Tell hostapd whch interface to operate on interface=wlan0 #For ath9k (AR9287), use the nl80211 driver driver=nl80211 #Set up the SSID, channel, wifi mode, and WPA parameters ssid=my_ssid channel=3 hw_mode=g auth_algs=1 wpa=3 wpa_passphrase=secret_key wpa_key_mgmt=WPA-PSK wpa_pairwise=CCMP TKIP rsn_pairwise=CCMP /etc/network/interfaces iface lo inet loopback #Set up the WAN interface to use DHCP to get its address from the ISP auto eth0 iface eth0 inet dhcp #Set up the wired LAN interface to manual auto eth1 iface eth1 inet manual #Set up the bridge so that wireless and wired LAN are on the same subnet auto br0 iface br0 inet static # Assign your IP address, subnet and mask, broadcast address address 192.168.0.1 netmask 255.255.255.0 broadcast 192.168.0.255 # add eth1 to bridge, wlan0 will be added later bridge_ports eth1 #after the bridge is up we can start dhcp and the firewall post-up /etc/init.d/isc-dhcp-server restart post-up /usr/local/bin/firewall.sh #Set up the wireless LAN interface auto wlan0 iface wlan0 inet manual up iwconfig wlan0 # run hostapd using the hostapd.conf config file we made earlier hostapd /etc/hostapd.conf # hostapd is supposed to add wlan0 to the bridge but it didn't work for me, so I do it here post-up brctl addif br0 wlan0 /etc/default/isc-dhcp-server #Just need to tell the server it's on the bridged network INTERFACES="br0" /etc/dhcp/dhcpd.conf ddns-update-style none; option domain-name "some.domain.com"; #These are the OpenDNS servers, but feel free to use whatever DNS servers you prefer option domain-name-servers 208.67.222.222, 208.67.220.220; default-lease-time 600; max-lease-time 7200; authoritative; log-facility local7; subnet 192.168.0.0 netmask 255.255.255.0 { range 192.168.0.100 192.168.0.149; option routers 192.168.0.1; option ip-forwarding off; option subnet-mask 255.255.255.0; option broadcast-address 192.168.0.255; } /usr/local/bin/firewall.sh Get this from Voyage Network Setup and modify it as you need to. Reboot (or at least restart networking with /etc/init.d/networking restart) and it should work OK. |