如何从命令行刷新有线以太网连接?

如何从命令行刷新有线以太网连接?

取消选中“启用网络”(禁用网络)然后重新启用的命令行等效项是什么?

在我的环境中,有多个网络需要我物理移动网线。有时我的连接无法正常刷新,因此我会禁用/重新启用网络以刷新连接。如果能够从命令行执行此操作,对我来说效率会高得多。

我正在使用 12.04 LTS。

答案1

你可以试试:

nmcli connection reload

它将从磁盘重新加载所有连接文件。

答案2

我会用nmcli用于此目的的命令:

nmcli nm enable false && nmcli nm enable true

手册页:

DESCRIPTION
       nmcli is a command‐line tool for controlling NetworkManager and report‐
       ing on its status.  It is not meant as a full replacement for nm‐applet
       or other similar clients but as a complementary utility to those pro‐
       grams.  The main usage for nmcli is on servers, headless machines or
       for power users who prefer the command line.

       [...]

  nm     NetworkManager
          Use this object to inquire and change state of NetworkManager.

         [...]

          enable [true|false]
                 Get networking‐enabled status or enable/disable network‐
                 ing by NetworkManager.  All interfaces managed by Net‐
                 workManager are deactivated when networking has been dis‐
                 abled.
                 Reference to D‐Bus:
                 interface: org.freedesktop.NetworkManager
                 method:    Enable
                 arguments: TRUE or FALSE

答案3

请尝试:

sudo service network-manager restart

答案4

要从磁盘重新加载所有连接文件(例如在更新 vpn 密码后),您只需sudo nmcli c reload

相关内容