Red Hat Training

A Red Hat training course is available for Red Hat Enterprise Linux

3.3.7. nmcli를 사용하여 동적 이더넷 연결 추가 및 구성

동적 이더넷 연결 추가

동적 IP 구성을 사용하여 이더넷 구성 프로필을 추가하려면 DHCP 에서 네트워크 구성을 할당할 수 있습니다.
nmcli connection add type ethernet con-name connection-name ifname interface-name
예를 들어 my-office 라는 동적 연결 프로필을 생성하려면 다음을 수행합니다.
~]$ nmcli con add type ethernet con-name my-office ifname ens3
Connection 'my-office' (fb157a65-ad32-47ed-858c-102a48e064a2) successfully added.
이더넷 연결을 열려면 다음을 수행합니다.
~]$ nmcli con up my-office
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/5)
장치 및 연결의 상태를 검토합니다.
~]$ nmcli device status
DEVICE  TYPE      STATE         CONNECTION
ens3    ethernet  connected     my-office
ens9    ethernet  disconnected  --
lo      loopback  unmanaged     --

동적 이더넷 연결 구성

호스트에서 DHCP 서버로 보낸 호스트 이름을 변경하려면 dhcp-hostname 속성을 수정합니다.
~]$ nmcli con modify my-office my-office ipv4.dhcp-hostname host-name ipv6.dhcp-hostname host-name
호스트에서 DHCP 서버로 보낸 IPv4 클라이언트 ID를 변경하려면 dhcp-client-id 속성을 수정합니다.
~]$ nmcli con modify my-office my-office ipv4.dhcp-client-id client-ID-string
IPv6 에 대한 dhcp-client-id 속성이 없으며dhclientIPv6 의 식별자를 만듭니다. 자세한 내용은 dhclient(8) 도움말 페이지를 참조하십시오.
DHCP 서버에서 호스트로 전송된 DNS 서버를 무시하려면 ignore-auto-dns 특성을 수정합니다.
~]$ nmcli con modify my-office my-office ipv4.ignore-auto-dns yes ipv6.ignore-auto-dns yes
속성 및 설정에 대한 자세한 내용은 nm-settings(5) 도움말 페이지를 참조하십시오.

예 3.9. 대화형 편집기를 사용하여 동적 이더넷 연결 구성

대화형 편집기를 사용하여 동적 이더넷 연결을 구성하려면 다음을 수행합니다.
~]$ nmcli con edit type ethernet con-name ens3

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

Adding a new '802-3-ethernet' connection

Type 'help' or '?' for available commands.
Type 'describe [<setting>.<prop>]' for detailed property description.

You may edit the following settings: connection, 802-3-ethernet (ethernet), 802-1x, ipv4, ipv6, dcb
nmcli> describe ipv4.method

=== [method] ===
[NM property description]
IPv4 configuration method.  If 'auto' is specified then the appropriate automatic method (DHCP, PPP, etc) is used for the interface and most other properties can be left unset.  If 'link-local' is specified, then a link-local address in the 169.254/16 range will be assigned to the interface.  If 'manual' is specified, static IP addressing is used and at least one IP address must be given in the 'addresses' property.  If 'shared' is specified (indicating that this connection will provide network access to other computers) then the interface is assigned an address in the 10.42.x.1/24 range and a DHCP and forwarding DNS server are started, and the interface is NAT-ed to the current default network connection.  'disabled' means IPv4 will not be used on this connection.  This property must be set.

nmcli> set ipv4.method auto
nmcli> save
Saving the connection with 'autoconnect=yes'. That might result in an immediate activation of the connection.
Do you still want to save? [yes] yes
Connection 'ens3' (090b61f7-540f-4dd6-bf1f-a905831fc287) successfully saved.
nmcli> quit
~]$
기본 조치는 연결 프로필을 영구적으로 저장하는 것입니다. 필요한 경우 save 임시 명령을 사용하여 다음에 다시 시작할 때까지 메모리에만 프로필을 저장할 수 있습니다.