Ubuntu – How to set a static IP in Ubuntu

ipnetworkingUbuntu

How do I set my computer to have a static IP in Ubuntu 11.04? The only two lines in /etc/network/interfaces are:

auto lo
iface lo inet loopback

I think usually when people do this they have a wired connection and just edit the eth0 settings, however I'm using a wireless adapter.

Best Answer

You can use Network Manager with a static IP address.

If you want a system-wide setting, you can use /etc/network/interfaces for a wireless adapter. The only difference with a wired adapter is that you'll need extra settings for the encryption (unless your wifi network is unencrypted).

For WPA (any supported variant), use wpa-supplicant Install wpasupplicant http://bit.ly/software-small.

auto wlan0
iface wlan0 inet static
    address 192.0.2.3
    netmask 255.255.255.0
    broadcast 192.0.2.255
    gateway 192.0.2.1
    dns-nameservers 192.0.2.2
    wpa-ssid chez-jackson
    wpa-psk swordfish

The wpa- parameters are those you could put in a block in wpa_supplicant.conf, with wpa- prefixed.

For WEP, the wireless-tools Install wpasupplicant http://bit.ly/software-small package has all you need. Instead of the wpa- settings, put wireless- settings, e.g.

    wireless-essid chez-jackson
    wireless-key 0123456789abcdef
Related Question