Madwifi Wireless Access Point

From Gentoo Linux Wiki

Jump to: navigation, search
Note: This configuration is for kernels prior to 2.6.29.x. If you are using kernel 2.6.29.x or newer then see this guide

You can use madwifi to create a wireless access point. This article explains how.

Contents

[edit] Installation

Configure your kernel as follows.

Linux Kernel Configuration: Tree
[*] Enable loadable module support  --->
 [*]   Module unloading
 [ ]   Module versioning support

Device Drivers  --->
 [*] Network device support  --->
  Wireless LAN  --->
   [*] Wireless LAN (IEEE 802.11)

[*] Networking support  --->
 [*]   Wireless  --->
  [*]   Wireless extensions
 
 Networking options  --->
  <*> 802.1d Ethernet Bridging     (Optional)

-*- Cryptographic API  --->
 <*>   HMAC support
 <*>   AES cipher algorithms

You will need CONFIG_KMOD=y (Not sure where it is located in menuconfig)
You will need CONFIG_SYSCTL=y (Not sure where it is located in menuconfig)

Or if you prefer here is what your .config should look like.

Linux Kernel Configuration: .config
#CONFIG_MODVERSIONS is not set
CONFIG_MODULES=y
CONFIG_MODULE_UNLOAD=y
CONFIG_KMOD=y
CONFIG_NETDEVICES=y
CONFIG_WIRELESS_EXT=y
CONFIG_WLAN_80211=y
CONFIG_SYSCTL=y
CONFIG_CRYPTO=y
CONFIG_CRYPTO_HMAC=y
CONFIG_CRYPTO_AES=y
CONFIG_BRIDGE=y          (optional)

You will need several packages: Atheros wireless drivers:

emerge -a madwifi-ng madwifi-ng-tools
Note: madwifi-ng needs to be re-emerged after kernel updates. Make sure /usr/src/linux links to your new kernel.

hostapd is required to run a WAP:

emerge -a hostapd

Services for your WAP (DHCP and DNS):

emerge -a dhcp bind

Make sure bind is listening on 192.168.0.1 and 192.168.1.1. If you are doing ethernet bridging then Bind only needs to be listening on 192.168.0.1

Optional: If you want to do ethernet bridging:

emerge -a bridge-utils

[edit] Ethernet Setup

This article assumes you have eth0 connecting to the Internet, eth1 is a wired subnet and ath0 is a wireless subnet.

cd /etc/init.d
ln -s net.lo net.eth1
ln -s net.lo net.ath0

Optional:

ln -s net.lo net.br0

Load module:

modprobe ath_pci update-modules

Edit the following files:

File: /etc/modprobe.d/ath_pci
   options ath_pci autocreate=ap
File: /etc/conf.d/local.stop
   ifconfig ath0 down
   wlanconfig ath0 destroy
   wlanconfig ath0 create wlandev wifi0 wlanmode ap

There are two possible configurations that can occur here depending whether or not you want to do Ethernet bridging. Ethernet bridging allows you to combine your wired subnet and wireless subnet together into one subnet so you can copy files, stream video or music between a wired and wireless system and see all your computers in "My Network Place".

[edit] Without Ethernet Bridging

Edit the following files as shown...

File: /etc/conf.d/net (baselayout 1.x)
config_eth0=( "Enter your information here" )     (See /etc/conf.d/net.example)
config_eth1=( "192.168.0.1 netmask 255.255.255.0 broadcast 192.168.0.255" )
config_ath0=( "192.168.1.1 netmask 255.255.255.0 broadcast 192.168.1.255" )
mode_ath0="master"
essid_ath0="MyNetwork"
File: /etc/conf.d/net (baselayout 2.x)
config_eth0="Enter your information here"    (See /etc/conf.d/net.example)
config_eth1="192.168.0.1 netmask 255.255.255.0 broadcast 192.168.0.255"
config_ath0="192.168.1.1 netmask 255.255.255.0 broadcast 192.168.1.255"
mode_ath0="master"
essid_ath0="MyNetwork"
File: /etc/conf.d/dhcpd
DHCPD_IFACE="eth1 ath0"
File: /etc/dhcp/dhcpd.conf
ddns-update-style none;
authoritative;
subnet 192.168.0.0 netmask 255.255.255.0 {
range 192.168.0.75 192.168.0.100;
option domain-name-servers 192.168.0.1;              (Make sure BIND is listening on this IP)
option domain-name "hostname.domain.tld";
option routers 192.168.0.1;
option broadcast-address 192.168.0.255;
default-lease-time 10000;
max-lease-time 20000;
}
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.75 192.168.1.100;
option domain-name-servers 192.168.1.1;               (Make sure BIND is listening on this IP)
option domain-name "hostname.domainn.tld";
option routers 192.168.1.1;
option broadcast-address 192.168.1.255;
default-lease-time 10000;
max-lease-time 20000;
}

