우분투 서버 15.10의 고정 IP

우분투 서버 15.10의 고정 IP

고정 IP 설정에 대한 이런 종류의 질문과 튜토리얼이 많다는 것을 알고 있지만 모든 것을 시도했지만 여전히 고정 IP를 얻을 수 없습니다. 인터넷은 잘 작동하지만(google.com에 핑할 수 있음) 원하는 IP를 얻지 못하고 여전히 임의의 IP(보통 192.168.1.8)를 얻습니다.

내 구성은 다음과 같습니다.

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 

내가 넣었을 때 얻는 것은 이것이다.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)

그리고 이건노선:

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

그리고 이건 내꺼야덜 /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)

감사해요!

답변1

변경/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

주석에서 제안한 대로 올바른 인터페이스 이름을 사용하고 넷마스크 줄을 수정하는 것 외에도 파일에는 필드가 address192.168.1.107 대신 192.168.0.107로 나열됩니다.

다음 두 줄도 제거해야 합니다.

auto lo enp2s0
iface lo inet loopback

그리고 다음으로 교체하세요:

auto enp2s0

따라서 전체 /etc/network/interfaces파일은 다음과 같아야 합니다.

# 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

재부팅하는 대신 다음을 사용하여 인터페이스를 다시 시작할 수 있습니다.

ifdown enp2s0 && enp2s0

관련 정보