CentOS Stream 9은 CentOS 7, 8의 설정위치(/etc/sysconfig/network-scripts)와 다르다.

 

1. 설정파일 위치로 이동

/etc/NetworkManager/system-connections/아래에 

인터페이스의 고유명.nmconnection파일의 내용을 수정한다.

[root@localhost system-connections]# pwd
/etc/NetworkManager/system-connections
[root@localhost system-connections]# ls
ens33.nmconnection
[root@localhost system-connections]# vi ens33.nmconnection

 

2. 파일수정

[connection]
id=ens33
uuid=2b539e23-1c0b-329f-badb-b916fb7d9ccd
type=ethernet
autoconnect-priority=-999
interface-name=ens33
timestamp=1742654524

[ethernet]

[ipv4]
# method=auto
# 이하 직접 추가
address1=192.168.209.130/24
dns=192.168.209.2;
gateway=192.168.209.2
method=manual

[ipv6]
addr-gen-mode=eui64
method=auto

[proxy]

 

3. 네트워크 서비스 재시작

[root@localhost system-connections]# systemctl restart NetworkManager

 

4. 다른방법 nmcli 명령으로 수정하기

[root@localhost system-connections]# nmcli connection modify ens33 ipv4.method manual

[root@localhost system-connections]# nmcli connection modify ens33 ipv4.addresses 192.168.209.130/24

[root@localhost system-connections]# nmcli connection modify ens33 ipv4.gateway 192.168.209.2

[root@localhost system-connections]# nmcli connection modify ens33 ipv4.dns 192.168.209.2

[root@localhost system-connections]# nmcli connection down ens33 
Connection 'ens33' successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/2)

[root@localhost system-connections]# nmcli connection up ens33 
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/3)

[root@localhost system-connections]# systemctl restart NetworkManager

[root@localhost system-connections]# nmcli device show ens33 
GENERAL.DEVICE:                         ens33
GENERAL.TYPE:                           ethernet
GENERAL.HWADDR:                         00:0C:29:8D:74:78
GENERAL.MTU:                            1500
GENERAL.STATE:                          100 (connected)
GENERAL.CONNECTION:                     ens33
GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveConnection/2
WIRED-PROPERTIES.CARRIER:               on
IP4.ADDRESS[1]:                         192.168.209.130/24
IP4.GATEWAY:                            192.168.209.2
IP4.ROUTE[1]:                           dst = 192.168.209.0/24, nh = 0.0.0.0, mt = 100
IP4.ROUTE[2]:                           dst = 0.0.0.0/0, nh = 192.168.209.2, mt = 100
IP4.DNS[1]:                             192.168.209.2
IP6.ADDRESS[1]:                         fe80::20c:29ff:fe8d:7478/64
IP6.GATEWAY:                            --
IP6.ROUTE[1]:                           dst = fe80::/64, nh = ::, mt = 1024

[root@localhost system-connections]# 

 

4. 호스트명 영구 설정

[root@localhost etc]# hostnamectl set-hostname centos9.daonelab.com
[root@localhost etc]# hostname
centos9.daonelab.com