Ubuntu – The correct syntax for /etc/network/interfaces

network-managerwireless

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

Best Answer

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.