본문 바로가기
공부/Ubuntu

ubuntu network 설정

by CITTA 2023. 2. 3.
728x90
반응형

OS : Ubuntu 20.04

root 계정으로 구성하였음

  1. config 파일을 확인
$ ls -al /etc/netplan/
total 12
drwxr-xr-x  2 root root 4096 Jan 26 15:31 .
drwxr-xr-x 88 root root 4096 Jan 26 16:04 ..
-rw-r--r--  1 root root  194 Jan 26 15:31 01-netcfg.yaml

## ubuntu 18.04 live version은 50-cloud-init.yaml
## 기본적으로 아무 설정이 되어 있지 않다.

$ cat /etc/netplan/01-netcfg.yaml
# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
  version: 2
  renderer: networkd
  ethernets:
    ens33:
      dhcp4: yes
  1. config 파일 수정
## network interface 확인
$ ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.***.***  netmask 255.255.254.0  broadcast 192.168.***.255
        inet6 fe80::20c:29ff:fe40:89e2  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:40:89:e2  txqueuelen 1000  (Ethernet)
        RX packets 2579  bytes 547149 (547.1 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 351  bytes 52073 (52.0 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
...

# ip a
...
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:0c:29:40:89:e2 brd ff:ff:ff:ff:ff:ff
    inet 192.168.***.***/23 brd 192.168.***.255 scope global dynamic ens33
       valid_lft 4960sec preferred_lft 4960sec
    inet6 fe80::20c:29ff:fe40:89e2/64 scope link
       valid_lft forever preferred_lft forever

## config 파일 수정
## 1.static 설정 방법
# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
  version: 2
  renderer: networkd
  ethernets:
    ens33:
      addresses:
        - 192.168.***.**/23
      gateway4: 192.168.***.1
      nameservers:
        addresses: [168.126.63.1]

## 2.dhcp 설정 방법
# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
  version: 2
  renderer: networkd
  ethernets:
    ens33:                    <- 네트워크 인터페이스 명
      dhcp4: yes

## config 수정 후 적용
$ netplan apply
728x90
반응형

'공부 > Ubuntu' 카테고리의 다른 글

ubuntu 설치 후 부팅 시 cloud-init message 발생  (0) 2023.02.13
Netplan bonding (active-backup)  (0) 2023.02.13
ubuntu 방화벽 관리  (0) 2023.02.07
ubuntu gui root 로그인 허용  (0) 2023.02.06
ubuntu gui package 설치  (0) 2023.02.06

댓글