반응형

로컬에서 개발용으로 사용하려는 우분투 서버를 설치하면 보통 DHCP IP를 자동할당 받는다.

하지만 이렇게 자동으로 할당 받으면 개발PC 쪽에서 서버에 접속할때 자주 IP를 확인하고 다시 설정해 줘야 하는 불편함이 있다.

IP를 고정으로 설치하면 이런 불편함을 없앨 수 있다.

다음은 고정 IP설정 방법이다.

설명하는 방법은 모두 root권한으로 실시해야 한다.

1. 설정 파일은 /etc/netplan/ 50-cloud-init.yaml 이다. 이 파일을 에디터로 연다.

#nano /etc/netplan/50-cloud-init.yaml
# This file is generated from information provided by
# the datasource.  Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
    ethernets:
        enp2s0:
            dhcp4: true
    version: 2

3. 파일을 다음과 같이 수정한다.

# This file is generated from information provided by
# the datasource.  Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
    ethernets:
        enp2s0:
            dhcp4: no
            addresses: [1xx.xxx.xxx.xxx/24]
            gateway4: 2xx.xxx.xx.xxx
            nameservers:
              addresses: [168.126.63.1,168.126.63.2]
    version: 2

4. 수정파일 저장 후 다음 명령을 수행한다.

#netplan apply

5. IP가 할당 되었는지 다음 명령으로 확인한다.

$ifconfig

* 작업전 각 통신사의 공유기를 접속하여 DHCP의 범위를 조정하여 고정IP로 사용할 IP를 확보해야 한다.

 

server 18.04 고정 IP설정 방법
server 18.04 고정 IP설정 방법

반응형
블로그 이미지

DeveloperN

개발자 n의 개발 이야기(draft)

,