關於「NetworkManager」的操作使用 [論壇 - Ubuntu 與工具程式及軟體推薦]
正在瀏覽:
1 名遊客
關於「NetworkManager」的操作使用 |
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
會員五級
![]() ![]() 註冊日期:
2012/4/22 10:50 所屬群組:
已註冊使用者 等級: 37
HP : 0 / 905
![]() |
延續『#5 回覆: 關於「resolvconf」的操作使用』這篇討論。
以下對「NetworkManager」探索到的部份,簡單做個紀錄。 以下測試環境是「Xubuntu 16.04 amd64 英文界面」。 ================================================================================ ## Package * network-manager ================================================================================ ## Manpage 執行
顯示
* man 1 nmcli * man 1 nm-online * man 1 nmtui * man 1 nmtui-connect * man 1 nmtui-edit * man 1 nmtui-hostname * man 5 NetworkManager.conf * man 5 nm-settings * man 5 nm-settings-keyfile * man 5 nm-system-settings.conf * man 7 nmcli-examples * man 8 NetworkManager ================================================================================ ## service 執行
顯示
## /lib/systemd/system/NetworkManager.service 執行
顯示
## /lib/systemd/system/network-manager.service 執行
顯示
================================================================================ ## init 執行
顯示
================================================================================ ## 更多相關的套件 執行
顯示
================================================================================ 執行
顯示
================================================================================ 執行
顯示
================================================================================ 待續...
2017/10/6 15:18
|
||||||||||
![]() |
回覆: 關於「NetworkManager」的操作使用 |
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
會員五級
![]() ![]() 註冊日期:
2012/4/22 10:50 所屬群組:
已註冊使用者 等級: 37
HP : 0 / 905
![]() |
這篇的用法可以對照參考「#2 回覆: 請問mysqld問題」的說明。
================================================================================ ## usage 執行
顯示
執行
顯示
================================================================================ ## status 執行
或是執行
或是執行
會看到類似下面的訊息 ● NetworkManager.service - Network Manager Loaded: loaded (/lib/systemd/system/NetworkManager.service; enabled; vendor preset: enabled) Active: active (running) since Wed 2017-10-04 15:07:55 CST; 11min ago Docs: man:NetworkManager(8) Main PID: 1121 (NetworkManager) CGroup: /system.slice/NetworkManager.service ├─1121 /usr/sbin/NetworkManager --no-daemon ├─1334 /sbin/dhclient -d -q -sf /usr/lib/NetworkManager/nm-dhcp-helper -pf /var/run/dhclient-enp4s0.pid -lf /var/lib/NetworkManager/ └─1374 /usr/sbin/dnsmasq --no-resolv --keep-in-foreground --no-hosts --bind-interfaces --pid-file=/var/run/NetworkManager/dnsmasq.pi Oct 04 15:08:02 my-host-name dnsmasq[1374]: started, version 2.75 cache disabled Oct 04 15:08:02 my-host-name dnsmasq[1374]: compile time options: IPv6 GNU-getopt DBus i18n IDN DHCP DHCPv6 no-Lua TFTP conntrack ipset auth DN Oct 04 15:08:02 my-host-name dnsmasq[1374]: DBus support enabled: connected to system bus Oct 04 15:08:02 my-host-name dnsmasq[1374]: warning: no upstream servers configured Oct 04 15:08:02 my-host-name NetworkManager[1121]: <info> [1507100882.9787] device (enp4s0): Activation: successful, device activated. Oct 04 15:08:02 my-host-name NetworkManager[1121]: <info> [1507100882.9833] dnsmasq[0xf01100]: dnsmasq appeared as :1.19 Oct 04 15:08:02 my-host-name dnsmasq[1374]: setting upstream servers from DBus Oct 04 15:08:02 my-host-name dnsmasq[1374]: using nameserver 192.168.1.1#53(via enp4s0) Oct 04 15:08:04 my-host-name NetworkManager[1121]: <info> [1507100884.4873] manager: startup complete Oct 04 15:08:19 my-host-name NetworkManager[1121]: <info> [1507100899.4403] bluez: use BlueZ version 5 執行
顯示
執行
NetworkManager(1121)─┬─dhclient(1334) ├─dnsmasq(1374) ├─{gdbus}(1267) └─{gmain}(1265) ================================================================================ ## force-reload 執行
或是執行
這個在「#5 回覆: 關於「resolvconf」的操作使用」有使用到。 並且可以對照下面的「#3」來看。 ================================================================================ ## restart 執行
顯示
或是執行
或是執行
================================================================================ ## start 執行
顯示
或是執行
或是執行
================================================================================ ## stop 執行
顯示
或是執行
或是執行
================================================================================ 待續...
2017/10/6 15:21
|
||||||||||
![]() |
回覆: 關於「NetworkManager」的操作使用 |
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
會員五級
![]() ![]() 註冊日期:
2012/4/22 10:50 所屬群組:
已註冊使用者 等級: 37
HP : 0 / 905
![]() |
# Reload NetworkManager's configuration
這裡的用法,使用情境,可以用在「#5 回覆: 關於「resolvconf」的操作使用」的「實驗二」。 ================================================================================ 執行 $ man NetworkManager 可以找到下面這一段說明 SIGNALS NetworkManager process handles the following signals: SIGHUP The signal causes a reload of NetworkManager's configuration. Note that not all configuration parameters can be changed at runtime and therefore some changes may be applied only after the next restart of the daemon. A SIGHUP also involves further reloading actions, like doing a DNS update and restarting the DNS plugin. The latter can be useful for example when using the dnsmasq plugin and changing its configuration in /etc/NetworkManager/dnsmasq.d. However, it also means this will shortly interrupt name resolution. In the future, there may be further actions added. A SIGHUP means to update NetworkManager configuration and reload everything that is supported. Note that this does not reload connections from disk. For that there is a D-Bus API and nmcli's reload action 執行
或是執行
顯示
================================================================================ ## 方式一 先執行下面指令,找到「NetworkManager」的「pid」
顯示
執行下面指令,重新載入「NetworkManager」的「configuration」
或是執行下面指令,重新載入「NetworkManager」的「configuration」
最後執行
可以看到類似如下面的訊息
也可以在「/var/log/syslog」這個檔案,看到類似的「log」。 例如執行
可以看到類似如下面的訊息
================================================================================ ## 方式二 執行下面指令,重新載入「NetworkManager」的「configuration」
顯示
接著執行
可以看到類似如下面的訊息
================================================================================ ## 方式三 執行下面指令,重新載入「NetworkManager」的「configuration」
顯示
或是執行下面指令,重新載入「NetworkManager」的「configuration」
或是執行下面指令,重新載入「NetworkManager」的「configuration」
最後執行
可以看到類似如下面的訊息
================================================================================ ...待續...
2017/10/6 15:27
|
||||||||||
![]() |
回覆: 關於「NetworkManager」的操作使用 |
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
會員五級
![]() ![]() 註冊日期:
2012/4/22 10:50 所屬群組:
已註冊使用者 等級: 37
HP : 0 / 905
![]() |
接下來紀錄,跟「D-Bus」相關的操作,可以對照『回覆: 關於「dnsmasq」的操作使用』的「#3」,「#4」,「#5」。
上面「#3」的「方式三」,也有使用範例。 ================================================================================ 執行
顯示
================================================================================ 執行
顯示
================================================================================ 執行
顯示
================================================================================ 執行
顯示 <!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> <!-- GDBus 2.48.2 --> <node> <interface name="org.freedesktop.DBus.Properties"> <method name="Get"> <arg type="s" name="interface_name" direction="in"/> <arg type="s" name="property_name" direction="in"/> <arg type="v" name="value" direction="out"/> </method> <method name="GetAll"> <arg type="s" name="interface_name" direction="in"/> <arg type="a{sv}" name="properties" direction="out"/> </method> <method name="Set"> <arg type="s" name="interface_name" direction="in"/> <arg type="s" name="property_name" direction="in"/> <arg type="v" name="value" direction="in"/> </method> <signal name="PropertiesChanged"> <arg type="s" name="interface_name"/> <arg type="a{sv}" name="changed_properties"/> <arg type="as" name="invalidated_properties"/> </signal> </interface> <interface name="org.freedesktop.DBus.Introspectable"> <method name="Introspect"> <arg type="s" name="xml_data" direction="out"/> </method> </interface> <interface name="org.freedesktop.DBus.Peer"> <method name="Ping"/> <method name="GetMachineId"> <arg type="s" name="machine_uuid" direction="out"/> </method> </interface> <interface name="org.freedesktop.NetworkManager"> <method name="Reload"> <arg type="u" name="flags" direction="in"/> </method> <method name="GetDevices"> <arg type="ao" name="devices" direction="out"/> </method> <method name="GetAllDevices"> <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_manager_get_all_devices"/> <arg type="ao" name="devices" direction="out"/> </method> <method name="GetDeviceByIpIface"> <arg type="s" name="iface" direction="in"/> <arg type="o" name="device" direction="out"/> </method> <method name="ActivateConnection"> <arg type="o" name="connection" direction="in"/> <arg type="o" name="device" direction="in"/> <arg type="o" name="specific_object" direction="in"/> <arg type="o" name="active_connection" direction="out"/> </method> <method name="AddAndActivateConnection"> <arg type="a{sa{sv}}" name="connection" direction="in"/> <arg type="o" name="device" direction="in"/> <arg type="o" name="specific_object" direction="in"/> <arg type="o" name="path" direction="out"/> <arg type="o" name="active_connection" direction="out"/> </method> <method name="DeactivateConnection"> <arg type="o" name="active_connection" direction="in"/> </method> <method name="Sleep"> <arg type="b" name="sleep" direction="in"/> </method> <method name="Enable"> <arg type="b" name="enable" direction="in"/> </method> <method name="GetPermissions"> <arg type="a{ss}" name="permissions" direction="out"/> </method> <method name="SetLogging"> <arg type="s" name="level" direction="in"/> <arg type="s" name="domains" direction="in"/> </method> <method name="GetLogging"> <arg type="s" name="level" direction="out"/> <arg type="s" name="domains" direction="out"/> </method> <method name="CheckConnectivity"> <arg type="u" name="connectivity" direction="out"/> </method> <method name="state"> <arg type="u" name="state" direction="out"/> </method> <signal name="CheckPermissions"/> <signal name="StateChanged"> <arg type="u" name="state"/> </signal> <signal name="PropertiesChanged"> <arg type="a{sv}" name="properties"/> </signal> <signal name="DeviceAdded"> <arg type="o" name="device_path"/> </signal> <signal name="DeviceRemoved"> <arg type="o" name="device_path"/> </signal> <property type="ao" name="Devices" access="read"/> <property type="ao" name="AllDevices" access="read"/> <property type="b" name="NetworkingEnabled" access="read"/> <property type="b" name="WirelessEnabled" access="readwrite"/> <property type="b" name="WirelessHardwareEnabled" access="read"/> <property type="b" name="WwanEnabled" access="readwrite"/> <property type="b" name="WwanHardwareEnabled" access="read"/> <property type="b" name="WimaxEnabled" access="readwrite"/> <property type="b" name="WimaxHardwareEnabled" access="read"/> <property type="ao" name="ActiveConnections" access="read"/> <property type="o" name="PrimaryConnection" access="read"/> <property type="s" name="PrimaryConnectionType" access="read"/> <property type="u" name="Metered" access="read"/> <property type="o" name="ActivatingConnection" access="read"/> <property type="b" name="Startup" access="read"/> <property type="s" name="Version" access="read"/> <property type="u" name="State" access="read"/> <property type="u" name="Connectivity" access="read"/> <property type="a{sv}" name="GlobalDnsConfiguration" access="readwrite"/> </interface> <node name="AgentManager"/> <node name="Settings"/> <node name="IP6Config"/> <node name="DHCP4Config"/> <node name="IP4Config"/> <node name="ActiveConnection"/> <node name="Devices"/> </node> ================================================================================ 執行
顯示
用法請參考「man qdbus」。 ================================================================================ 執行
顯示
用法請參考「man gdbus」。 ================================================================================ 執行
顯示
用法請參考「man dbus-send」。 ================================================================================ 一些範例,也可以在「network-manager」的「Source Package」找到。 執行
然後執行
顯示 network-manager-1.2.6/examples/shell/ ├── active-wifi.sh ├── disconnect-device.sh ├── get-hostname.sh ├── list-devices.sh ├── Makefile.am ├── Makefile.in ├── nm-logging.sh └── test-get-hostname.sh 0 directories, 8 files 也可以直接連到「GitHub / NetworkManager / examples」觀看。 ================================================================================ ...待續...
2017/10/6 15:36
|
||||||||||
![]() |
回覆: 關於「NetworkManager」的操作使用 |
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
會員五級
![]() ![]() 註冊日期:
2012/4/22 10:50 所屬群組:
已註冊使用者 等級: 37
HP : 0 / 905
![]() |
# config
================================================================================ 執行
顯示
================================================================================ ## print-config 執行
顯示
================================================================================ 執行
顯示
可以找到兩個檔案 * /etc/NetworkManager/NetworkManager.conf * /etc/NetworkManager/conf.d/default-wifi-powersave-on.conf ================================================================================ ## /etc/NetworkManager/NetworkManager.conf 執行
顯示
================================================================================ ## /etc/NetworkManager/conf.d/default-wifi-powersave-on.conf 執行
顯示
================================================================================ 待續...
2017/10/6 15:39
|
||||||||||
![]() |
回覆: 關於「NetworkManager」的操作使用 |
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
會員五級
![]() ![]() 註冊日期:
2012/4/22 10:50 所屬群組:
已註冊使用者 等級: 37
HP : 0 / 905
![]() |
2017/10/6 15:43
|
||||||||||
![]() |
回覆: 關於「NetworkManager」的操作使用 |
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
會員五級
![]() ![]() 註冊日期:
2012/4/22 10:50 所屬群組:
已註冊使用者 等級: 37
HP : 0 / 905
![]() |
# Dispatcher scripts
================================================================================ 執行 $ man NetworkManager 可以找到下面這一段敘述 DISPATCHER SCRIPTS NetworkManager will execute scripts in the /etc/NetworkManager/dispatcher.d directory or subdirectories in alphabetical order in response to network events. Each script should be a regular executable file owned by root. Furthermore, it must not be writable by group or other, and not setuid. Each script receives two arguments, the first being the interface name of the device an operation just happened on, and second the action. For device actions, the interface is the name of the kernel interface suitable for IP configuration. Thus it is either VPN_IP_IFACE, DEVICE_IP_IFACE, or DEVICE_IFACE, as applicable. For the hostname action it is always "none". The actions are: ...略... up The interface has been activated. ...略... down The interface has been deactivated. ================================================================================ 執行
顯示 /etc/NetworkManager/dispatcher.d/ ├── 01ifupdown ├── no-wait.d ├── pre-down.d └── pre-up.d 3 directories, 1 file 執行
顯示
================================================================================ ## /etc/NetworkManager/dispatcher.d/01ifupdown 可以簡單做個小實驗,將「echo $@ > /tmp/test.log」這一行, 加入「/etc/NetworkManager/dispatcher.d/01ifupdown」這個檔案。 然後執行
顯示
執行
執行
顯示
執行
執行
顯示
================================================================================ 觀看「/etc/NetworkManager/dispatcher.d/01ifupdown」這個檔案, 可以看到下面一段程式碼 ...略... for i in $ADDRESS_FAMILIES; do export ADDRFAM="$i" # Run the right scripts case "$2" in up|vpn-up) export MODE="start" export PHASE="post-up" run-parts /etc/network/if-up.d ;; down|vpn-down) export MODE="stop" export PHASE="post-down" run-parts /etc/network/if-post-down.d ;; ...略... 執行
顯示
可以找到兩個資料夾 * /etc/network/if-up.d * /etc/network/if-post-down.d ================================================================================ 執行
顯示
執行
顯示
================================================================================ 執行
顯示
執行
顯示
================================================================================ ...待續...
2017/10/6 15:48
|
||||||||||
![]() |
回覆: 關於「NetworkManager」的操作使用 |
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
會員五級
![]() ![]() 註冊日期:
2012/4/22 10:50 所屬群組:
已註冊使用者 等級: 37
HP : 0 / 905
![]() |
# 關於「nm-applet」和「nm-connection-editor」
================================================================================ ## nm-applet 執行
顯示
執行
顯示
================================================================================ ## nm-connection-editor 執行
顯示
執行
顯示
================================================================================ ## bin 執行
顯示
================================================================================ ## man 執行
顯示
* man 1 nm-applet * man 1 nm-connection-editor ================================================================================ ## autostart 執行
顯示
執行
顯示
================================================================================ ## ui 執行
顯示
執行
================================================================================ ## gsettings 執行
顯示
執行
顯示
================================================================================ 執行
顯示
================================================================================ 執行
顯示
執行
顯示 Usage: gsettings [--schemadir SCHEMADIR] list-schemas List the installed (non-relocatable) schemas Arguments: SCHEMADIR A directory to search for additional schemas ================================================================================ 執行
顯示
================================================================================ 執行
顯示
================================================================================ 執行
顯示
================================================================================ 執行
執行
顯示
================================================================================ 執行
執行
顯示
================================================================================ ...待續...
2017/10/6 15:54
|
||||||||||
![]() |
回覆: 關於「NetworkManager」的操作使用 |
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
會員五級
![]() ![]() 註冊日期:
2012/4/22 10:50 所屬群組:
已註冊使用者 等級: 37
HP : 0 / 905
![]() |
# 關於「network-admin」
================================================================================ ## network-admin 執行
顯示
執行
顯示
執行
顯示
執行
顯示
執行
顯示
顯示
執行
顯示
================================================================================ ## bin 執行
顯示
================================================================================ ## man 執行
顯示
================================================================================ ## ui 執行
顯示
執行
================================================================================ 執行
執行
顯示
================================================================================ 暫告一段落 報告完畢 ![]()
2017/10/6 16:01
|
||||||||||
![]() |
回覆: 關於「NetworkManager」的操作使用 |
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
會員五級
![]() ![]() 註冊日期:
2012/4/22 10:50 所屬群組:
已註冊使用者 等級: 37
HP : 0 / 905
![]() |
剛在重新檢視「network-manager」這個套件,
發現有「nmtui」可以使用,以前沒特別去注意使用它, 剛測試了一下,是在「Terminal」下的「圖形界面」工具。 執行
顯示
執行
顯示
## Manpage * $ man nmtui * $ man nmtui-connect * $ man nmtui-edit * $ man nmtui-hostname 簡單的測試了一下,我的理解,「nmtui」是入口, 而「nmtui-edit」是用來維護「連線設定」,也就是「列表」,「新增」,「編輯」,「刪除」。 編輯好後,則是使用「nmtui-connect」來啟用某一個連線。 ================================================================================ 執行
顯示
================================================================================ 執行
顯示
================================================================================ 執行
顯示
================================================================================ 執行
顯示
================================================================================ 以上提供參考 報告完畢 ![]()
2017/10/28 9:32
|
||||||||||
![]() |
您可以查看帖子.
您不可發帖.
您不可回覆.
您不可編輯自己的帖子.
您不可刪除自己的帖子.
您不可發起投票調查.
您不可在投票調查中投票.
您不可上傳附件.
您不可不經審核直接發帖.