3

I'm struggling with setting my static ip, nothing seems to work.

When I enter my interfaces, it says (by default):

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

And that's okay, so, now I just want to assign a static ip, and I am using the wlan0 device in order to do so, as eth0 is unavailable. I try to add in below, for example:

auto wlan0
iface wlan0 inet static
 address 192.168.0.87/24
 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.87/24, 8.8.8.8
 wpa-ssid 'user'
 wpa-psk 'password' # I also tried it with hex value without quotation marks 

For sure, I know that my gateway is like that, all of it comes from the interface settings under nmcli dev list iface wlan0, but then it does not work. When I reboot the system, despite my network manager is properly disabled, the connections do not work, it just freezes and times out every time.

What could possibly wrong here?

  • 2
    Address needs to be a single address, not a range. Leave out the /24, also applies to dns – Jan Sep 30 '14 at 11:02
  • 2
    Unless this is server (no GUI) you should consider setting your interface via the network-manager nm-applet GUI instead of modifying the /etc/network/interfaces file. – steeldriver Sep 30 '14 at 11:16
  • The fault was ultimately the matter or removing quotation marks from the username and putting a value in a hex way. Anyway, I took notes off from your hints and I'll improve my game. Thanks. – Maciej Sitko Sep 30 '14 at 12:13
4

Test this:

Open a terminal.

Run it:

sudo -i
nano /etc/network/interfaces

Add the following lines for you wifi lan adaptor.

----------------------------------------------
# The wifi network interface
auto wlan0
iface wlan0 inet static
    address 192.168.0.87
    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, 8.8.8.8
    wpa-ssid <Your wifi network SSID>
    wpa-psk <Your hex encoded wifi WPA password>
-----------------------------------------------

Control + O, save file. Control + X, close nano.

4

Using the Network Manager GUI did the trick for me on Xubuntu 16.04:

Edit the wifi connection, and on IPv4 tab, enter:

  • Method: Manual
  • Address: xxx.xxx.xxx.xxx (your static address, in my case it was 192.168.2.107)
  • Netmask: 24
  • Gateway: xxx.xxx.xxx.xxx (your gateway address, in my case it was 192.168.2.1)
  • DNS Server: xxx.xxx.xxx.xxx (your gateway address, in my case it was 192.168.2.1)
  • 1
    Hello and welcome to Ask Ubuntu! While this is a good first answer, it can still be improved, with, say, a screenshot. If you feel like this is a good idea, please feel free to edit it into your answer. Otherwise, I'd recommend you read our tour and How to Answer page in order to get a better idea of how this site works, and how to better keep providing awesome content! – Kaz Wolfe Mar 29 '17 at 18:43
  • how do you find your static and gateway address? – ben432rew Jul 15 '17 at 1:45
  • 1
    @ben432rew gateway is the ip of your router, and static is the address you chose (should be done through router first) – smac89 Sep 10 '18 at 1:45
1

To setting up a static IP in Ubuntu the proper way is:

Disable the graphical management of your network connection in /etc/NetworkManager/NetworkManager.conf Gather the information for the static IP (interface, IP to be used, default gateway, subnet, DNS) Modify /etc/network/interfaces to include the information above. Restart networking and network-manager services.

  • "These instructions assume you are using a wired ethernet port to set a static IP on..." – arsaKasra Apr 15 '16 at 12:54

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.