我想知道如何在 Ubuntu 20.04 中更改接口名称。我已将文件配置/etc/netplan/01-network-manager-all.yaml
如下:
# Let NetworkManager manage all devices on this system
network:
version: 2
renderer: NetworkManager
ethernets:
nf0:
match:
macaddress: 02:53:55:4d:45:00
macaddress: 00:00:00:00:00:00
addresses:
- 192.168.1.0/24
optional: true
set-name: nf0
nf1:
match:
macaddress: 02:53:55:4d:45:01
macaddress: 00:00:00:00:00:01
addresses:
- 192.168.1.1/24
optional: true
set-name: nf1
nf2:
match:
macaddress: 02:53:55:4d:45:02
macaddress: 00:00:00:00:00:02
addresses:
- 192.168.1.2/24
optional: true
set-name: nf2
nf3:
match:
macaddress: 02:53:55:4d:45:03
macaddress: 00:00:00:00:00:03
addresses:
- 192.168.1.3/24
optional: true
set-name: nf3
据我所知,我必须定义ethernets:
节点内的每个接口。我的目的是通过匹配 MAC 地址(使用选项)来查找接口,match
并设置名称(使用set-name:
)、新 MAC 地址(使用macaddress:
)和 IP 地址(使用addresses:
)。除其中一个接口外,每个接口均按预期配置(有时 nf3 不采用配置,有时 nf2 不采用配置)。上面的配置一定有问题,但我看不出来。我也读过参考,但我可能读错了,或者我漏掉了一些东西。如果能对我提出的问题提供一些见解,我将不胜感激。下面我放上输出,ifconfig
以便您看到如何nf2
调用enp1s0
,并且它不采用我在配置文件中指示的 IP。
enp1s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
ether 00:00:00:00:00:02 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 420 bytes 136080 (136.0 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
enp5s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.20 netmask 255.255.255.0 broadcast 192.168.0.255
ether 70:8b:cd:9e:d7:6b txqueuelen 1000 (Ethernet)
RX packets 38759 bytes 32961673 (32.9 MB)
RX errors 0 dropped 19 overruns 0 frame 0
TX packets 27510 bytes 3688242 (3.6 MB)
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
loop txqueuelen 1000 (Local Loopback)
RX packets 3424 bytes 356738 (356.7 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 3424 bytes 356738 (356.7 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
nf0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
ether 02:53:55:4d:45:00 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
nf1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.1 netmask 255.255.255.0 broadcast 192.168.1.255
ether 00:00:00:00:00:01 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 688 bytes 118186 (118.1 KB)
TX errors 0 dropped 1 overruns 0 carrier 0 collisions 0
nf3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.3 netmask 255.255.255.0 broadcast 192.168.1.255
ether 00:00:00:00:00:03 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 28 bytes 2471 (2.4 KB)
TX errors 0 dropped 5 overruns 0 carrier 0 collisions 0
此外,如果有帮助的话,这里是uname -a
输出:
Linux main 5.8.0-36-generic #40~20.04.1-Ubuntu SMP Wed Jan 6 10:15:55 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
感谢您的评论和帮助。
编辑(回应 heynnema 的评论):enp5s0 来自主板,但 enp1s0、nf0、nf1、nf3 来自FPGA-SUME系统使用合成 NIC 进行编程并通过 PCIe 连接。我没有使用 IP 192.168.0.0 或 IP 192.168.0.1(尽管我将 IP 更改为 192.168.1.150-192.168.1.153,但没有任何变化)。
我需要更改 MAC 地址,因为我正在构建一个原型,其中有两个主机,每个主机都连接一个 NetFPGA-SUME(因此每个主机都有 4 个以太网端口:nf0、nf1、nf2 和 nf3)。我计划通过交换机(在第三个 NetFPGA-SUME 板上实现)与每个主机进行通信。我必须更改 MAC 地址,因为主机 A 中的端口 nf0 具有与主机 B 中的 nf0 相同的 MAC 地址。因此,我想区分它们。此外,我认为填充交换机 TCAM 时会出现问题。
我想使用set-name
可读性,这样我就可以清楚地区分接口。我不想将其中一个 nfX 端口与主板以太网端口混淆。
关于 DNS 问题,我并不想通过这些端口连接到互联网(提供互联网连接的端口是 enp5s0),所以我认为它们没有必要。我认为我也可以删除 IP,因为交换机只在第二层工作,但我只是好奇为什么其中一个接口不能正确获取 IP。
输出sudo lshw -C network
:
*-network
description: Ethernet interface
product: RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller
vendor: Realtek Semiconductor Co., Ltd.
physical id: 0
bus info: pci@0000:05:00.0
logical name: enp5s0
version: 15
serial: 70:8b:cd:9e:d7:6b
size: 1Gbit/s
capacity: 1Gbit/s
width: 64 bits
clock: 33MHz
capabilities: pm msi pciexpress msix bus_master cap_list ethernet physical tp mii 10bt 10bt-fd 100bt 100bt-fd 1000bt-fd autonegotiation
configuration: autonegotiation=on broadcast=yes driver=r8169 driverversion=5.8.0-36-generic duplex=full firmware=rtl8168h-2_0.0.2 02/26/15 ip=192.168.0.20 latency=0 link=yes multicast=yes port=MII speed=1Gbit/s
resources: irq:18 ioport:e000(size=256) memory:fe804000-fe804fff memory:fe800000-fe803fff
*-network:0
description: Ethernet interface
physical id: 1
bus info: pci@0000:01:00.0
logical name: nf1
serial: 00:00:00:00:00:01
capabilities: ethernet physical
configuration: broadcast=yes driver=NetFPGA SUME (RIFFA DMA) driverversion=5.8.0-36-generic ip=192.168.1.151 multicast=yes
*-network:1
description: Ethernet interface
physical id: 2
bus info: pci@0000:01:00.0
logical name: nf2
serial: 00:00:00:00:00:02
capabilities: ethernet physical
configuration: broadcast=yes driver=NetFPGA SUME (RIFFA DMA) driverversion=5.8.0-36-generic ip=192.168.1.152 multicast=yes
*-network:2
description: Ethernet interface
physical id: 3
bus info: pci@0000:01:00.0
logical name: enp1s0
serial: 00:00:00:00:00:03
capabilities: ethernet physical
configuration: broadcast=yes driver=NetFPGA SUME (RIFFA DMA) driverversion=5.8.0-36-generic multicast=yes
输出grep GRUB /etc/default/grub
:
GRUB_DEFAULT=0
GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=-1
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash ipv6.disable=1"
GRUB_CMDLINE_LINUX="ipv6.disable=1"
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"
#GRUB_TERMINAL=console
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480
# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true
#GRUB_DISABLE_RECOVERY="true"
#GRUB_INIT_TUNE="480 440 1"
答案1
BIOS
从https://github.com/NetFPGA/NetFPGA-SUME-public/wiki/Getting-Started-Guide.。
主机主板
NetFPGA-SUME 板既可以独立工作,也可以在主机内部工作。如果您打算在主机中使用 NetFPGA-SUME 板,则需要确保主板支持 PCI Express Gen3 x8 配置。建议在主板上安装最新的固件。对于某些主板,您可能需要在 BIOS 配置中手动将 PCI Express 配置设置为 Gen3。
使用 验证当前 BIOS
sudo dmidecode -s bios-version
。根据需要进行更新。验证 Gen3 的 BIOS 设置。
YAML
你的 .yaml 应该看起来更像这个骨架...并且缩进应该是 2 个空格,没有制表符...
network:
version: 2
renderer: networkd
ethernets:
enp5s0:
# populate as required
nf0:
# populate as required
nf1:
# populate as required
enp1s0:
# populate as required
nf3:
# populate as required
GRUB
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash ipv6.disable=1"
GRUB_CMDLINE_LINUX="ipv6.disable=1"
小问题...你只需要“ipv6.disable=1”一次。
更新#1:
macaddress: 00:00:00:00:00:00
原始 .yaml 文件中的 nf0 无效。使用不同的 MAC,现在一切正常。