본문 바로가기

Linux & Unix

Ubuntu Server 18.04 - 네트워크 설정

Ubuntu Server 18.04 네트워크 설정

1. Online Config
1) iproute 패키지의 ip 명령어 이용

- 아래 명령을 사용해 interface 확인
# ip a
# lshw -class network
# ethtool enp3s0

# ip address add IP주소 dev 인터페이스명
# ip addr add 10.102.66.200/24 dev enp3s0
# ip link set dev enp3s0 up
# ip address show dev enp3s0
# ip route add default via 10.102.66.1
# ip route show

추가 명령어
# ip addr del 10.102.66.200/24 dev enp3s0
# ip link set dev enp3s0 down
# ip flush enp3s0

2) nameserver 설정

# systemd-resolve --status
# systemd-resolve
# systemd-resolved


2. Persistent Config

- network renderer 는 2가지
               NetworkManager
               networkd (Systemd-networkd) // 이거 사용

- YAML config 파일에 설정
- 파일 위치
              /{lib,etc,run}/netplan/*.yaml
              /{lib,etc,run}/netplan/\*.yaml

- 내용 예시
vim /etc/netplan/99_config.yaml

network:
  version:2
    ethernets:
      eth7:
        dhcp4: true

network:
  version: 2
  renderer: networkd
  bonds:
    bond0:
      interfaces:
        - enp3s0
        - enp4s0
      parameters:
        mode: active-backup
        mii-monitor-interval: 1
        primary: enp3s0
      addresses:
        - 10.0.0.10/24
      gateway4: 10.0.0.1
      nameservers:
        addresses:
          - 8.8.8.8
          - 8.8.4.4

network:
  version: 2
  rederer: networkd
  ethernets:
    bond0:
      addresses:
        - 10.0.0.10/24
      gateway4: 10.0.0.1
      nameservers:
        search: [local]
        addresses:
          - 8.8.8.8
          - 8.8.4.4


3.설정파일에서 IP 적용시키기

# netplan apply

- netplan 명령
netplan generate            //runs during early boot and will read config, and write files
netplan apply                  //Kicks the various backends to realize network config
netplan list
netplan update
netplan config set          //capture existing config on an interface into the the equivalent YAML
netplan config show       //Merge and display all the current available configuration on the system


4. go back to ifupdown (이전 버전용)
1) On a running system,
netplan can be removed by installing ifupdown and configuring /etc/network/interfaces manually as users have done before.

2) At install time
netcfg/do_not_use_netplan=true
boot menu > F6 > e(edit) > 위 부분 추가


5. Debugging
1)
/run/systemd/network/10-netplan- 파일 : netplan YAML 의 설정이 여기에 들어감

2) 아래 파일을 조사
*.network
*.netdev
*.link
manpage (systemd.network, systemd.netdev, systemd,link)