nmcli를 사용하여 장치를 연결에 연결하는 방법은 무엇입니까?

nmcli를 사용하여 장치를 연결에 연결하는 방법은 무엇입니까?

CentOS 7 설치에는 2개의 연결과 3개의 장치가 있습니다. ens7내 장치를 연결에 어떻게 연결합니까 my-bridge? 내 장치를 어떻게 eth0연결에 연결할 수 있나요 my-eth1?

터미널의 관련 데이터는 다음과 같습니다.

[root@localhost ~]# nmcli con show
NAME       UUID          TYPE            DEVICE 
my-bridge  some.uuid     802-3-ethernet  --     
my-eth1    another.uuid  802-3-ethernet  --     

[root@localhost ~]# nmcli device status
DEVICE  TYPE      STATE         CONNECTION 
ens7    ethernet  disconnected  --         
eth0    ethernet  disconnected  --         
lo      loopback  unmanaged     --         
[root@localhost ~]# ping 8.8.8.8
connect: Network is unreachable

비슷한 것 같은데 nmcli connection modify id my-bridge ens7정확한 구문은 잘 모르겠습니다.

my-bridge또한 문제는 연결이 다음과 같은 방식으로 생성된다는 사실과 관련될 수 있습니다.

# nmcli con add con-name my-bridge ifname eth1 type ethernet ip4 10.1.1.2/24
# nmcli connection modify my-bridge ipv4.method manual ipv4.addresses 10.1.1.1/24

답변에는 장치를 연결에 연결하기 위해 터미널에 입력하는 정확한 구문 또는 처음부터 장치에 자동으로 연결되는 새 연결을 생성하는 구문이 표시됩니다.

답변1

짧은 대답은 다음과 같습니다.

# nmcli con modify my-bridge connection.interface-name ens7
# nmcli con up my-bridge

하지만 결코 그렇게 간단하지는 않습니다. 계속 읽어보세요…

장치에 연결하려면 세 가지가 필요합니다.

  1. 유효한 네트워크 장비
  2. connection.autoconnect설정할 속성은 다음과 같습니다.yes
  3. connection.interface-name속성은 인터페이스 이름으로 설정됩니다.

사용 가능한 NIC(가상 머신의 가상 네트워크 카드)가 있는지 확인하세요. 옵션이 많기 때문에 이는 이 답변의 범위를 벗어납니다.

귀하의 재산 상태를 확인하십시오 connection.autoconnect:

# nmcli con show my-bridge | grep connection.autoconnect:
connection.autoconnect:                  no

필요한 경우 이를 다음과 같이 변경할 수 있습니다.

# nmcli con modify my-bridge connection.autoconnect yes

상태 확인 connection.interface-name:

# nmcli con show my-bridge | grep connection.interface-name
connection.interface-name           --

필요한 경우 다음을 설정합니다.

# nmcli con modify my-bridge connection.interface-name ens7

답변2

가장 간단한 것은

nmcli device wifi connect <name ssid> password <the password>

확인하다이 bash 스크립트비밀번호를 변수로 사용하는 솔루션입니다.

스크립트는 비밀번호를 선택하고 숨기는 옵션을 제공합니다.

답변3

장치에 두 개의 Wi-Fi 어댑터가 있고 두 번째 어댑터를 사용하려는 경우 다음 명령을 실행해야 합니다. 내부 WiFi 안테나는 매우 기본적이지만 USB WiFi 어댑터는 매우 훌륭하기 때문에 이를 AWS DeepLens와 함께 사용합니다.

# Find the device name (such as wlan0) of your good adapter
ip a
ifconfig

# Ensure that NetworkManager sees the device
nmcli d

# Ensure that the device is detected as a Wifi adapter:
# NOTE: Replace "wlan0" with the name of your device
nmcli d show wlan0

# Ensure that the device can look around and do a scan of nearby networks:
nmcli d wifi list ifname wlan0

# Connect to the Wifi with the given password
# NOTE: Replace "MyHomeNetwork" with your Wifi network SSID
#       and replace "Sup3r-secret-password" with your password,
#       If your password contains any special characters, such as the $ below
#         I highly recommend surrounding it in single quotes, this is a shell thing,
#         not a nmcli thing.
nmcli d wifi connect MyHomeNetwork password 'Sup3r-$ecret-password' ifname wlan0

# Make sure it worked!
nmcli d
ip a
ifconfig

# PROFIT!

답변4

또한 이를 수행하기 위해 네트워크 연결 프로필을 특정 장치에 임시로 연결하려는 경우(예: USB WiFi 어댑터를 사용하여 무선 연결을 사용하려는 경우) 다음 nmcli과 같이 기본이 아닌 인터페이스를 사용할 수 있습니다.

nmcli con up MyNetwork ifname other-device

(일부 네트워크 관리자 프런트엔드를 통해 구성된 연결에서는 "이 MAC 주소에 대한 연결 제한"이 설정되어 있을 수 있으므로 기본적으로 작동하지 않을 수 있지만 쉽게 수정할 수 있습니다.)

관련 정보