Wisdom’s Cloud

[Linux] [CentOS] NetworkManager 본문

LINUX/Advanced

[Linux] [CentOS] NetworkManager

지혜로운지혜쓰 2022. 9. 2. 14:03

네트워크 설정을 하다가 NetworkManager의 동작 여부에 따른 차이가 발생해서 NetworkManager에 대해 알아보게 되었다.

 

 

 

먼저 NetworkManager는 동적으로 네트워크의 변경 사항을 탐지하고 설정해 주는 데몬이다.

다시 말해, NetowrkManager가 동작하고 있으면 지속적으로 link가 plug 또는 unplug 됐는지를 체크하여 up/down으로 알려준다.

 

 

네트워크 인터페이스를 확인하고 설정하는 명령어들은 아래와 같다.

하지만 각 명령어마다 인터페이스를 down 시키는 것에 차이가 있으니 혼동하지 말아야 한다.

ifconfig 명령어와 ip 명령어는 해당 인터페이스 자체를 down 시키는 것이고, 실제 link의 상태는 ethtool 명령어를 통해 확인해야 하며, ifdown 명령어는 해당 인터페이스의 ip를 down 시키는 것이다.

그리고 이 명령어들로 설정한 내용들은 재부팅 후 초기화되기 때문에 영구적으로 설정하기 원한다면 /etc/sysconfig/network-scripts/ifcfg-ethXX 파일에 설정해야 한다.

