Skip to content

Instantly share code, notes, and snippets.

@Kyshman
Last active March 14, 2022 17:43
Show Gist options
  • Save Kyshman/0afdc4cd1c35b9db790168dabb41e391 to your computer and use it in GitHub Desktop.
Save Kyshman/0afdc4cd1c35b9db790168dabb41e391 to your computer and use it in GitHub Desktop.
Automatic WiFi Static & DHCP Settings on Startup

Adding Static Wi-Fi IP address on Ubuntu/Debian and derivaties

  • Begin by Hex encoding your wifi details
sudo wpa_passphrase "Your Wifi Network SSID"  "Your Wifi WPA/WPA2 password"

Output:

network={
	ssid="Your Wifi Network SSID"
	#psk="Your Wifi WPA/WPA2 password"
	psk=aeddac6f23c5c5c21d6ef9909837d3f93cf574b6e56f13a23328b1f001f7f53c
}
  • Edit the interfaces configuration file
sudo vi /etc/network/interfaces
  • Add the following to the end of the file or edit the file accordingly if you already have auto wlan0 & iface wlan0 sections
  • Adapt your IPs according to your network
# 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 "aeddac6f23c5c5c21d6ef9909837d3f93cf574b6e56f13a23328b1f001f7f53c"
  • For DHCP
# The wifi network interface
auto wlan0
iface wlan0 inet dhcp
    wpa-ssid "Your Wifi Network SSID"
    wpa-psk "aeddac6f23c5c5c21d6ef9909837d3f93cf574b6e56f13a23328b1f001f7f53c"
  • After reboot your wifi network should be active and connected with a fixed IP before user login.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment