How to add a Wireless LAN adaptor static IP to Ubuntu that auto connects at startup

  • You need to manually add your wifi (wlan0) interface details to your /etc/network/interfaces file.
  • If you are using a WPA or WPA2 password on your wifi network you need to convert the WPA-PSK password to HEX.
  • To create a HEX encoded key for your wifi network configuration use the following command (remove < >) :
sudo wpa_passphrase <Your Wifi Network SSID>  <Your Wifi WPA/WPA2 password>
  • In this example we are assigning 192.168.0.2 as the fixed IP of our wifi lan adaptor with gateway and dns on 192.168.0.1.
  • Change the network information according to your setup.
  • Open a terminal window and enter:
sudo gedit /etc/network/interfaces
  • The add the following for you wifi lan adaptor to create a fixed IP entry that will auto connect at startup for all users.
  • Save and reboot when done.
# The wifi network interface
auto wlan0
iface wlan0 inet static
    address 192.168.0.2
    netmask 255.255.255.0
    network 192.168.0.0
    broadcast 192.168.0.255
    gateway 192.168.0.1
    dns-nameservers 192.168.0.1, 192.168.0.2, 8.8.8.8
    wpa-ssid <Your Wifi Network SSID>
    wpa-psk <Your HEX encoded Wifi WPA password>
  • After reboot your wifi network should be active and connected with a fixed IP before user login.

Tags: