Wireles Networking is a practical guide to planning and building low-cost telecommunications infrastructure. See the editorial for more information.... |
![]() |
Home ![]() ![]() ![]() |
|
See also: Forwarding, IEEE 802.11 Wireless Networks, Transparent Bridging Access Point | |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
|
Masquerading Access PointScenario 1: Masquerading access point This is the simplest of the scenarios, and is especially useful in situations where you want a single access point for an office setting. This is easiest in a situation where:
Initial setupStart of with an already configured computer running GNU/Linux. This could be an Ubuntu Server installation, or Fedora Core. The computer must have at least 2 interfaces for this to work, and at least one of these interfaces should be wireless. The rest of this description assumes that your cabled Ethernet port (eth0) is connected to the Internet, and that there is a wireless interface (wlan0) that will provide the access point functionality. To find out if your chipset supports master mode, try the following command as root: # iwconfig wlan0 mode Master ...replacing wlan0 with the name of your interface. If you get an error message, then your wireless card doesn't support access point mode. You can still try the same setup in Ad-hoc mode, which is supported by all chipsets. This requires that you to set all the laptops that are connecting to this “access point” into Ad-hoc mode as well, and may not work quite the way you are expecting. It is usually better to find a wireless card that will support AP mode. See the HostAP and MADWiFi websites mentioned earlier for a list of supported cards. Before continuing, make sure dnsmasq is installed on your machine. You can use the graphical package manager of your distribution to install it. In Ubuntu you can simply run the following as root: # apt-get install dnsmasq Setting up the interfacesSet up your server so that eth0 is connected to the Internet. Use the graphical configuration tool that came with your distribution. If your Ethernet network uses DHCP, you could try the following command as root: # dhclient eth0 You should receive an IP address and default gateway. Next, set your wireless interface to Master mode and give it a name of your choice: # iwconfig wlan0 essid “my network” mode Master enc off The enc off switch turns off WEP encryption. To enable WEP, add a hex-key string of the correct length: # iwconfig wlan0 essid “my network” mode Master enc 1A2B3C4D5E Alternately, you can use a readable string by starting with “s:” # iwconfig wlan0 essid “my network” mode Master enc “s:apple” Now give your wireless interface an IP address in a private subnet, but make sure it is not the same subnet as that of your Ethernet adapter: # ifconfig wlan0 10.0.0.1 netmask 255.255.255.0 broadcast 10.0.0.255 up Setting up masquerading in the kernelIn order for us to be able to translate addresses between the two interfaces on the computer, we need to enable masquerading (NAT) in the linux kernel. First we load the relevant kernel module: # modprobe ipt_MASQUERADE Now we will flush all existing firewall rules to ensure that the firewall is not blocking us from forwarding packets between the two interfaces. If you have an existing firewall running, make sure you know how to restore the existing rules later before proceeding. # iptables -F Enable the NAT functionality between the two interfaces # iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE Finally we need to enable the kernel to forward packets between interfaces: # echo 1 > /proc/sys/net/ipv4/ip_forward On Debian-based Linux distributions such as Ubuntu, this change can also be made by editing the file /etc/network/options, and changing the line ip_forward=no to ip_forward=yes and then restarting the network interfaces with: # /etc/init.d/network restart or # /etc/init.d/networking restart Setting up the DHCP serverAt this point we actually should have a working access point. It can be tested by connecting to the wireless network “my network” with a separate machine and giving that machine an address in the same address range as our wireless interface on the server (10.0.0.0/24 if you followed the examples). If you have enabled WEP, be sure to use the same key that you specified on the AP. In order to make it easier for people to connect to the server without knowing the IP address range, we will set up a DHCP server to automatically hand out addresses to wireless clients. We use the program dnsmasq for this purpose. As the name indicates, it provides a caching DNS server as well as a DHCP server. This program was developed especially for use with firewalls performing NAT. Having a caching DNS server is especially helpful if your Internet connection is a high-latency and/or low-bandwidth connection, such as a VSAT or dial-up. It means that many DNS queries can be resolved locally, saving a lot of traffic on the Internet connection, and also making the connection feel noticeably faster for those connecting. Install dnsmasq with your distributions package manager. If dnsmasq is not available as a package, download the source code and install it manually. It is available from thekelleys.org.uk. All that is required for us to run dnsmasq is to edit a few lines of the dnsmasq configuration file, /etc/dnsmasq.conf. The configuration file is well commented, and has many options for various types of configuration. To get the basic DHCP server up and running we just need to uncomment and/or edit two lines. Find the lines that starts: interface= ...and make sure it reads: interface=wlan0 ...changing wlan0 to match name of your wireless interface. Then find the line that starts with: #dhcp-range= Uncomment the line and edit it to suit the match addresses being used, i.e. dhcp-range=10.0.0.10,10.0.0.110,255.255.255.0,6h Then save the file and start dnsmasq: # /etc/init.d/dnsmasq start That's it, you should now be able to connect to the server as an access point, and get an IP address using DHCP. This should let you connect to the Internet through the server. Adding extra security: Setting up a FirewallOnce this is set up and tested, you can add extra firewall rules using whatever firewall tool is included in your distribution. Some typical front-ends for setting up firewall rules include:
Once everything is configured properly, make sure that all settings are reflected in the system startup scripts. This way, your changes will continue to work should the machine need to be rebooted.
|
|
Home ![]() ![]() ![]() |