If you want to connect to a wireless network on Ubuntu or any other Debian based Linux distro, one of the many ways to do it is by editing the
/etc/network/interfaces file with your Wi-Fi network info.
This is a command line only method, so it’s very useful if you don’t have a GUI installed on the system but need to get on to the WiFi network. It will also support DHCP or static configuration. Read on to see how to connect to a wireless network by editing this file.
In this tutorial you will learn:
- Connect to wireless network via
|Category||Requirements, Conventions or Software Version Used|
|System||Debian based distros|
|Other||Privileged access to your Linux system as root or via the
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of
$ – requires given linux commands to be executed as a regular non-privileged user
Edit /etc/network/interfaces file
- Start by finding the name of your wireless network interface. A simple
ip acommand should do the trick. The output will most likely show your Wi-Fi interface as
wlp3s0, or something similar.
- Next, edit your system’s
/etc/network/interfacesfile and append the following lines to use DHCP. Even if the file doesn’t already exist on your system, you can create it and it will be read by the network manager.
auto wlan0 iface wlan0 inet dhcp wpa-essid mywifiname wpa-psk mypass
Be sure to replace
wlan0with the name of your own wireless interface, and substitute your own Wi-Fi’s name (ESSID) and password where we’ve put our examples.
- Alternatively, you can copy and paste the following example and substitute your own values if you wish to use a static IP configuration.
auto wlan0 iface wlan0 inet static address 192.168.1.150 netmask 255.255.255.0 gateway 192.168.1.1 wpa-essid mywifiname wpa-psk mypass
- To make the changes take effect, it’s best to completely restart the system.
$ sudo reboot
That’s all there is to it. If you configured everything correctly, your interface should connect automatically to the wireless network upon future reboots.