메뉴 건너뛰기

록키리눅스 네트워크 설정, 즉 IP주소나 Hostname을 변경해보겠습니다.

 

CentOS 7까지는 /etc/sysconfig/network-script 아래에 있는 ifcfg-"이더넷명" 파일을 수정한 다음, network.service를 재시작해서 적용했는데, 록키 리눅스(Rocky Linux)에서는 NetworkManager를 사용해서 네트워크 설정을 적용합니다. GUI 환경에서는 nmtui, CUI 환경에서는 nmcli 로 설정합니다.

 

 

 

1. nmtui

 

화면 캡처 2023-02-01 095326.png

터미널에서 nmtui를 실행합니다.

 

 

 

화면 캡처 2023-02-01 095338.png

IP주소를 변경하기 위해서는 Edit a connection을 hostname을 변경하기 위해서는 Set system hostname으로 진입합니다.

 

 

 

화면 캡처 2023-02-01 095405.png

Ethernet 어뎁터 ens32를 선택하고 Edit로 들어갑니다.

 

 

 

화면 캡처 2023-02-01 095501.png

원하는 IP주소를 입력합니다.

 

 

 

화면 캡처 2023-02-01 100649.png

 

# systemctl restart NetworkManager

NetworkManager를 재시작하면, 변경된 IP주소 및 호스트네임이 적용됩니다.



 

 

 

 

2. nmcli

 

화면 캡처 2023-02-01 132507.png



nmcli는 위 # nmcli connection show 와 같이 리눅스 쉘에서 바로 명령어를 실행할 수도 있고,

아래와 같이 nmcli 모드에서 명령어를 실행할 수도 있습니다.

# nmcli connection edit ens32

nmcli> print ipv4

[root@Rocky91 ~]# nmcli connection edit ens32

 

===| nmcli interactive connection editor |===

 

Editing existing '802-3-ethernet' connection: 'ens32'

 

Type 'help' or '?' for available commands.

Type 'print' to show all the connection properties.

Type 'describe [<setting>.<prop>]' for detailed property description.

 

You may edit the following settings: connection, 802-3-ethernet (ethernet), 802-1x, dcb, sriov, ethtool, match, ipv4, ipv6, hostname, tc, proxy

nmcli> print ipv4

['ipv4' setting values]

ipv4.method: manual

ipv4.dns: 8.8.8.8

ipv4.dns-search: --

ipv4.dns-options: --

ipv4.dns-priority: 0

ipv4.addresses: 192.168.0.1/24

ipv4.gateway: 192.168.0.254

ipv4.routes: --

ipv4.route-metric: -1

ipv4.route-table: 0 (unspec)

ipv4.routing-rules: --

ipv4.ignore-auto-routes: no

ipv4.ignore-auto-dns: no

ipv4.dhcp-client-id: --

ipv4.dhcp-iaid: --

ipv4.dhcp-timeout: 0 (default)

ipv4.dhcp-send-hostname: yes

ipv4.dhcp-hostname: --

ipv4.dhcp-fqdn: --

ipv4.dhcp-hostname-flags: 0x0 (none)

ipv4.never-default: no

ipv4.may-fail: yes

ipv4.required-timeout: -1 (default)

ipv4.dad-timeout: -1 (default)

ipv4.dhcp-vendor-class-identifier: --

ipv4.link-local: 0 (default)

ipv4.dhcp-reject-servers: --



 

 

화면 캡처 2023-02-01 132547.png

nmcli> set ipv4.address "IP주소" --> 신규 IP 추가

nmcli> set ipv4.gateway "IP주소" --> 신규 gateway 추가

nmcli> set ipv4.dns "dns주소" --> 신규 DNS 추가

nmcli> save

Connection 'ens32' (b4f002ac-e143-3c02-a861-17f3e5) successfully updated.

nmcli> activate

 

위에 설정한 내용이 반영됩니다.



 

 

 

화면 캡처 2023-02-01 133356.png

화면 캡처 2023-02-01 134825.png

주의할 점은, 기존설정을 삭제하는 것이 아니고 신규설정을 추가하게 됩니다.

필요없는 네트워크 설정은 nmtui, nmcli 에서 삭제 후 activate 합니다.

[root@Rocky91 ~]# nmcli connection mod uuid "uuid" -ipv4.addresses "아이피"

nmcli 모드에서 activate 하거나,

nmcli> activate

리눅스쉘에서 # nmcli connection up ens32 를 하면 변경사항이 반영됩니다.



