본문 바로가기
개발환경/Ubuntu

Ubuntu 18.04 고정 IP 설정

by xangmin 2020. 4. 28.
반응형

 글 시작에 앞서 다음 블로그에 대한 내용을 보고 참고했다.

출처 : https://hanseokhyeon.tistory.com/entry/Ubuntu-1804-%EA%B3%A0%EC%A0%95-IP-%EC%84%A4%EC%A0%95%ED%95%98%EA%B8%B0?category=830462

 

1. IP 확인

ifconfig

 

result:

enp2s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet xxx.xxx.xx.xx  netmask 255.255.255.0  broadcast xxx.xxx.xx.255
        inet6 fe80::7285:c2ff:fe69:98df  prefixlen 64  scopeid 0x20<link>
        ether 70:85:c2:69:98:df  txqueuelen 1000  (Ethernet)
        RX packets 15300  bytes 2387677 (2.3 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1335  bytes 211254 (211.2 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 16  memory 0xdf100000-df120000

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 532  bytes 46585 (46.5 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 532  bytes 46585 (46.5 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

 enp2s0에서 inet xxx.xxx.xx.xx로 현재 내 유동 IP를 확인할 수 있다.

 

2. netplan 설정 파일 수정

cd /etc/netplan
sudo vim 01-network-manager-all.yaml

Before:

# Let NetworkManager manage all devices on this system
network:
  version: 2
  renderer: NetworkManager

After:

# Let NetworkManager manage all devices on this system
network:
  version: 2
  renderer: NetworkManager
  ethernets:
    enp2s0:
      addresses:
        - xxx.xxx.xx.xx/24
      gateway4: xxx.xxx.xx.254
      nameservers:
        addresses: [168.126.63.1]

 

3. netplan 적용

sudo netplan apply

 

4. IP 확인

 

5. ssh로 접속 환인

ssh kimsangmin@xxx.xxx.xx.xx

 

 

반응형

댓글