OS/Install & Modify

[Rocky Linux] nmcli 명령어

PeamS 2026. 2. 10. 15:55

Intro

Rocky 8 부터는 ifcfg 말고 nmcli 로 네트워크 관리할 수 있도록 변경됐습니다.

cat /etc/sysconfig/network-scripts/readme-ifcfg-rh.txt 로 확인 가능

 

cisco cli 처럼 명령어 단축이 가능합니다. (connection -> con, modify -> mo)

 

예시 설명
connection.id eth0 별칭, 별명
connection.interface-name eth0 물리 이더넷 이름(ens, eth,enp...)
ipv4.address 192.168.0.1/24 IPv4 주소 / Prefix
ipv4.gateway 192.168.0.254 IPv4 게이트웨이
ipv4.method manual manual(static), auto(dhcp) 로 보면 편합니다.

 

명령어

nmcli connection edit

  • set : 값 설정 (예 : set ipv4.address 192.168.0.1/24
  • remove : 값 제거 (예 : remove ipv4.address 192.168.0.1/24)
  • print : 설정 상태 보기 (예 : print ipv4)
  • save : 설정 저장
  • activate : 설정 반영 (nmcli connection up 과 비슷합니다. 바로 설정 값이 올라 옵니다)

nmcli connection up

 

 

예제

bond 이중화 구축

2개 이상의 포트를 묶을 때 사용하며 옵션은 다음과 같습니다.

옵션 기본값 내용
mode - active-backup
primary - 메인 인터페이스 지정
(DEVICE 이름으로 넣어야 함)
num_grat_arp 1 장애 발생 시 Gratuitous ARP 전송 횟수
primary_reselect 0 0 : 즉각 복구
1 : 속도나 듀플렉스 보고 복구
2 : 수동 복구. 인터페이스가 복구돼도 Currently Active Slave 가 바뀌진 않음.

 

2개 포트 active-standby 만들기

bond0 인터페이스 생성하기

nmcli con add type bond con-name bond0 ifname bond0 bond.options "mode=active-backup,miimon=100,primary_reselect=2"

 

eth0, eth1 를 bond0-active, bond0-backup 이름으로 bond0 에 추가하기

nmcli con add type ethernet slave-type bond con-name bond0-active ifname eth0 master bond0
nmcli con add type ethernet slave-type bond con-name bond0-backup ifname eth1 master bond0

 

bond0 에 대해 IP 설정 진행

nmcli con mo bond0 connection.autoconnect yes
nmcli con mo bond0 ipv4.address 192.168.0.11/24
nmcli con mo bond0 ipv4.gateway 192.168.0.1
nmcli con mo bond0 ipv4.method manual

 

설정 반영하기

nmcli con up bond0-active
nmcli con up bond0-backup
nmcli con up bond0

 

eth0 이름으로 된 컨넥션은 비활성화되고 bond0-active 로 올라온다. (eth0 device 가 쓰는 컨넥션이 eth0 -> bond0-active 로 바뀜)
bond0-active 컨넥션이 지워진다면 비활성화 된 eth0 컨넥션이 다시 올라온다. (/etc/NetworkManager/system-connections 확인)

 

messages 로그

test01 kernel: bond0: (slave enp1s0): link status definitely up, 0 Mbps full duplex
test01 kernel: bond0: (slave enp1s0): making interface the new active one
test01 kernel: bond0: (slave enp7s0): link status definitely down, disabling slave

 

트러블슈팅

(Rocky8) nmcli connection up 시 No suitable device found for this connection

에러내용

'eth1'(UUID) 연결 활성화 실패: No suitable device found for this connection (device eth0 not available because profile is not compatible with device (mismatching interface name)).

 

원인 및 해결

eth1 에 물리적인 연결이 없을 경우 eth1 connection up 이 되지 않습니다.

물리적인 연결 후 재시도