如何设置网络管理器服务来自动配置调制解调器连接?

How to set up a network-manager service to configure a modem connection automatically?

我尝试在 Ubuntu 18.04 上连接 USB Huawei E8372 调制解调器。 dmesg命令给出一个信息:

[  371.616615] cdc_ether 1-6:1.0 eth0: register 'cdc_ether' at usb-0000:00:14.0-6, CDC Ethernet Device, 0c:5b:8f:27:9a:64
[  371.616948] usb-storage 1-6:1.2: USB Mass Storage device detected
[  371.617603] scsi host4: usb-storage 1-6:1.2
[  371.625478] cdc_ether 1-6:1.0 enx0c5b8f279a64: renamed from eth0
[  372.636698] scsi 4:0:0:0: Direct-Access     HUAWEI   TF CARD Storage  2.31 PQ: 0 ANSI: 2
[  372.637021] sd 4:0:0:0: Attached scsi generic sg2 type 0
[  372.637270] sd 4:0:0:0: Power-on or device reset occurred
[  372.637965] sd 4:0:0:0: [sdc] Attached SCSI removable disk
[  372.856712] usbcore: registered new interface driver usbserial_generic
[  372.856727] usbserial: USB Serial support registered for generic
[  372.860310] usbcore: registered new interface driver option
[  372.860325] usbserial: USB Serial support registered for GSM modem (1-port)

所以我有 enx0c5b8f279a64 界面。网络管理器服务添加此设备(来自 service network-manager status 的日志):

[1561201979.1919] devices added (path: /sys/devices/pci0000:00/0000:00:14.0/usb1/1-6/1-6:1.0/net/enx0c5b8f279a64, iface: enx0c5b8f279a64)
[1561201979.1919] device added (path: /sys/devices/pci0000:00/0000:00:14.0/usb1/1-6/1-6:1.0/net/enx0c5b8f279a64, iface: enx0c5b8f279a64)

但是我不能上网。而且,ifconfig不显示这个界面。

我可以使用 dhclient: dhclient -v enx0c5b8f279a64:

Listening on LPF/enx0c5b8f279a64/0c:5b:8f:27:9a:64
Sending on   LPF/enx0c5b8f279a64/0c:5b:8f:27:9a:64
Sending on   Socket/fallback
DHCPREQUEST of 192.168.8.100 on enx0c5b8f279a64 to 255.255.255.255 port 67 (xid=0x36f4d377)
DHCPNAK from 192.168.8.1 (xid=0x77d3f436)
DHCPDISCOVER on enx0c5b8f279a64 to 255.255.255.255 port 67 interval 3 (xid=0x5ad85374)
DHCPDISCOVER on enx0c5b8f279a64 to 255.255.255.255 port 67 interval 7 (xid=0x5ad85374)
DHCPREQUEST of 192.168.8.100 on enx0c5b8f279a64 to 255.255.255.255 port 67 (xid=0x7453d85a)
DHCPOFFER of 192.168.8.100 from 192.168.8.1
DHCPACK of 192.168.8.100 from 192.168.8.1
bound to 192.168.8.100 -- renewal in 41121 seconds.

之后上网,network-manager日志:

[1561202049.0339] device (enx0c5b8f279a64): carrier: link connected
[1561202049.0415] device (enx0c5b8f279a64): carrier: link connected

我希望网络管理器服务自动设置调制解调器的接口,而不需要像 运行 dhclient 这样的任何手动步骤。怎么做?

谢谢。

在 ubuntu 中使用 18.04 netplan,只需为您的接口编写 enx0c5b8f279a64:"dhcp: true"”(参见此处示例:https://netplan.io/examples