如何在 netplan 中配置我的网络接口以便 ppp 可以使用它?

如何在 netplan 中配置我的网络接口以便 ppp 可以使用它?

我有一台新机器,我正在使用 18.04 服务器版本将其设置为我的 LAN 路由器,为我的 LAN 提供 DHCP 和绑定服务、防火墙、NAT、互联网访问等。

它有 2 个以太网网卡,其中一个连接到我的 Draytek ADSL 调制解调器,需要ppp

我已经安装了我认为需要的所有内容,但由于ppp无法建立互联网连接,我的配置显然是错误的。

根据这个答案如何使用 netplan 配置 PPPoE?这应该相对容易,但答案省略了我所追求的关键信息,即在 yaml 中放什么netplan- 或者我遗漏的其他内容。

可能我自己也遇到了这个问题,因为我安装xubuntu-core了最小的桌面/窗口管理器 GUI,以便在工作时轻松上网。我担心它会引起这个问题network-manager,尽管我不确定。

这是我的 netplan yaml:

adam@gondolin:~$ cat /etc/netplan/01-netcfg.yaml 
# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
  version: 2
  renderer: networkd
  ethernets:
    enp5s0:
      dhcp4: yes
    enp0s31f6:
      dhcp4: no
      dhcp6: no
adam@gondolin:~$ 

我已将enp5s0接口设置为使用 DHCP,以便在我准备此服务器时可以进入 LAN 并访问互联网,尽管当它准备就绪时,该接口将是具有固定 IP 地址 192.168.0.3 的 LAN 的路由器接口。

这是ifconfig -a输出:

adam@gondolin:~$ ifconfig -a
enp0s31f6: flags=4098<BROADCAST,MULTICAST>  mtu 1500
        ether e0:d5:5e:62:97:4c  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 16  memory 0xf7400000-f7420000  

enp5s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.228  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 fe80::e2d5:5eff:fe62:974e  prefixlen 64  scopeid 0x20<link>
        ether e0:d5:5e:62:97:4e  txqueuelen 1000  (Ethernet)
        RX packets 5561  bytes 431753 (431.7 KB)
        RX errors 0  dropped 898  overruns 0  frame 0
        TX packets 4462  bytes 1871915 (1.8 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device memory 0xf7200000-f721ffff  

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 9479  bytes 757999 (757.9 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 9479  bytes 757999 (757.9 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlp6s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.230  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 fe80::39c6:9a99:7b58:1cf1  prefixlen 64  scopeid 0x20<link>
        ether 00:e1:8c:75:39:d3  txqueuelen 1000  (Ethernet)
        RX packets 29  bytes 4677 (4.6 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 64  bytes 9172 (9.1 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

adam@gondolin:~$ 

它还显示有关 wifi 接口的信息 - 另一个可疑迹象,但我没有使用它 - 禁用它是netplan个好主意吗? (以及如何?)

这是输出networkctl

adam@gondolin:~$ networkctl
IDX LINK             TYPE               OPERATIONAL SETUP     
  1 lo               loopback           carrier     unmanaged 
  2 enp5s0           ether              routable    configured
  3 enp0s31f6        ether              off         unmanaged 
  4 wlp6s0           wlan               routable    unmanaged 

4 links listed.
adam@gondolin:~$ 

这是syslog尝试启动时出现的错误ppp

Aug 26 22:03:10 localhost pppd[10297]: Plugin rp-pppoe.so loaded.
Aug 26 22:03:10 localhost pppd[10298]: pppd 2.4.7 started by adam, uid 0
Aug 26 22:03:10 localhost pppd[10298]: error sending pppoe packet: Network is down
Aug 26 22:03:10 localhost pppd[10298]: error receiving pppoe packet: Network is down
Aug 26 22:03:15 localhost pppd[10298]: error sending pppoe packet: Network is down
Aug 26 22:03:25 localhost pppd[10298]: error sending pppoe packet: Network is down
Aug 26 22:03:45 localhost pppd[10298]: Timeout waiting for PADO packets
Aug 26 22:03:45 localhost pppd[10298]: Unable to complete PPPoE Discovery
Aug 26 22:03:51 localhost pppd[10298]: Terminating on signal 15
Aug 26 22:03:51 localhost pppd[10298]: Exit.

最后,这是我的/etc/ppp/peers/provider

adam@gondolin:~$ cat /etc/ppp/peers/provider
# See the manual page pppd(8) for information on all the options.
# There should be a matching entry with the password in /etc/ppp/pap-secrets
# and/or /etc/ppp/chap-secrets.
user "[email protected]"
hide-password
plugin rp-pppoe.so nic-enp0s31f6
# MUST CHANGE: replace ******** with the phone number of your provider.
# The /etc/chatscripts/pap chat script may be modified to change the
# modem initialization string.
#connect "/usr/sbin/chat -v -f /etc/chatscripts/pap -T ********"
# Serial device to which the modem is connected.
#/dev/modem
# Speed of the serial line.
#115200
# Assumes that your IP address is allocated dynamically by the ISP.
noipdefault
# Don't try to get the name server addresses from the ISP - messes up local name resolution
#usepeerdns    
# Use this connection as the default route.
defaultroute
replacedefaultroute
# Makes pppd "dial again" when the connection is lost.
persist
# Do not ask the remote to authenticate.
noauth

adam@gondolin:~$ 

syslog我还看到启动时登录流显示某些东西正在复活network-manager,尽管我已将其禁用sudo systemctl disable network-manager

答案1

我设法修复了ppp

我做了一些更改。我停止、禁用并删除了network-manager它的软件包。这阻止了 Ubuntu 在启动时启动它,这大概是对在系统中查找 wifi 网络接口的反应。

实际上,我尝试配置/etc/NetworkManager/NetworkManager.conf以忽略所有接口名称,如下wl所示:

[keyfile]
unmanaged-devices=interface-name:wl*

但这并没有帮助。

我浪费了很多时间在 wifi 界面上,因为我认为设置它会很方便,这样我就可以自由地配置 2 个以太网卡,而不必担心如何 ssh 到机器上。这个决定花了我几个小时。

这是我当前的netplanyaml:

adam@gondolin:~$ cat /etc/netplan/01-netcfg.yaml
# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
  version: 2
  renderer: networkd
  ethernets:
    enp5s0:
      dhcp4: no
      dhcp4: no
      addresses: [ 192.168.0.3/24 ]
    enp0s31f6:
      addresses:
      - fe80::10/128
      dhcp4: no
      dhcp6: no
  wifis:
    wlp6s0:
      dhcp4: yes
      dhcp6: yes
      access-points:
        "ANDUIN":
          password: "top-secret"
adam@gondolin:~$ 

其中一个关键点是面向外部的 NIC 的 IPv6 地址enp0s31fs- 这是 netplan 问题的一个解决方法https://bugs.launchpad.net/netplan/+bug/1763608down如果接口没有 IP 地址,则会导致 netplan 离开接口。我认为这将在未来导致 IPv6 问题。

我还没有将其安装ppp为服务或挂接networkd-dispatcher,也没有准备好互联网连接,所以我还没有完成,但至少这个问题已经得到解答了。

相关内容