NetworkManager/nmcli를 사용하여 보조 IP 제거

NetworkManager/nmcli를 사용하여 보조 IP 제거

nmcli를 사용하여 Ubuntu 16.04 서버에 고정 IP를 할당하려고 시도했지만 작동했지만 여전히 원래 IP를 "보조" IP로 유지합니다. 나는 그것을 제거하는 방법을 모른다. 10.163.148.36은 서버의 원래 IP이고 10.163.148.194는 전환하려는 새 IP입니다. 다음 nmcli 명령을 사용하여 IP 주소를 설정합니다.

nmcli connection modify 'Wired connection 1' ipv4.addresses '10.163.148.194/24' ipv4.gateway '10.163.148.2' ipv4.method 'manual' ipv4.ignore-auto-dns 'yes' connection.autoconnect 'yes' ipv4.dns '10.10.10.10 10.20.10.10'

ens160 인터페이스의 두 IP 주소를 기록해 두십시오.

aruba@ubuntu:~$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 00:50:56:8a:10:64 brd ff:ff:ff:ff:ff:ff
    inet 10.163.148.194/24 brd 10.163.148.255 scope global ens160
       valid_lft forever preferred_lft forever
    inet 10.163.148.36/24 brd 10.163.148.255 scope global secondary ens160
       valid_lft forever preferred_lft forever
    inet6 2006::b0a3:b9ab:2f96:a461/64 scope global temporary dynamic
       valid_lft 604254sec preferred_lft 85254sec
    inet6 2006::dc94:ead6:e8ef:8095/64 scope global mngtmpaddr noprefixroute dynamic
       valid_lft 2591987sec preferred_lft 604787sec
    inet6 fe80::941e:5fa3:3571:df76/64 scope link
       valid_lft forever preferred_lft forever

내 nmcli 연결 세부 정보:

aruba@ubuntu:~$ nmcli connection show "Wired connection 1"
connection.id:                          Wired connection 1
connection.uuid:                        d724141e-4c7f-3fc9-97b1-c37e014aebe4
connection.interface-name:              --
connection.type:                        802-3-ethernet
connection.autoconnect:                 yes
connection.autoconnect-priority:        -999
connection.timestamp:                   1481582261
connection.read-only:                   no
connection.permissions:
connection.zone:                        --
connection.master:                      --
connection.slave-type:                  --
connection.autoconnect-slaves:          -1 (default)
connection.secondaries:
connection.gateway-ping-timeout:        0
connection.metered:                     unknown
connection.lldp:                        -1 (default)
802-3-ethernet.port:                    --
802-3-ethernet.speed:                   0
802-3-ethernet.duplex:                  --
802-3-ethernet.auto-negotiate:          yes
802-3-ethernet.mac-address:             00:50:56:8A:10:64
802-3-ethernet.cloned-mac-address:      --
802-3-ethernet.mac-address-blacklist:
802-3-ethernet.mtu:                     auto
802-3-ethernet.s390-subchannels:
802-3-ethernet.s390-nettype:            --
802-3-ethernet.s390-options:
802-3-ethernet.wake-on-lan:             1 (default)
802-3-ethernet.wake-on-lan-password:    --
ipv4.method:                            manual
ipv4.dns:                               10.1.10.10,10.2.10.10
ipv4.dns-search:
ipv4.dns-options:                       (default)
ipv4.addresses:                         10.163.148.194/24
ipv4.gateway:                           10.163.148.1
ipv4.routes:
ipv4.route-metric:                      -1
ipv4.ignore-auto-routes:                no
ipv4.ignore-auto-dns:                   no
ipv4.dhcp-client-id:                    --
ipv4.dhcp-timeout:                      0
ipv4.dhcp-send-hostname:                yes
ipv4.dhcp-hostname:                     --
ipv4.dhcp-fqdn:                         --
ipv4.never-default:                     no
ipv4.may-fail:                          yes
ipv4.dad-timeout:                       -1 (default)
ipv6.method:                            auto
ipv6.dns:
ipv6.dns-search:
ipv6.dns-options:                       (default)
ipv6.addresses:
ipv6.gateway:                           --
ipv6.routes:
ipv6.route-metric:                      -1
ipv6.ignore-auto-routes:                no
ipv6.ignore-auto-dns:                   no
ipv6.never-default:                     no
ipv6.may-fail:                          yes
ipv6.ip6-privacy:                       -1 (unknown)
ipv6.addr-gen-mode:                     stable-privacy
ipv6.dhcp-send-hostname:                yes
ipv6.dhcp-hostname:                     --
GENERAL.NAME:                           Wired connection 1
GENERAL.UUID:                           d724141e-4c7f-3fc9-97b1-c37e014aebe4
GENERAL.DEVICES:                        ens160
GENERAL.STATE:                          activated
GENERAL.DEFAULT:                        yes
GENERAL.DEFAULT6:                       yes
GENERAL.VPN:                            no
GENERAL.ZONE:                           --
GENERAL.DBUS-PATH:                      /org/freedesktop/NetworkManager/ActiveConnection/0
GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/Settings/0
GENERAL.SPEC-OBJECT:                    /
GENERAL.MASTER-PATH:                    --
IP4.ADDRESS[1]:                         10.163.148.194/24
IP4.ADDRESS[2]:                         10.163.148.36/24
IP4.GATEWAY:                            10.163.148.2
IP4.DNS[1]:                             10.10.10.10
IP4.DNS[2]:                             10.20.10.10
IP6.ADDRESS[1]:                         2006::b0a3:b9ab:2f96:a461/64
IP6.ADDRESS[2]:                         2006::dc94:ead6:e8ef:8095/64
IP6.ADDRESS[3]:                         fe80::941e:5fa3:3571:df76/64
IP6.GATEWAY:                            fe80::213:1aff:fec7:f857

마지막으로 내 NetworkManager 구성은 다음과 같습니다.

aruba@ubuntu:~$ cat /etc/NetworkManager/NetworkManager.conf
[main]
plugins=keyfile,ofono
dns=dnsmasq

[ifupdown]
managed=true

답변1

"Red Hat"에서 구문은 다음과 같습니다.

nmcli con mod "Wired connection 1" -ipv4.addresses "10.163.148.194"

속성 앞에 빼기 기호를 추가하면 됩니다.

우분투에서도 이렇게 작동할 수 있을까요...?

답변2

나는 같은 상황에 직면했고 다음과 같이 "ip addr del" 명령을 사용하여 이전 IP를 삭제하는 것 외에는 다른 해결책을 찾지 못했습니다.

ip addr del 10.163.148.36/24 dev ens160

답변3

이것이 Fedora 29에서 저에게 효과적이었던 것입니다(RHEL/CentOS에서는 잘 작동할 수도 있습니다).

nmcli con mod ens192 ipv4.addresses "" ipv4.gateway ""

그런 다음 인터페이스를 팝업하여 변경 사항을 적용하세요.

nmcli con down ens192; nmcli con up ens192

답변4

Fedora 설치에서 다음 명령을 사용하여 제거했습니다.

nmcli con mod end192 ipv4.method manual

이렇게 하면 DHCP 연결이 중지되고 구성된 정적 IPv4 주소만 할당됩니다.

관련 정보