如何自动化ethtool?

Hal*_*mar 4 command-line networking

我在 Windows XP 旁边的桌面上尝试了 Lubuntu。除了以下问题外,我真的很喜欢它:我有一个 LAN 宽带互联网连接,它可以在 XP 中完美运行,但在 Lubuntu 中却没有。

每次启动 Lubuntu 时,我都必须运行sudo ethtool -s eth0 speed 10 duplex half autoneg off. 然后建立有线连接。

是否有任何方法可以保存和自动化此命令,以便在我重新启动 Lubuntu 时自动建立 Internet 连接?

jfg*_*956 6

我不知道 lubuntu,但它基于 ubuntu,后者基于 debian,因此 debian 解决方案应该可以工作。

在 debian 中,网络配置在/etc/network/interface文件中。可以在使用post-up参数启动接口后执行命令。所以编辑/etc/network/interface文件如下应该没问题:

iface eth0 inet dhcp
    post-up /sbin/ethtool -s $IFACE speed 10 duplex half autoneg off
Run Code Online (Sandbox Code Playgroud)

似乎也可以直接ethtool/etc/network/interface文件中指定选项:

iface eth0 inet dhcp
    link-speed 10
    link-duplex half
    ethernet-autoneg off
Run Code Online (Sandbox Code Playgroud)

这些解决方案比使用/etc/rc.local技巧更好,因为它们将所有网络配置保存在一个单一的标准位置。