From 09263a244e66386de55ebf70c96c7ddd2998195e Mon Sep 17 00:00:00 2001 From: tianci Date: Sat, 23 Oct 2021 11:09:30 +0800 Subject: [PATCH 1/4] gemstone,nmtui command --- docs/gemstones/nmtui.zh.md | 114 +++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 docs/gemstones/nmtui.zh.md diff --git a/docs/gemstones/nmtui.zh.md b/docs/gemstones/nmtui.zh.md new file mode 100644 index 0000000000..0a38fb3d89 --- /dev/null +++ b/docs/gemstones/nmtui.zh.md @@ -0,0 +1,114 @@ +--- +title - 快速更改网络信息 +author: tianci li +update: 2021-10-23 +--- + +对于初次使用GNU/Linux的新手用户来说,最先考虑的事情是安装操作系统后如何让机器连接互联网。本篇将告诉您如何配置IP地址、子网掩码、网关以及DNS,有几种方式作为参考,不管是新手还是熟手,相信您都都能快速上手。 + +# nmtui + +`NetworkManager`是标准 Linux 网络配置工具套件,支持服务器,也支持桌面环境,发展到如今,绝大多数流行的发行版都支持它。Centos 7以及以后的版本中引入这个网络配置工具套件,如果您希望图形化的方式配置网络信息(即命令行`nmtui`),只需要这么做: + +```bash +shell > dnf -y install NetworkManager NetworkManager-tui +shell > nmtui +``` + +|NetworkManager TUI|| +|---|---| +|Edit a connection|| +|Activate a connection|| +|Set system hostname|| +|Quit|| +||\| + +您可以使用 Tab键 或者 键的方式选择具体的功能,如果要更改网络信息,请选择 **Edit a connection** ,然后Enter键。选择不同的网卡,选择 **Edit..** 进行编辑。 + +## DHCP的IPv4 + +针对IPv4,如果是使用DHCP的方式获取网络信息,则只需要选择 *IPv4 CONFIGURATION* 后面的 **\**,然后在您的终端中运行下`systemctl restart NetworkManager.service`,大多数的情况下都能生效,极少数的情况下需要开关网卡才能生效,例如这样的方式——`nmcli connection down ens33`,`nmcli connection up ens33` + +## 手动固定网络信息 + +如果要将所有IPv4的网络信息进行手动固定,需要选择 *IPv4 CONFIGURATION* 后面的 **\**,一行一行进行添加,例如我这样的: + +|项|值| +|---|---| +|Addresses|192.168.100.4/24|| +|Gateway|192.168.100.1|| +|DNS servers|8.8.8.8| + +然后点击 \ ,一步一步返回到终端界面,执行`systemctl restart NetworkManager.service` 即可。同样的,极少数的情况下需要开关网卡才能生效。 + +# 更改配置文件的方式 + +所有的RHEL发行版,不管是上游的还是下游的,都是一样的配置方式。网络信息的配置文件保存在 **/etc/sysconfig/network-scripts/** 目录下面,一个网卡对应一个配置文件。配置文件的参数非常的多,如下表所示。注意!参数一定要大写。 + +```bash +shell > ls /etc/sysconfig/network-scripts/ +ifcfg-ens33 +``` + +|参数名 |含义 | 示例| +|--- |--- |--- |--- | +|DEVICE |系统逻辑设备名 |DEVICE=ens33 | +|ONBOOT |网卡是否随系统自启动,可选择yes或者no|ONBOOT=yes| +|TYPE|网卡接口类型,一般是Ethernet|TYPE=Ethernet| +|BOOTPROTO|获取ip的方式,可以是DHCP动态获取,也可以使用static静态手动配置|BOOTPROTO=static| +|IPADDR|网卡的ip地址,当BOOTPROTO=static时,该参数才生效|IPADDR=192.168.100.4| +|HWADDR|硬件地址,即MAC地址|HWADDR=00:0C:29:84:F6:9C| +|NETMASK|十进制的子网掩码|NETMASK=255.255.255.0| +|PREFIX|子网掩码,用数字表示的方式|PREFIX=24| +|GATEWAY|网关,若有多块网卡,该参数只能出现一次|GATEWAY=192.168.100.1| +|PEERDNS|当为yes时,此处定义的DNS参数会修改/etc/resolv.conf;当为no时,不会修改/etc/resolv.conf。当使用DHCP时,此处默认yes|PEERDNS=yes| +|DNS1|主选DNS,当PEERDNS=no时才生效|DNS1=8.8.8.8| +|DNS2|备选DNS,当PEERDNS=no时才生效|DNS2=114.114.114.114| +|BROWSER_ONLY|是否只允许浏览器|BROWSER_ONLY=no| +|USERCTL|是否允许普通用户控制网卡设备,yes表示允许,no表示不允许|USERCTL=no| +|UUID|通用唯一识别码,主要作用是标识硬件,一般来说可不填|| +|PROXY_METHOD|代理的方式,一般为none,可不填|| +|IPV4_FAILURE_FATAL|如果为yes,表示ipv4配置失败后禁用设备;为no,表示不禁用。|IPV4_FAILURE_FATAL=no| +|IPV6INIT|是否启用IPV6,yes启用,no不启用。当IPV6INIT=yes时,还能启用 IPV6ADDR 与 IPV6_DEFAULTGW 两个参数,前者表示IPV6地址,后者表示指定网关|IPV6INIT=yes| +|IPV6_AUTOCONF|是否使用IPV6的自动配置,yes表示使用;no表示不使用|IPV6_AUTOCONF=yes| +|IPV6_DEFROUTE|是否给IPV6默认路由|IPV6_DEFROUTE=yes| +|IPV6_FAILURE_FATAL|IPV6配置失败后,是否禁用设备|IPV6_FAILURE_FATAL=no| +|IPV6_ADDR_GEN_MODE|产生IPV6地址的模型,可选值有stable-privacy与eui64|IPV6_ADDR_GEN_MODE=stable-privacy| + +配置文件修改成功后,记得重启网卡服务`systemctl restart NetworkManager.service` + +## IPV4的推荐配置 + +```bash +TYPE=Ethernet +ONBOOT=yes +DEVICE=ens33 +USERCTL=no +IPV4_FAILURE_FATAL=no +BROWSER_ONLY=no +BOOTPROTO=static +PEERDNS=no +IPADDR=192.168.100.4 +PREFIX=24 +GATEWAY=192.168.100.1 +DNS1=8.8.8.8 +DNS2=114.114.114.114 +``` + +## IPV6的推荐配置 + +```bash +TYPE=Ethernet +ONBOOT=yes +DEVICE=ens33 +USERCTL=no +BROWSER_ONLY=no +IPV6INIT=yes +IPV6_AUTOCONF=yes +IPV6_DEFROUTE=yes +IPV6_FAILURE_FATAL=no +``` + +# 查看网络信息 + +`ip a`或者`nmcli device show` From 829060a9dad41cba59fe3011ab4b4ce7c7ff4891 Mon Sep 17 00:00:00 2001 From: tianci li <86754294+jimcat8@users.noreply.github.com> Date: Sat, 23 Oct 2021 11:28:20 +0800 Subject: [PATCH 2/4] Update nmtui.zh.md --- docs/gemstones/nmtui.zh.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/gemstones/nmtui.zh.md b/docs/gemstones/nmtui.zh.md index 0a38fb3d89..4e016f20c4 100644 --- a/docs/gemstones/nmtui.zh.md +++ b/docs/gemstones/nmtui.zh.md @@ -50,8 +50,8 @@ shell > ls /etc/sysconfig/network-scripts/ ifcfg-ens33 ``` -|参数名 |含义 | 示例| -|--- |--- |--- |--- | +|参数名|含义|示例| +|---|---|---| |DEVICE |系统逻辑设备名 |DEVICE=ens33 | |ONBOOT |网卡是否随系统自启动,可选择yes或者no|ONBOOT=yes| |TYPE|网卡接口类型,一般是Ethernet|TYPE=Ethernet| From 1bd45b0f58fbb022cd3e21fefd867ef86d7c4b26 Mon Sep 17 00:00:00 2001 From: tianci li <86754294+jimcat8@users.noreply.github.com> Date: Mon, 25 Oct 2021 00:39:55 +0800 Subject: [PATCH 3/4] Update nmtui.zh.md --- docs/gemstones/nmtui.zh.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/gemstones/nmtui.zh.md b/docs/gemstones/nmtui.zh.md index 4e016f20c4..0921446b8b 100644 --- a/docs/gemstones/nmtui.zh.md +++ b/docs/gemstones/nmtui.zh.md @@ -8,7 +8,7 @@ update: 2021-10-23 # nmtui -`NetworkManager`是标准 Linux 网络配置工具套件,支持服务器,也支持桌面环境,发展到如今,绝大多数流行的发行版都支持它。Centos 7以及以后的版本中引入这个网络配置工具套件,如果您希望图形化的方式配置网络信息(即命令行`nmtui`),只需要这么做: +`NetworkManager`是标准 Linux 网络配置工具套件,支持服务器,也支持桌面环境,发展到如今,绝大多数流行的发行版都支持它。这套网络配置工具适用于 Rocky Linux 8 及更高版本,如果您希望图形化的方式配置网络信息(即命令行`nmtui`),只需要这么做: ```bash shell > dnf -y install NetworkManager NetworkManager-tui From 77d1a431e7a7c966441ec8ed46cacfadb82edf58 Mon Sep 17 00:00:00 2001 From: Steven Spencer Date: Mon, 25 Oct 2021 09:24:14 -0500 Subject: [PATCH 4/4] Edits for PR 322 and English translation * minor changes to the meta... fixed title - to title: and shortened the description for a better fit in the side menu * Added one top level # Introduction and changed the other top-levels to * Added the English translation and made sure that it formatted correctly in MkDocs --- docs/gemstones/nmtui.md | 117 +++++++++++++++++++++++++++++++++++++ docs/gemstones/nmtui.zh.md | 19 +++--- 2 files changed, 128 insertions(+), 8 deletions(-) create mode 100644 docs/gemstones/nmtui.md diff --git a/docs/gemstones/nmtui.md b/docs/gemstones/nmtui.md new file mode 100644 index 0000000000..92990d7b29 --- /dev/null +++ b/docs/gemstones/nmtui.md @@ -0,0 +1,117 @@ +--- +title: nmtui - Network Management Tool +author : tianci li +contributors: Steven Spencer +update : 2021-10-23 +--- + +# Introduction + +For novice users who are new to GNU/Linux for the first time, the first thing to consider is how to connect the machine to the Internet after installing the operating system. This article will tell you how to configure the IP address, subnet mask, gateway and DNS. There are several ways for reference. Whether you are a novice or a familiar, I believe you can quickly get started. + +## nmtui + +`NetworkManager` is a standard Linux network configuration tool suite, which supports server and desktop environments. Nowadays, most popular distributions support it. This set of network configuration tools is suitable for Rocky Linux 8 and later versions. If you want to configure network information graphically (i.e. the command line `nmtui` ), you only need to do this: + +```bash +shell > dnf -y install NetworkManager NetworkManager-tui +shell > nmtui +``` + +|NetworkManager TUI|| +|---|---| +|Edit a connection|| +|Activate a connection|| +|Set system hostname|| +|Quit|| +||\| + +You can use the Tab key or the key to select the specific If you want to change the network information, please select **Edit a connection** and then Enter. Select a different network card and select **Edit..** to edit. + +### DHCP IPv4 + +For IPv4, if it is to obtain network information using DHCP way, you only need to select * IPv4 CONFIGURATION * back ** \ < Automatic \> ** , and then run your terminal under `systemctl restart NetworkManager.service` , large In most cases, it can take effect. In rare cases, you need to switch the network card to take effect. For example, this way- `nmcli connection down ens33` , `nmcli connection up ens33` + +### Manually fix network information + +If you want to manually fix all IPv4 network information, you need to select ** \< Manual \> ** after *IPv4 CONFIGURATION* and add it line by line. For example, I like this: + +|Item|Value| +|---|---| +|Addresses|192.168.100.4/24|| +|Gateway|192.168.100.1|| +|DNS servers|8.8.8.8| + +Then click \< OK \> , return to the terminal interface step by step, and execute `systemctl restart NetworkManager.service` . Similarly, in rare cases, the network card needs to be switched on and off to take effect. + +## Change the way of configuration files + +All RHEL distributions, whether upstream or downstream, are configured in the same way. The configuration file of network information is stored in the **/etc/sysconfig/network-scripts/** directory, and one network card corresponds to one configuration file. The configuration file has many parameters, as shown in the following table. Notice! The parameters must be capitalized. + +```bash +shell > ls /etc/sysconfig/network-scripts/ +ifcfg-ens33 +``` + +|Parameter name|Meaning|Example| +|---|---|---| +|DEVICE |System logical device name|DEVICE=ens33 | +|ONBOOT |Whether the network card starts automatically with the system, you can choose yes or no|ONBOOT=yes| +|TYPE|Network card interface type, usually Ethernet|TYPE=Ethernet| +|BOOTPROTO|The way to obtain ip, it can be DHCP dynamic acquisition, or static manual configuration using static|BOOTPROTO=static| +|IPADDR|The ip address of the network card, when BOOTPROTO=static, this parameter will take effect |IPADDR=192.168.100.4| +|HWADDR|Hardware address, ie MAC address|HWADDR=00:0C:29:84:F6:9C| +|NETMASK|Decimal subnet mask|NETMASK=255.255.255.0| +|PREFIX|Subnet mask, represented by numbers|PREFIX=24| +|GATEWAY|Gateway, if there are multiple network cards, this parameter can only appear once |GATEWAY=192.168.100.1| +|PEERDNS|When it is yes, the DNS parameters defined here will modify /etc/resolv.conf; when it is no, /etc/resolv.conf will not be modified. When using DHCP, the default is yes|PEERDNS=yes| +|DNS1|The primary DNS is selected, it takes effect only when PEERDNS=no|DNS1=8.8.8.8| +|DNS2|Alternative DNS, only effective when PEERDNS=no|DNS2=114.114.114.114| +|BROWSER_ONLY|Whether to allow only browsers|BROWSER_ONLY=no| +|USERCTL|Whether ordinary users are allowed to control the network card device, yes means allow, no means not allowed |USERCTL=no| +|UUID|Universal unique identification code, the main function is to identify the hardware, generally speaking, it is not necessary to fill in|| +|PROXY_METHOD|Proxy method, generally none, can be left blank|| +|IPV4_FAILURE_FATAL|If it is yes, it means that the device will be disabled after ipv4 configuration fails; if it is no, it means it will not be disabled. |IPV4_FAILURE_FATAL=no| +|IPV6INIT|Whether to enable IPV6, yes to enable, no not to enable. When IPV6INIT=yes, the two parameters IPV6ADDR and IPV6_DEFAULTGW can also be enabled. The former represents the IPV6 address and the latter represents the designated gateway |IPV6INIT=yes| +|IPV6_AUTOCONF|Whether to use IPV6 automatic configuration, yes means use; no means not use |IPV6_AUTOCONF=yes| +|IPV6_DEFROUTE|Whether to give IPV6 the default route|IPV6_DEFROUTE=yes| +|IPV6_FAILURE_FATAL|After IPV6 configuration fails, whether to disable the device|IPV6_FAILURE_FATAL=no| +|IPV6_ADDR_GEN_MODE|Generate IPV6 address model, optional values ​​are stable-privacy and eui64|IPV6_ADDR_GEN_MODE=stable-privacy| + +After the configuration file is modified successfully, remember to restart the network card service `systemctl restart NetworkManager.service` + +### Recommended configuration for IPV4 + +```bash +TYPE=Ethernet +ONBOOT=yes +DEVICE=ens33 +USERCTL=no +IPV4_FAILURE_FATAL=no +BROWSER_ONLY=no +BOOTPROTO=static +PEERDNS=no +IPADDR=192.168.100.4 +PREFIX=24 +GATEWAY=192.168.100.1 +DNS1=8.8.8.8 +DNS2=114.114.114.114 +``` + +### Recommended configuration for IPV6 + +```bash +TYPE=Ethernet +ONBOOT=yes +DEVICE=ens33 +USERCTL=no +BROWSER_ONLY=no +IPV6INIT=yes +IPV6_AUTOCONF=yes +IPV6_DEFROUTE=yes +IPV6_FAILURE_FATAL=no +``` + +## View network information + +`ip a` or `nmcli device show` diff --git a/docs/gemstones/nmtui.zh.md b/docs/gemstones/nmtui.zh.md index 0921446b8b..72475c3cbc 100644 --- a/docs/gemstones/nmtui.zh.md +++ b/docs/gemstones/nmtui.zh.md @@ -1,12 +1,15 @@ --- -title - 快速更改网络信息 +title: nmtui - 网络管理工具 author: tianci li +contributors: Steven Spencer update: 2021-10-23 --- +# 引言 + 对于初次使用GNU/Linux的新手用户来说,最先考虑的事情是安装操作系统后如何让机器连接互联网。本篇将告诉您如何配置IP地址、子网掩码、网关以及DNS,有几种方式作为参考,不管是新手还是熟手,相信您都都能快速上手。 -# nmtui +## nmtui `NetworkManager`是标准 Linux 网络配置工具套件,支持服务器,也支持桌面环境,发展到如今,绝大多数流行的发行版都支持它。这套网络配置工具适用于 Rocky Linux 8 及更高版本,如果您希望图形化的方式配置网络信息(即命令行`nmtui`),只需要这么做: @@ -25,11 +28,11 @@ shell > nmtui 您可以使用 Tab键 或者 键的方式选择具体的功能,如果要更改网络信息,请选择 **Edit a connection** ,然后Enter键。选择不同的网卡,选择 **Edit..** 进行编辑。 -## DHCP的IPv4 +### DHCP的IPv4 针对IPv4,如果是使用DHCP的方式获取网络信息,则只需要选择 *IPv4 CONFIGURATION* 后面的 **\**,然后在您的终端中运行下`systemctl restart NetworkManager.service`,大多数的情况下都能生效,极少数的情况下需要开关网卡才能生效,例如这样的方式——`nmcli connection down ens33`,`nmcli connection up ens33` -## 手动固定网络信息 +### 手动固定网络信息 如果要将所有IPv4的网络信息进行手动固定,需要选择 *IPv4 CONFIGURATION* 后面的 **\**,一行一行进行添加,例如我这样的: @@ -41,7 +44,7 @@ shell > nmtui 然后点击 \ ,一步一步返回到终端界面,执行`systemctl restart NetworkManager.service` 即可。同样的,极少数的情况下需要开关网卡才能生效。 -# 更改配置文件的方式 +## 更改配置文件的方式 所有的RHEL发行版,不管是上游的还是下游的,都是一样的配置方式。网络信息的配置文件保存在 **/etc/sysconfig/network-scripts/** 目录下面,一个网卡对应一个配置文件。配置文件的参数非常的多,如下表所示。注意!参数一定要大写。 @@ -77,7 +80,7 @@ ifcfg-ens33 配置文件修改成功后,记得重启网卡服务`systemctl restart NetworkManager.service` -## IPV4的推荐配置 +### IPV4的推荐配置 ```bash TYPE=Ethernet @@ -95,7 +98,7 @@ DNS1=8.8.8.8 DNS2=114.114.114.114 ``` -## IPV6的推荐配置 +### IPV6的推荐配置 ```bash TYPE=Ethernet @@ -109,6 +112,6 @@ IPV6_DEFROUTE=yes IPV6_FAILURE_FATAL=no ``` -# 查看网络信息 +## 查看网络信息 `ip a`或者`nmcli device show`