在运行 Ubuntu 18.04 的老服务器上更换新 NIC 卡时出现问题

在运行 Ubuntu 18.04 的老服务器上更换新 NIC 卡时出现问题

我正在尝试将 10gb NIC 卡添加到运行 18.04 的旧 Ubuntu 服务器上,但遇到了困难。我目前正在使用 apt-get 更新,但该服务器已运行至少十年,我相信由于 Ubuntu 在此期间的变化,网络配置现在变得一团糟。

我当前的设置是将服务器的 LOM 设置为静态 IP 10.0.0.12。我想将该 IP 地址移动到新的 NIC 卡。虽然让另一个 NIC 仍与同一 10.0.0.x 子网中的其他 IP 地址一起工作可能很好,但这并不是至关重要的。

在下面的输出中,enp7s0f0np0 是我要移动到的光纤 10gb 端口。我希望它位于 10.0.0.12。

eth0 是我想移除的旧铜千兆端口。我希望它能放弃 10.0.0.12。

stew@argus:~$ ifconfig -a
enp7s0f0np0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.0.171  netmask 255.255.255.0  broadcast 10.0.0.255
        inet6 fe80::c665:5865:8783:9f44  prefixlen 64  scopeid 0x20<link>
        ether 00:0f:53:24:8a:10  txqueuelen 1000  (Ethernet)
        RX packets 15856  bytes 6617218 (6.6 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2894  bytes 318866 (318.8 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 16  

enp7s0f1np1: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 00:0f:53:24:8a:11  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 17  

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.0.121  netmask 255.255.255.0  broadcast 10.0.0.255
        inet6 fe80::20f:1fff:fefa:be37  prefixlen 64  scopeid 0x20<link>
        ether 00:0f:1f:fa:be:37  txqueuelen 1000  (Ethernet)
        RX packets 416  bytes 82839 (82.8 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 525  bytes 109468 (109.4 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

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 413  bytes 149729 (149.7 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 413  bytes 149729 (149.7 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

tap0: flags=4098<BROADCAST,MULTICAST>  mtu 1500
        ether 02:2e:55:4a:8a:6e  txqueuelen 100  (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

我不知道为什么 enp7s0f0np0 位于 10.0.0.171,而这在我的 DHCP 范围内。正如您在下面的 /etc/network/interfaces 文件中看到的,我尝试将其静态设置为 10.0.0.6。

stew@argus:~$ ethtool eth0
Settings for eth0:
        Supported ports: [ TP ]
        Supported link modes:   10baseT/Half 10baseT/Full 
                                100baseT/Half 100baseT/Full 
                                1000baseT/Full 
        Supported pause frame use: No
        Supports auto-negotiation: Yes
        Supported FEC modes: Not reported
        Advertised link modes:  10baseT/Half 10baseT/Full 
                                100baseT/Half 100baseT/Full 
                                1000baseT/Full 
        Advertised pause frame use: No
        Advertised auto-negotiation: Yes
        Advertised FEC modes: Not reported
        Speed: 1000Mb/s
        Duplex: Full
        Port: Twisted Pair
        PHYAD: 0
        Transceiver: internal
        Auto-negotiation: on
        MDI-X: off (auto)
Cannot get wake-on-lan settings: Operation not permitted
        Current message level: 0x00000007 (7)
                               drv probe link
        Link detected: yes

^ 铜千兆端口

stew@argus:~$ ethtool enp7s0f0np0
Settings for enp7s0f0np0:
        Supported ports: [ FIBRE ]
        Supported link modes:   1000baseT/Full 
                                10000baseT/Full 
        Supported pause frame use: Symmetric Receive-only
        Supports auto-negotiation: Yes
        Supported FEC modes: Not reported
        Advertised link modes:  1000baseT/Full 
                                10000baseT/Full 
        Advertised pause frame use: Symmetric
        Advertised auto-negotiation: Yes
        Advertised FEC modes: Not reported
        Link partner advertised link modes:  10000baseT/Full 
        Link partner advertised pause frame use: Symmetric
        Link partner advertised auto-negotiation: No
        Link partner advertised FEC modes: Not reported
        Speed: 10000Mb/s
        Duplex: Full
        Port: FIBRE
        PHYAD: 255
        Transceiver: internal
        Auto-negotiation: on
Cannot get wake-on-lan settings: Operation not permitted
        Current message level: 0x000020f7 (8439)
                               drv probe link ifdown ifup rx_err tx_err hw
        Link detected: yes

^ 10Gb 光纤端口

stew@argus:~$ cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
#auto eth0
#iface eth0 inet dhcp

auto eth0
iface eth0 inet static
address 10.0.0.121
netmask 255.255.255.0
network 10.0.0.0
broadcast 10.0.0.255
gateway 10.0.0.1
dns-addresses 10.0.0.1

auto enp7s0f0np0
iface eth0 inet static
address 10.0.0.12
netmask 255.255.255.0
network 10.0.0.0
broadcast 10.0.0.255
gateway 10.0.0.1
dns-addresses 10.0.0.1

这里我尝试将 eth0 移到 10.0.0.121 一侧。

看起来我没有运行 Netplan,或者至少没有完全运行:

stew@argus:~$ cd /etc/netplan/
stew@argus:/etc/netplan$ ls -alg
total 24
drwxr-xr-x   2 root  4096 Jun 20 20:06 .
drwxr-xr-x 211 root 16384 Jun 20 20:02 ..
-rw-r--r--   1 root   235 May 21 21:24 50-cloud-init.yaml
stew@argus:/etc/netplan$ cat 50-cloud-init.yaml 
network:
version: 2
ethernets:
    ens3:
        dhcp4: true
        match:
            macaddress: <redacted for post>
        set-name: ens3
        nameservers:
            addresses: [10.0.0.1, 8.8.4.4, 8.8.8.8, 1.1.1.1, 1.1.0.0]

当我尝试对 /etc/network/interfaces 进行以下更改时:

stew@argus:~$ cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
#auto eth0
#iface eth0 inet dhcp

#auto eth0
#iface eth0 inet static
#address 10.0.0.121
#netmask 255.255.255.0
#network 10.0.0.0
#broadcast 10.0.0.255
#gateway 10.0.0.1
#dns-addresses 10.0.0.1

auto enp7s0f0np0
iface eth0 inet static
address 10.0.0.12
netmask 255.255.255.0
network 10.0.0.0
broadcast 10.0.0.255
gateway 10.0.0.1
dns-addresses 10.0.0.1

我失去了 ssh 和 ping 10.0.0.12 的服务器的能力——或者我能想到的任何 IP——但是我从盒子向外发出 ping 声。

再次强调,您应该假设此服务器上可能存在任何历史 Ubuntu 网络配置类型,它已经连续运行了 10 多年。我知道几种类型,但我想我一定错过了什么。

建议?

答案1

自动 enp7s0f0np0
ifaceenp7s0f0np0inet 静态
地址 10.0.0.12
网络掩码 255.255.255.0
网络 10.0.0.0
广播 10.0.0.255
网关 10.0.0.1
dns 地址 10.0.0.1

快速浏览一下,似乎您可能延续了 eth0,而不是我上面用粗体标记的新接口名称。

答案2

我认为我解决了这个问题。

我遵循了本教程:

https://www.itzgeek.com/how-tos/linux/ubuntu-how-tos/netplan-how-to-configure-static-ip-address-in-ubuntu-18-04-using-netplan.html,从“使用 Netplan 配置静态 IP 地址”部分开始。

我的 netplan 目录现在如下所示:

stew@argus:~$ cd /etc/netplan/
stew@argus:/etc/netplan$ ls -alg
total 24
drwxr-xr-x   2 root  4096 Jun 20 22:38 .
drwxr-xr-x 211 root 16384 Jun 20 20:02 ..
-rw-r--r--   1 root   384 Jun 20 22:38 01-network-card.yaml
stew@argus:/etc/netplan$ cat 01-network-card.yaml 
network:
        version: 2
        renderer: networkd
        ethernets:
                enp7s0f0np0:
                        dhcp4: no
                        addresses: [10.0.0.12/24]
                        gateway4: 10.0.0.1
                        nameservers:
                                search: [doodle.local]
                                addresses: [10.0.0.1,8.8.8.8]
stew@argus:/etc/netplan$ 

因为我做了

apt remove ifupdown

作为指南的一部分,我相信我的 /etc/network/interfaces 文件现在已不相关。但谢谢 @Justus95,您的建议可能确实是该设置存在问题。

相关内容