IP estático no servidor Ubuntu 15.10

IP estático no servidor Ubuntu 15.10

Eu sei que existem muitas dúvidas e tutoriais sobre como configurar ips estáticos, mas já tentei de tudo e ainda não consigo obter um ip estático. A Internet está funcionando bem (posso executar ping no google.com), mas não estou obtendo o IP que desejo, ainda estou obtendo um IP aleatório (geralmente 192.168.1.8)

Aqui está minha configuração:

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 

Isso é o que eu recebo quando colocoifconfig -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)

E isso érota:

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

E este é o meumenos /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)

Obrigado!

Responder1

Mudança em/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 

Responder2

Além de usar o nome de interface correto e corrigir a linha da máscara de rede, conforme sugerido nos comentários, seu arquivo também lista o addresscampo como 192.168.0.107 em vez de 192.168.1.107.

Você também precisa remover estas duas linhas:

auto lo enp2s0
iface lo inet loopback

E substitua-os por:

auto enp2s0

Portanto, todo o seu /etc/network/interfacesarquivo deve ficar assim:

# 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

Em vez de reiniciar, você pode reiniciar sua interface com:

ifdown enp2s0 && enp2s0

informação relacionada