2

I know there's a lot of this kind of questions and tutorials about setting static ips, but I've tried everything and still I can't manage to get a static ip. Internet's working fine (I can ping google.com), but I'm not getting the ip I want, I'm still getting a random ip (usually 192.168.1.8)

Here's my config:

auto lo
auto lo intet loopback

auto lo enp2s0
iface lo inet loopback
iface enp0s3 inet static
        address 192.168.0.107
        netmask 255.255.255.0i
        gateway 192.168.1.1
dns-nameservers 200.45.191.35 200.45.48.233 

This is what I get when I put ifconfig -a:

enp2s0    Link encap:Ethernet  HWaddr b8:70:f4:3f:8c:c5  
          inet addr:192.168.1.8  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::ba70:f4ff:fe3f:8cc5/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:380 errors:0 dropped:0 overruns:0 frame:0
          TX packets:363 errors:0 dropped:0 overruns:0 carrier:1
          collisions:0 txqueuelen:1000 
          RX bytes:34659 (34.6 KB)  TX bytes:63438 (63.4 KB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:354 errors:0 dropped:0 overruns:0 frame:0
          TX packets:354 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:59253 (59.2 KB)  TX bytes:59253 (59.2 KB)

tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
          inet addr:10.8.0.1  P-t-P:10.8.0.2  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

wlp3s0    Link encap:Ethernet  HWaddr 38:59:f9:c5:4d:5b  
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

And this is route:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.1.1     0.0.0.0         UG    0      0        0 enp2s0
10.8.0.0        10.8.0.2        255.255.255.0   UG    0      0        0 tun0
10.8.0.2        *               255.255.255.255 UH    0      0        0 tun0
192.168.1.0     *               255.255.255.0   U     0      0        0 enp2s0

And this is my less /etc/resolv.conf

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 200.45.191.35
nameserver 200.45.48.233
search Home
/etc/resolv.conf (END)

Thanks!

  • Check your netmask 255.255.255.0i ? – EdiD Apr 7 '16 at 11:22
  • Your interface is enp2s0. You are addressing enp0s3 – EdiD Apr 7 '16 at 11:24
  • @EdiD Thank you, I modified both things, rebooted but I still can't get the ip I want (192.168.1.107), I'm getting 192.168.1.8 – Ckubrak Apr 7 '16 at 11:32
2

Change in /etc/network/interfaces

auto lo enp2s0
iface lo inet loopback

iface enp2s0 inet static
    address 192.168.1.107
    netmask 255.255.255.0
    gateway 192.168.1.1
    dns-nameservers 200.45.191.35 200.45.48.233 
2

In addition to using the correct interface name, and correcting the netmask line, as suggested in comments, your file also lists the address field as 192.168.0.107 instead of 192.168.1.107.

You also need to remove these two lines:

auto lo enp2s0
iface lo inet loopback

And replace them with:

auto enp2s0

So your whole /etc/network/interfaces file should look like this:

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto enp2s0
iface enp2s0 inet static
 address 192.168.1.107
 netmask 255.255.255.0
 gateway 192.168.1.1
 dns-nameservers 200.45.191.35 200.45.48.233

Rather than rebooting you can restart your interface with:

ifdown enp2s0 && enp2s0
  • Now it gets the ip I want. Now when I want to ssh, "ssh 192.168.1.107" is not working, but "ssh 192.168.1.8" works, which is really weird. I wanted the static ip mostly for ssh. – Ckubrak Apr 8 '16 at 0:44
  • Check whether you can ping the new address. ping 192.168.0.107 – Arronical Apr 8 '16 at 8:37
  • Now something even weirder is happening. I can access from 192.168.1.8 and 192.168.1.107, and yes I can ping 192.168.1.107 – Ckubrak Apr 8 '16 at 14:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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