[edit] With Ethernet Bridging

Edit the following files as shown...

File: /etc/conf.d/net (baselayout 1.x)
config_eth0=( "Enter your information here" )     (See /etc/conf.d/net.example)
config_eth1=( "null" )
config_ath0=( "null" )
bridge_br0=( "eth1" "ath0" )
config_br0=( "192.168.0.1 netmask 255.255.255.0 broadcast 192.168.0.255" )
channel_ath0="1"
mode_ath0="master"
essid_ath0="MyNetwork"
File: /etc/conf.d/net (baselayout 2.x)
config_eth0="Enter your information here"     (See /etc/conf.d/net.example)
config_eth1="null"
config_ath0="null"
bridge_br0="eth1 ath0"
config_br0="192.168.0.1 netmask 255.255.255.0 broadcast 192.168.0.255"
channel_ath0="1"
mode_ath0="master"
essid_ath0="MyNetwork"
File: /etc/conf.d/dhcpd
DHCPD_IFACE="br0"
File: /etc/dhcp/dhcpd.conf
ddns-update-style none;
authoritative;
subnet 192.168.0.0 netmask 255.255.255.0 {
range 192.168.0.75 192.168.0.100;
option domain-name-servers 192.168.0.1;               (Make sure BIND is listening on this IP)
option domain-name "hostname.domain.tld";
option routers 192.168.0.1;
option broadcast-address 192.168.0.255;
default-lease-time 10000;
max-lease-time 20000;
}

[edit] Configuration of Hostapd

I will make this simple, here is a configuration that just works for hostapd-0.4.9 and hostapd-0.5.10 (well it did for me anyways)

File: /etc/hostapd/hostapd.conf
   interface=ath0 
   #bridge=br0                          (optional, if you want bridging remove the #) 
   driver=madwifi 
   logger_syslog=-1 
   logger_syslog_level=2 
   logger_stdout=-1 
   logger_stdout_level=1 
   debug=0 
   dump_file=/tmp/hostapd.dump 
   ctrl_interface=/var/run/hostapd 
   ctrl_interface_group=0 
   ssid=MyNetwork 
   macaddr_acl=0 
   accept_mac_file=/etc/hostapd/hostapd.accept 
   deny_mac_file=/etc/hostapd/hostapd.deny 
   auth_algs=1 
   wpa=1 
   wpa_passphrase=Enter your Passphrase            
   wpa_key_mgmt=WPA-PSK 
   wpa_pairwise=TKIP CCMP

[edit] Services

Configure your startup scripts

rc-update add net.eth0 default rc-update add net.eth1 default rc-update add net.ath0 default rc-update add hostapd default

Optional:

rc-update add net.br0 default

Here are some iptables rules you might use when doing Ethernet bridging

iptables -A INPUT -i br0 -p all -j ACCEPT iptables -A FORWARD -i br0 -p all -j ACCEPT

That's it. Just reboot and you should be all set.

[edit] Troubleshooting

Sometimes hostapd does not look for the right device, such as looking for wlan0 when you have ath0. Besides from setting things appropriately in /etc/hostapd/hostapd.conf, you will also have to edit /etc/conf.d/hostapd

File: /etc/conf.d/hostapd
INTERFACES="ath0"
Personal tools
In other languages