3

How do I configure /etc/network/interfaces for my wifi?

When I cant to set a static IP for my ethernet card I use the following configuration:

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
   address 192.168.1.xxx
   network 192.168.1.0
   netmask 255.255.255.0
   gateway 192.168.1.1
   broadcast 192.168.1.255

dns-nameservers 208.67.222.222
dns-search lan
dns-domain lan

This works a treat, but when I apply the same logic to my wlan0, it doesn't work!

So what is the correct way to set a static IP for my wlan0?

Thanks

lloowen
  • 99
  • 2
    Have you taken a look at the manpage? man 5 interfaces (command line) and this example on the Debian Wiki. WiFi requires additional settings like passphrases and SSID. Why don't you use Network Manager to assign a static IP? Or are you on a headless server? – gertvdijk Jan 21 '13 at 17:36

2 Answers2

4

Wireless will require the addition of the network you intend to connect to and any encryption details. Also, your interfaces file is a bit busy; may I suggest:

auto lo
iface lo inet loopback

auto wlan0
iface wlan0 inet static
address 192.168.1.xxx
netmask 255.255.255.0
gateway 192.168.1.1
wpa-ssid mynetwork
wpa-psk 0123456789

dns-nameservers 208.67.222.222 8.8.8.8
dns-search lan
dns-domain lan

I also suggested a backup DNS nameserver. If you are not using WPA or WPA2, the wording will be slightly different.

chili555
  • 60,188
  • For wpa-psk: use the hash value returning from $ wpa_passphrase myssid my_very_secret_passphrase – Gayan Weerakutti Jun 05 '17 at 18:26
  • @reversiblean /etc/network/interfaces expects the psk in clear text, not a hash. – chili555 Aug 23 '17 at 20:32
  • @chili555 wpa_passphrase is the tool to get the hash for the interfaces file AFAIK. – Thufir Nov 29 '17 at 14:18
  • It is the tool to get the hash for a wpa_supplicant.conf file that can, in turn, be referred to in /etc/network/interfaces. The interfaces file, if it does not call up a wpa_supplicant file, using the format I use above, expects the password in clear text, not a hash. – chili555 Nov 29 '17 at 15:06
0

Use Network Manager to configure your network interfaces install network manager by sudo apt-get install network-manager-gnome command . https://help.ubuntu.com/community/NetworkManager

JOGOOL
  • 84
  • 1
  • 7
  • I honestly don't see the point of network manager, it's an extra layer of configuration that just doesn't need to be there and doesn't help in any way, but just confuses matters. I generally uninstall it immediately after installing an operating system because I like to be in control of configs. – Owl Jan 20 '20 at 09:59