Module 16: Manual Network Connections

Connecting to an Access Point

wpa_supplicant can either be used via a command line interface, with wpa_cli, or with configuration files containing the settings of the network.

Simple wpa_supplicant configuration for an open network:

network={
  ssid="hotel_wifi"
  scan_ssid=1
}

Simple wpa_supplicant configuration for a WPA or WPA2-PSK network:

network={
  ssid="home_network"
  scan_ssid=1
  psk="correct battery horse staple"
  key_mgmt=WPA-PSK
}

wpa_supplicant will automatically choose between TKIP and CCMP based on availability, but it is possible to force one or the other by adding pairwise=CCMP or pairwise=TKIP to the configuration if necessary.

A quick and easy alternative is wpa_passphrase. This tool can generate a configuration file for a basic WPA-PSK network. It requires at least one parameter, the ESSID. The second parameter, the passphrase, is optional, for security reasons. If the second parameter is omitted, it will prompt for the passphrase. This tool will output the content of a configuration file. We can redirect the output to a file with 'wpa_passphrase home_network > home_network.conf'

Connecting to home_network:

kali@kali:~$ sudo wpa_supplicant -i wlan0 -c wifi-client.conf
Successfully initialized wpa_supplicant
wlan0: SME: Trying to authenticate with 00:ef:78:be:0d:98 (SSID='home_network' freq=2437 MHz)
wlan0: Trying to associate with 00:ef:78:be:0d:98 (SSID='home_network' freq=2437 MHz)
wlan0: Associated with 00:ef:78:be:0d:98
wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
wlan0: WPA: Key negotiation completed with 00:ef:78:be:0d:98 [PTK=CCMP GTK=CCMP]
wlan0: CTRL-EVENT-CONNECTED - Connection to 00:ef:78:be:0d:98 completed [id=0 id_str=]
...

With a connection confirmed, we can run wpa_supplicant with -B to run it in the background.

Once connected, request a DHCP lease with dhclient:

Setting up an Access Point

Internet Access

Listing support modes on all wireless interfaces:

Static IP on Access Point Wireless Interface

Setting the IP address for wlan0:

DHCP Server

dnsmasq configuration file, dnsmasq.conf:

Starting dnsmasq:

Checking for dnsmasq in syslog:

Routing

Enabling IP forwarding:

Installing nftables:

Doing masquerade with nftables:

Access Point Mode

hostapd configuration, hostapd.conf:

Starting hostapd with our AP configuration:

With hostapd started and clients connecting successfully, we can later run this in the background by using the -B switch.

Last updated