ブログ

オートネゴシエーションを無効にしてネットワーク通信速度を固定する方法: ethtool

at_shigehisa.y…
2019年10月1日 10時15分

今回は、ethtool(https://manpages.debian.org/buster/ethtool/ethtool.8.en.html)を使ってオートネゴシエーションの禁止と通信速度の固定を行います。 mii-toolを使う場合は、オートネゴシエーションを無効にしてネットワーク通信速度を固定する方法: mii-toolを参照して下さい。

1. ネットワーク状態の確認

はじめに、nmcliコマンドで、登録されているコネクションを確認します。

root@armadillo:~# nmcli connect
NAME                UUID                                  TYPE            DEVICE
Wired connection 1  d32dc075-1401-3f57-a4fd-d6af06337c0c  802-3-ethernet  eth0

ここでは、有線LANが登録されていることが分かります。

2. ethtoolのインストールおよびeth0の状態確認

以下のコマンドでethtoolをインストールします。

root@armadillo:~# apt-get install ethtool

以下のコマンドを実行して、eth0の状態を確認します。

root@armadillo:~# ethtool eth0
Settings for eth0:
        Supported ports: [ TP MII ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Supported pause frame use: Symmetric
        Supports auto-negotiation: Yes
        Advertised link modes:  10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Advertised pause frame use: Symmetric
        Advertised auto-negotiation: Yes
        Link partner advertised link modes:  10baseT/Half 10baseT/Full
                                             100baseT/Half 100baseT/Full
                                             1000baseT/Full
        Link partner advertised pause frame use: No
        Link partner advertised auto-negotiation: Yes
        Speed: 1000Mb/s
        Duplex: Full
        Port: MII
        PHYAD: 0
        Transceiver: internal
        Auto-negotiation: on
        Supports Wake-on: g
        Wake-on: d
        Link detected: yes

上記結果から、eth0はオートネゴシエーションが有効、通信速度1000Mbps、全二重でリンクアップされていることが分かります。

3. オートネゴシエーションの無効と通信速度の固定

ここでは、以下のコマンドを実行して、eth0のオートネゴシエーションを無効、通信速度を100Mbpsに固定してみます。

root@armadillo:~# ethtool -s eth0 speed 100 duplex full autoneg off
root@armadillo:~# fec 30bf0000.ethernet eth0: Link is Down
fec 30bf0000.ethernet eth0: Link is Up - 100Mbps/Full - flow control off

ethtoolを実行して、eth0が指定した設定になっていることを確認します。

root@armadillo:~# ethtool eth0
Settings for eth0:
        Supported ports: [ TP MII ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Supported pause frame use: Symmetric
        Supports auto-negotiation: Yes
        Advertised link modes:  100baseT/Full
        Advertised pause frame use: Symmetric
        Advertised auto-negotiation: No
        Speed: 100Mb/s
        Duplex: Full
        Port: MII
        PHYAD: 0
        Transceiver: internal
        Auto-negotiation: off
        Supports Wake-on: g
        Wake-on: d
        Link detected: yes
root@armadillo:~#

4. 変更した内容をArmadillo起動時に自動実行

ethtoolで変更した内容は一時的なものであり、Armadilloを再起動したら変更内容はデフォルトに戻ります。 Armadillo再起動時にオートネゴシエーションを無効にして、通信速度を所定の値に設定したい場合は、スクリプトを自動実行させます。 スクリプトの例を以下に示します。

#!/bin/bash
ethtool -s eth0 speed 100 duplex full autoneg off

上記スクリプトを自動実行させる方法は、以下のブログを参照して下さい。 Armadillo-X1, Armadillo-IoT G3/G3L: systemdでアプリを自動起動する方法(その1)