如何设置网桥的 MTU 为 9000?

Rob*_*J1M 10 networking

我必须桥接千兆网络接口。

/etc/network/interfaces 是:

 auto lo
 iface lo inet loopback

# Set up interfaces manually, avoiding conflicts with, e.g., network manager
 iface eth0 inet manual

 iface eth1 inet manual

 # Bridge setup
 auto br0
 iface br0 inet static
    bridge_ports eth0 eth1
    address 192.168.88.2
    broadcast 192.168.88.255
    netmask 255.255.255.0
    gateway 192.168.88.254
    dns-nameservers 192.168.88.254
Run Code Online (Sandbox Code Playgroud)

但是MTU只有1500

myth@myth:~$ traceroute --mtu 192.168.88.1
traceroute to 192.168.88.1 (192.168.88.1), 30 hops max, 65000 byte packets
 1  RoboStation.local (192.168.88.1)  0.278 ms F=1500  0.279 ms  0.287 ms
Run Code Online (Sandbox Code Playgroud)

如果我运行以下命令:

myth@myth:~$ sudo ifconfig eth0 mtu 9000
myth@myth:~$ sudo ifconfig eth1 mtu 9000
myth@myth:~$ traceroute --mtu 192.168.88.1

traceroute to 192.168.88.1 (192.168.88.1), 30 hops max, 65000 byte packets
 1  RoboStation.local (192.168.88.1)  0.407 ms F=9000  0.422 ms  0.383 ms
Run Code Online (Sandbox Code Playgroud)

现在我的 MTU 为 9000,传输到我的 NAS 的速度要快得多

但是,我想我会在 /etc/network/interfaces 文件中这样做:

 auto lo
 iface lo inet loopback

 # Set up interfaces manually, avoiding conflicts with, e.g., network manager
 iface eth0 inet manual
    mtu 9000

 iface eth1 inet manual
    mtu 9000

 # Bridge setup
 auto br0
 iface br0 inet static
    bridge_ports eth0 eth1
    address 192.168.88.2
    broadcast 192.168.88.255
    netmask 255.255.255.0
    gateway 192.168.88.254
    dns-nameservers 192.168.88.254
    mtu 9000
Run Code Online (Sandbox Code Playgroud)

但是网络在启动时无法启动

mtu 9000从 br0 部分删除了,PC 会随着网络启动而启动,但 MTU 仍然是 9000

如何在启动时将 eth0 和 eth1 的 MTU 设置为 9000,以便网桥以 9000 运行?

还有没有办法在不一直重启的情况下测试 /etc/network/interfaces ?

ger*_*ijk 10

看起来该mtu选项在使用该manual方法时不可用(请参阅 参考资料interfaces(5))。所以,这是应该起作用的(结合评论中的反馈):

auto lo
iface lo inet loopback

# Set up interfaces manually, avoiding conflicts with, e.g., network manager
iface eth0 inet manual
   # nothing here

iface eth1 inet manual
   # nothing here

# Bridge setup
auto br0
iface br0 inet static
   bridge_ports eth0 eth1
   address 192.168.88.2
   ...
   post-up ifconfig eth0 mtu 9000 && ifconfig eth1 mtu 9000
Run Code Online (Sandbox Code Playgroud)

使用up(或在这种情况下post-up)选项,我们可以指定我们自己的命令在界面启动期间(之后)运行。