Project Home
Project Home
Discussion Forums
Project Information
Project Info will be offline from May 31 6:00pm until June 2 12:00AM for upcoming system upgrades. For more information please go to
wiki1664: Wifi_tcpip_config_wiki_page

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 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 (Where is your wireless interface IP address)
  • route add default (Where is your network gateway)
  • cat /etc/resolv.conf
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;
default-lease-time 86400;
#max-lease-time 7200;

subnet netmask {
        option broadcast-address;
        option routers;
        option domain-name-servers;
        option domain-name "";

        host printerserver {
               hardware ethernet 00:50:BA:85:EA:30;

        host networkenabledtoaster {
               hardware ethernet 00:A0:D2:11:AE:81;

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 Note that we have reserved IP address range to for static IP address assignment. The dynamic range starts at

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

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

Configuring an Access Point as a Router #

Step 1: Make sure the outsider network interface on your access point is active. That is, your access point is active on the wired network that it's connected too.

Step 2: Configure the access point interface. The simplest mechanism to use for this is WEP. Say we want our wireless network to advertize "MY_WIRELESS_NET" and our WEP secret is "MYWIRELESSWEP. We have to...

	#sysctl -w net.inet.ip.forwarding=1 <--- allow packets coming in from one interface to be forwarded (routed) out another 
	#ifconfig in_nic mediaopt hostap <--- Place the wireless interface into access point mode.
	#ifconfig in_nic ssid MY_WIRELESS_NET nwkey MYWIRELESSWEP <-- Configure the wireless interface to be a WEP network with associated key
	#ifconfig in_nic up <- Bring up the interface

Step 3: See above for how you set up DHCP to distribute IP addresses to the wireless client. Briefly, you provide a dhcp.conf with a configuration section as follows which defines the internal network,

	subnet netmask {

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 your dhcp.conf and release file are if you put them into the default place under /etc. Check dhcpd for more information.

To use WPA or WPA2, you need to set up and run "hostapd" (the server side application associated with the clients "wpa_supplicant") to do the authentication / key exchange for your network.

You can also configure your access point as a NAT network router as follows:

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

For details of how to configure a NAT, please refer to the related page on our wiki page or visit