Project Home
Project Home
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
wiki1664: Wifi_tcpip_config_wiki_page (Version 5)

TCP/IP Configuration in A Wireless Network (Client in Infrastructure Mode, or Ad-hoc Mode)#

Assigning an IP address to your wireless interface is independent of the 802.11 network configuration and uses the same utilities or daemons as a wired network. The main issue is whether your TCP/IP configuration is dynamically assigned, or statically configured. A static TCP/IP configuration can be applied regardless of the state of your wireless network connection. The wireless network could be active, or it could be unavailable until later. A dynamically assigned TCP/IP configuration (via the DHCP protocol) requires that the wireless network configuration be active, so that it can reach the DHCP server somewhere on the network. This is typically applied in a network that is centrally administered (using Infrastructure Mode with a WAP).

The most common use case is that you are a client using a Wireless Access Point to connect to the network. In this kind of network, there should be a DHCP server available. After the 802.11 network status is active, you just need to start dhcp.client to complete your TCP/IP configuration

  • dhcp.client -iral0

As an alternative, you could use lsm-autoip.so. AutoIP is a special case in that it negotiates with its peers on the network as they become available. You do not need to wait until the network link is active to launch it. AutoIP will assign your network interface an IP address, and resolve any IP address conflicts with your network peers as they are discovered by either your host or the peer changing its current IP address. You will be able to use this IP address once the wireless network is active. Please see the AutoIP documentation for more information.

The last configuration option is a static configuration, which does not change without intervention from the user. An example of a static configuration is

  • ifconfig ral0 10.0.0.5 (Where 10.0.0.5 is your wireless interface IP address)
  • route add default 10.0.0.1 (Where 10.0.0.1 is your network gateway)
  • cat /etc/resolv.conf
		domain company.com 
		nameserver 10.0.0.2 
		nameserver 10.0.0.3 
The other use case is an ad-hoc network. This network mode will typically be made up of a number of standalone peers with no central services. Since there is no central server it is likely that DHCP services will not be available.

If there are Windows or Apple systems on your ad-hoc network, they will enable the AutoIP protocol to assign an IP address. By using AutoIP, you will avoid IP address conflicts (two or more hosts using the same IP address) and avoid having to configure a new IP manually. Your IP address will be automatically configured, and you will be able to exchange TCP/IP packets with your peers.

If you are using a static configuration in an ad-hoc network, you will have the added task of deciding what IP address will be used on each system, making sure that there is no conflicts, and that all the IP addresses assigned are on the same subnet so that the systems can communicate.

TCP/IP Configuration in A Wireless Network (DHCP Server On WAP Acting As a Gateway)#

If you have configured your WAP to act as a gateway, you will have your wireless network on a separate subnet from your wired network. In this case you could be using infustructure mode or ad-hoc mode. The instructions below could work in either infustructure mode or ad-hoc mode. You will likely be using infustructure mode though so that your network is centrally administered. There are also two ways you can go about implementing DHCP services. Running dhcpd directly on your gateway, or using dhcprelay to contact another dhcp server elsewhere in the ISP or corporate network which manages DHCP services for subnets.

If you are running dhcpd on your gateway, it could be that your gateway is for a SOHO. In this case, your gateway is directly connected to the internet, or an IP network for which you do not have control or administrative privileges. You may also be using NAT in this case as you have only been provided one IP address by your Internet Service Provider. Alternatively, you may have administrative privileges for your network subnet which you manage.

If you are running dhcprelay on your gateway, your network subnet is managed elsewhere. You are simply relaying the dhcp client requests on your subnet to the DHCP server which exists elsewhere on the network. Your relay agent will forward the client requests to the server, and pass the reply packets back to the client.

These configuration examples assume that you have an interface other than the wireless network adapter which is completely configured to exchange TCP/IP traffic and reach any servers noted in these configurations which exist outside of the wireless network. Your gateway will be forwarding IP traffic between this interface and the wireless interface.

Launching The DHCP Server On Your Gateway#

This section will discuss launching the dhcp server on the gateway.

  • DHCP Server Configuration File

This is a simple dhcpd configuration file. This file includes a subnet range which is dynamically assigned to clients, but also contains two static entries which are known servers which are expected to be present at certain IP addresses. One is a printer server, the other is a network enabled toaster (because we can!). The dhcp server configuration is not wireless specific, and can be applied to wired networks as well.


ddns-update-style none;

#option subnet-mask 255.255.255.224;
default-lease-time 86400;
#max-lease-time 7200;

