Ubuntu 18.04 LTS에서 고정 IP를 설정하는 방법

Ubuntu 18.04 LTS에서 고정 IP를 설정하는 방법

목표는 다음과 같은 시스템의 Wi-Fi 장치에 대한 고정 IP를 설정하는 것입니다.내 호스트, Ubuntu 18.04 LTS를 실행 중입니다. 장치 이름은wlp1s0, 필수 IP 주소는 다음과 같습니다.192.168.1.10. 모든 시도가 실패했습니다.

단계 순서:

1) IP 식별:

$ ip route
default via 192.168.1.254 dev wlp1s0 proto dhcp metric 600 
169.254.0.0/16 dev wlp1s0 scope link metric 1000 
192.168.1.0/24 dev wlp1s0 proto kernel scope link src 192.168.1.154 metric 600 

$ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.254   0.0.0.0         UG    600    0        0 wlp1s0
169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 wlp1s0
192.168.1.0     0.0.0.0         255.255.255.0   U     600    0        0 wlp1s0

2) 확인/etc/resolv.conf

$ cat /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
# 127.0.0.53 is the systemd-resolved stub resolver.
# run "systemd-resolve --status" to see details about the actual nameservers.

nameserver 127.0.0.1
search attlocal.net

3) 장치를 끄십시오

sudo ip link set down

4) 편집/etc/네트워크/인터페이스

편집된 버전:

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

auto wlp1s0
iface wlp1s0 inet static
    address 192.168.1.10
    netmask 255.255.255.0
    gateway 192.168.1.254

5) 편집/etc/호스트

편집된 버전:

cat /etc/hosts
127.0.0.1   localhost
192.168.1.10     myhost

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::6 ip6-allnodes
ff02::2 ip6-allrouters
192.168.1.180 mysystem.mydomain

6) 장치 복원:

sudo ip link set wlp1s0 up

7) 기계를 다시 시작하십시오

reboot

다시 시작한 후

$ ip route
default via 192.168.1.254 dev wlp1s0 onlink linkdown 
169.254.0.0/16 dev wlp1s0 scope link metric 1000 linkdown 
192.168.1.0/24 dev wlp1s0 proto kernel scope link src 192.168.1.10 linkdown

$ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.254   0.0.0.0         UG    0      0        0 wlp1s0
169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 wlp1s0
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 wlp1s0

$ dmesg | grep wlp1s0
[   37.095682] iwlwifi 0000:01:00.0 wlp1s0: renamed from wlan0
[   38.911441] IPv6: ADDRCONF(NETDEV_UP): wlp1s0: link is not ready

네임서버를 추가해 보세요./etc/네트워크/인터페이스:

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

auto wlp1s0
iface wlp1s0 inet static
    address 192.168.1.10
    netmask 255.255.255.0
    gateway 192.168.1.254
    dns-nameservers 192.168.1.254

저것아니요일하다.

여기에 무엇이 빠졌나요?

답변1

위에서 언급한 Ubuntu 18.04의 경우 Netplan이 앞으로 나아갈 길인 것 같습니다.

다음과 같은 다양한 유용한 리소스가 있습니다.https://netplan.io/examples/특히 특정 사례의 경우 다음 구성이 작동할 수 있습니다.

network:
version: 2
   wifis:
    wlp1s0:
        dhcp4: no
        addresses: 192.168.1.10
        gateway4: 192.168.1.254
        nameservers:
            addresses: [8.8.8.8]
        access-points:
            "network_ssid_name":
                password: "**********"

들여쓰기는 매우 중요하므로 들여쓰기가 올바르지 않으면 구성이 작동하지 않습니다.

/etc/netplan계속 실행하면 발견되는 yaml 파일에 위의 구성을 추가합니다 sudo netplan --debug apply.

이 명령은 무엇이 잘못되었는지에 대한 정보를 제공하거나 네트워크를 다시 시작합니다.

관련 정보