Ubuntu 18.04 다중 IP 설정

HYEONG HWAN, MUN/ 7월 5, 2019/ 미분류/ 0 comments

https://blog.lael.be/post/8973

기존의 Ubuntu 16.04 에서는 /etc/network/interfaces 파일을 수정하면 되었는데, 18.04 부터 netplan 이라는 파일로 변경되었더라.

서버의 네트워크 작업은 만약의 상황을 위해 콘솔을 사용할 수 있는 환경에서 진행되어야 한다.

 

IP 주소 설정

# vi /etc/netplan/50-cloud-init.yaml

 

기본적으로 netplan 우선 순위는 50 으로 설정되어 있다.

yml 문법이다. indent(들여쓰기)는 2 space 이다. 문법에 맞추어서 작성해보자.

network:
    ethernets:
        eth0:
            addresses:
            - 121.131.72.199/28
            dhcp4: false
            gateway4: 121.131.72.206
            nameservers:
                addresses:
                - 168.126.63.1
                - 168.126.63.2
                search: []
        eth1:
            dhcp4: true
    version: 2

 

변경 적용하기

# netplan apply

 

즉시 적용된다.

 

 

다음의 명령어도 한번쯤 실행해 보면 좋다.

라우팅 테이블 보기

# route -n

 

====

2021.12.29 추가.

들어오는 IP 와 나가는 IP 가 다를 경우 경로 지정하기. 몇가지 실제 예제 추가.

network:
    ethernets:
        eth0:
            addresses:
            - 10.20.30.112/24
            gateway4: 10.20.30.1
            nameservers:
                addresses:
                - 168.126.63.1
                - 168.126.63.2
        eth1:
            addresses:
            - 121.131.72.204/28
            gateway4: 121.131.72.206
            nameservers:
                addresses:
                - 168.126.63.1
                - 168.126.63.2
            routing-policy:
                - from: 121.131.72.204/28
                  table: 200
                  priority: 10
            routes:
                - to: 0.0.0.0/0
                  via: 121.131.72.206
                  table: 200
        eth2:
            dhcp4: true

 

Leave a Comment

작성하신 댓글은 관리자의 수동 승인 후 게시됩니다.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>
*
*