[root@test-node-1 ~]# ifconfig
eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 9000
        inet 10.10.10.20  netmask 255.255.255.0  broadcast 10.10.10.255
        inet6 fe80::5054:ff:fe36:6f09  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:36:6f:09  txqueuelen 1000  (Ethernet)
        RX packets 378  bytes 19896 (19.4 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 10  bytes 712 (712.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        
[root@test-node-1 ~]# ifconfig eth1 down

[root@test-node-1 ~]# ifconfig
eth1: flags=4098<BROADCAST,MULTICAST>  mtu 9000
        inet 10.10.10.20  netmask 255.255.255.0  broadcast 10.10.10.255
        ether 52:54:00:36:6f:09  txqueuelen 1000  (Ethernet)
        RX packets 386  bytes 20312 (19.8 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 10  bytes 712 (712.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions
[root@test-node-1 ~]# ip addr
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9000 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 52:54:00:36:6f:09 brd ff:ff:ff:ff:ff:ff
    inet 10.10.10.20/24 brd 10.10.10.255 scope global noprefixroute eth1
       valid_lft forever preferred_lft forever
    inet6 fe80::5054:ff:fe36:6f09/64 scope link
       valid_lft forever preferred_lft forever

[root@test-node-1 ~]# ip link set eth1 down

[root@test-node-1 ~]# ip addr
3: eth1: <BROADCAST,MULTICAST> mtu 9000 qdisc pfifo_fast state DOWN group default qlen 1000
    link/ether 52:54:00:36:6f:09 brd ff:ff:ff:ff:ff:ff
    inet 10.10.10.20/24 brd 10.10.10.255 scope global noprefixroute eth1
       valid_lft forever preferred_lft forever
[root@test-node-1 ~]# ifconfig
eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 9000
        inet 10.10.10.20  netmask 255.255.255.0  broadcast 10.10.10.255
        inet6 fe80::5054:ff:fe36:6f09  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:36:6f:09  txqueuelen 1000  (Ethernet)
        RX packets 613  bytes 32116 (31.3 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 32  bytes 2276 (2.2 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 

[root@test-node-1 ~]# ifdown eth1
Device 'eth1' successfully disconnected

[root@test-node-1 ~]# ifconfig
eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether 52:54:00:36:6f:09  txqueuelen 1000  (Ethernet)
        RX packets 638  bytes 33416 (32.6 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 32  bytes 2276 (2.2 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions

 

 

그럼 이제 NetworkManager의 동작 유무의 따른 차이를 알아보자.

먼저 ONBOOT 옵션이 yes인 경우를 보자.

부팅 시 Network 데몬이 network-scripts를 가져오는데, ONBOOT 옵션이 yes이면 이 network-scripts를 기반으로 해당 인터페이스의 IP를 설정하겠다는 의미이다.

network-scripts를 통해 IP가 설정되었기 때문에 NetworkManager가 동작하든 안하든 link 상태를 체크하기 때문에 link가 up 상태인 것을 확인할 수 있다.

[root@test-node-1 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
ONBOOT=yes
BOOTPROTO=none
IPADDR=10.10.10.20
PREFIX=24
MTU=9000

#################### NetworkManager is running ####################
[root@test-node-1 ~]# ip addr
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9000 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 52:54:00:36:6f:09 brd ff:ff:ff:ff:ff:ff
    inet 10.10.10.20/24 brd 10.10.10.255 scope global noprefixroute eth1
       valid_lft forever preferred_lft forever
    inet6 fe80::5054:ff:fe36:6f09/64 scope link
       valid_lft forever preferred_lft foreve
[root@test-node-1 ~]# ethtool eth1
Settings for eth1:
        Link detected: yes
        
#################### NetworkManager is dead ####################
[root@test-node-1 ~]# ip addr
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9000 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 52:54:00:36:6f:09 brd ff:ff:ff:ff:ff:ff
    inet 10.10.10.20/24 brd 10.10.10.255 scope global eth1
       valid_lft forever preferred_lft forever
    inet6 fe80::5054:ff:fe36:6f09/64 scope link
       valid_lft forever preferred_lft forever
[root@test-node-1 ~]# ethtool eth1
Settings for eth1:
        Link detected: yes

 

 

다음으로 ONBOOT 옵션이 no인 경우를 보자.

일단 network-scripts를 가져오지 않았기 때문에 IP가 설정되지 않았다.

따라서 NetworkManager가 동작하지 않으면 link의 상태를 확인하지 않기 때문에 link가 down 되었지만, 실제로 down 되었는지는 알 수 없다.

반면 NetworkManager가 동작하고 있으면  지속적으로 link의 상태를 확인하며, 현재 테스트 환경은 가상 서버이므로 논리적으로 연결되었기 때문에 link의 상태가 up인 것을 볼 수 있다.

[root@test-node-1 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
ONBOOT=no
BOOTPROTO=none
IPADDR=10.10.10.20
PREFIX=24
MTU=9000

#################### NetworkManager is running ####################
[root@test-node-1 ~]# ip addr
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9000 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 52:54:00:36:6f:09 brd ff:ff:ff:ff:ff:ff
[root@test-node-1 ~]# ethtool eth1
Settings for eth1:
        Link detected: yes
        
#################### NetworkManager is dead ####################
[root@test-node-1 ~]# ip addr
3: eth1: <BROADCAST,MULTICAST> mtu 9000 qdisc pfifo_fast state DOWN group default qlen 1000
    link/ether 52:54:00:36:6f:09 brd ff:ff:ff:ff:ff:ff
[root@test-node-1 ~]# ethtool eth1
Settings for eth1:
        Link detected: no

 

 

아무튼 NetworkManager와 Network의 차이에 대해서 알아봤는데, 결론적으로는 네트워크 설정이 자주 변경될 일이 없는 환경에서는 NetworkManager가 있으면 자동으로 설정이 변경되어 문제를 야기할 수 있기 때문에 데몬을 중지시키는 것이 좋을 것 같다. 😃

 

 

 

[참고 문서]

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/networking_guide/getting_started_with_networkmanager

 

Chapter 2. Getting Started with NetworkManager Red Hat Enterprise Linux 7 | Red Hat Customer Portal

Access Red Hat’s knowledge, guidance, and support through your subscription.

access.redhat.com

https://access.redhat.com/solutions/783533

 

What's the difference between Network Initscript and NetworkManager in RHEL 7? - Red Hat Customer Portal

RHEL 7 now has increased support for NetworkManager, so which should I use? Is Network Initscript going away now that NetworkManager is on the rise? When is Network Initscript functionality preferred? When is NetworkManager preferred?

access.redhat.com