[root@Rocky91 ~]# nmcli connection show
NAME   UUID                                  TYPE      DEVICE
ens32  b4f002ac-e143-3c02-a861-17f3e0f41b85  ethernet  ens32
[root@Rocky91 ~]# nmcli connection edit ens32

===| nmcli interactive connection editor |===

Editing existing '802-3-ethernet' connection: 'ens32'

Type 'help' or '?' for available commands.
Type 'print' to show all the connection properties.
Type 'describe [<setting>.<prop>]' for detailed property description.

You may edit the following settings: connection, 802-3-ethernet (ethernet), 802-1x, dcb, sriov, ethtool, match, ipv4, ipv6, hostname, tc, proxy
nmcli> print ipv4
['ipv4' setting values]
ipv4.method:                            manual
ipv4.dns:                               210.101.225.1
ipv4.dns-search:                        --
ipv4.dns-options:                       --
ipv4.dns-priority:                      0
ipv4.addresses:                         210.101.228.142/25
ipv4.gateway:                           210.101.228.129
ipv4.routes:                            --
ipv4.route-metric:                      -1
ipv4.route-table:                       0 (unspec)
ipv4.routing-rules:                     --
ipv4.ignore-auto-routes:                no
ipv4.ignore-auto-dns:                   no
ipv4.dhcp-client-id:                    --
ipv4.dhcp-iaid:                         --
ipv4.dhcp-timeout:                      0 (default)
ipv4.dhcp-send-hostname:                yes
ipv4.dhcp-hostname:                     --
ipv4.dhcp-fqdn:                         --
ipv4.dhcp-hostname-flags:               0x0 (none)
ipv4.never-default:                     no
ipv4.may-fail:                          yes
ipv4.required-timeout:                  -1 (default)
ipv4.dad-timeout:                       -1 (default)
ipv4.dhcp-vendor-class-identifier:      --
ipv4.link-local:                        0 (default)
ipv4.dhcp-reject-servers:               --

 

 

참고: 록키리눅스 네트워크 설정하기

번호 제목 글쓴이 날짜 조회 수
34 git, github 사용하기. vscode에서 github 연동하기(2023.02.09) file 관리자 2023.02.08 1298
» 록키리눅스(Rocky Linux) 네트워크 설정하기 - nmcli, nmtui file 관리자 2023.02.01 35627
32 CentOS 종료 대비, 록키 리눅스(Rocky Linux) 설치하기 file 관리자 2023.01.27 1360
31 플래시 설치파일 file 관리자 2021.01.13 356
30 tar 압축하면서 다른 디렉토리에 풀기 file 관리자 2020.11.14 475
29 리눅스 하드디스크 추가 관리자 2019.02.12 1430
28 [MySQL]ERROR 1819 (HY000): Your password does not satisfy the current policy requirements 관리자 2018.12.23 1295
27 [리눅스]phpinfo() 실행 시 하얀 화면이 나타날 경우 대처방법 file 관리자 2018.12.13 3703
26 [리눅스]rsync 설정 후, crontab 스케줄 등록 관리자 2018.08.28 2740
25 [리눅스][XE]백업복구(서버이관) 시 오류-03.사이트 메뉴 편집, 사이트 디자인 설정 출력 안되는 현상 file 관리자 2018.08.27 11124
24 [리눅스][XE]백업복구(서버이관) 시 오류-02.아파치 rewrite에러 file 관리자 2018.08.27 516
23 [리눅스][XE]백업복구(서버이관) 시 오류-01.No matching DirectoryIndex (index.html) fonud 오류 file 관리자 2018.08.27 1461
22 [리눅스][XE][오류]msg_is_not_administrator file 관리자 2018.08.08 1242
21 [리눅스]CentOS에서 하드디스크 추가 관리자 2018.03.21 8843
20 [리눅스]리눅스 파일 압축 암호 설정 및 해제(ZIP) 관리자 2017.07.30 18083
19 [리눅스]CentOS 7,최신 APM 소스설치-5) PHP, gd library jpeg support file 관리자 2017.02.21 1853
18 [리눅스]CentOS 7 root password 분실 file 관리자 2016.12.27 6353
17 [리눅스]vsftpd ftp 파일전송오류(451 Failure writing to local file) 관리자 2016.12.20 4117
16 [리눅스]APM(apache+php+mysql) 다른서버로 이관하기(백업-복구하기) 관리자 2016.09.12 4673
15 [리눅스]XE(XpressEngine)설정 file 관리자 2016.07.26 684