subnet 192.168.20.0 netmask 255.255.255.0 {
        range 192.168.20.41 192.168.20.254;
        option broadcast-address 192.168.20.255;
        option routers 192.168.20.1;
        option domain-name-servers 192.168.20.1;
        option domain-name "soho.com";

        host printerserver {
               hardware ethernet 00:50:BA:85:EA:30;
               fixed-address 192.168.20.2;
        }

        host networkenabledtoaster {
               hardware ethernet 00:A0:D2:11:AE:81;
               fixed-address 192.168.20.40;
        }
}

The nameserver, router IP, and IP address will be supplied to your wireless network clients. The router IP address is the IP address of the gateways's wireless network interface which is connected to your wireless network. The nameserver is set to the gateway's wireless network adapter since the gateway is also handling name serving services. The gateway nameserver will redirect requests for unknown hostnames to the ISP nameserver. The internal wireless network has been defined to be 192.168.20.0. Note that we have reserved IP address range 192.168.20.1 to 192.168.20.40 for static IP address assignment. The dynamic range starts at 192.168.20.41.

Now that we have the configuration file, we need to start dhcpd.

We need to make sure that the directory /var/run exists as well as /var/state/dhcp. The file /var/state/dhcp/dhcpd.leases must exist. You can create an empty file for the initial start of the dhcpd binary.

When you start dhcpd, you must start it with the location of the configuration file if it is not in the default location. You will also want to pass an interface name as you only want dhcpd to service your internal wireless network interface. If we used the adapter from the wireless discussion, this would be ral0.

dhcpd -cf /etc/dhcpd.conf ral0

Your DHCP server should now be running. If there are any issues, you can start dhcpd in a debugging mode using the option -d. dhcpd also logs to the syslog.

  • Launching The DHCP Relay Agent On Your Gateway

The dhcprelay agent does not require a configuration file as the DHCP server does. You just need to launch a binary on the command line. What you must know is the IP address of the DHCP server which is located elsewhere on the network to which your gateway is connected . Once this binary has been launched, it will forward requests and responses between the client on your wireless network, and the DHCP server located elsewhere on the ISP or corporate network.

dhcprelay -i ral0 10.42.42.42

In this case it will relay requests from wireless interface ral0, and forward these requests to the DHCP server 10.42.42.42.

Configure the Access Point as a router #

Suppose we have our wireless network that is centered to the Access point which we are going to use it as the gateway. Let us say on the access point the wireless card to the internal network "in_nic", which the wireless workstations is to associate to in order to join the network. First let us construct the internal wireless network, say 10.42.42.0/24.

Step 1: Make sure the outsider network interface on your access point is active. That is, your access point has joined the outside network.

Step 2: Configure the access point interface in_nic. The practical simplest one is a WEP network. Say we want our wireless network called "MY_WIRELESS_NET" and we want our WEP secret is "MYWIRELESSWEP", we do the following.

	#sysctl -w net.inet.ip.forwarding=1 <--- so that packets are able to go out and in. 
	#ifconfig in_nic mediaopt hostap <--- so that the wireless interface is to operate in access point mode.
	#ifconfig in_nic ssid MY_WIRELESS_NET nwkey MYWIRELESSWEP <-- so that the network is a WEP one. 
	#ifconfig in_nic 10.42.0.1 up <-- done.

Step 3: You may want to use dhcp protocol to distribute IP addresses to the internal workstations. That is the same as described above section. Briefly, you have a session in your dhcp.conf which defines your internal network,

	subnet 10.42.42.0 netmask 255.255.255.0 {
		range 10.42.0.2 10.42.0.120;
		....;
	}

And then you run dhcpd as

	#dhcpd -cf full_path_to_your_dhcp_config_file -lf full_path_to_your_release_file ni_nic

You don't need to specify where are your dhcp.conf and release file if you put them under the dhcpd's default place. Check dhcpd for detail information.

You can also configure your wireless network as a more advanced one, say WPA or WPA2. Then you need to run "hostapd" to do the authentication for your network.

You can also configure your access point as a NAT network router. Then you need to do,

	#mount -Ttcpip lsm-pf.so <-- so that the PF module is loaded.
	use pfctl to do the configuration. 

For details of how to configure a natted network, please refer to the related page on our wiki page or visit www.netbsd.org/documentation/




Active Tab Versions Inactive Tab - left sideAssociations Inactive Tab - left sideAttachments Inactive Tab - left sideBack LinksInactive Tab - right side  
    Version From To Version Comment Created By
    Version 7 Add missing - to lsm-pf-v4.so Robert Craig  -  04/13/2009
    Version 6 Robert Craig  -  11/30/2007
    Version 5 Weijie Zhang(deleted)  -  11/30/2007
    Version 4 Weijie Zhang(deleted)  -  11/30/2007
    Version 3 initial dhcp server documentation Dave Brown  -  11/13/2007
    Version 2 Robert Craig  -  11/09/2007
    Version 1 Robert Craig  -  11/06/2007