linux系统中使用nmtui命令配置网络参数(图形用户界面)

      除了使用vim编辑器来配置网络参数,linux系统中至少有5种网络配置方法。

1、使用ifconfig命令获取当前网卡配置与网络状态等信息

[root@linuxprobe Desktop]# ifconfig   ## 未发现IP地址
eno16777728: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500  ## 网卡名称
        ether 00:0c:29:e4:f7:b9  txqueuelen 1000  (Ethernet)       ## 网卡物理地址
        RX packets 0  bytes 0 (0.0 B)                              ## 接收数据包及流量
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)                              ## 发送数据包及流量
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 642  bytes 51980 (50.7 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 642  bytes 51980 (50.7 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

 

2、查看网卡配置文件

[root@linuxprobe Desktop]# cd /etc/sysconfig/network-scripts/  ## 进入网卡配置文件所在目录
[root@linuxprobe network-scripts]# ls
ifcfg-eno16777728  ifdown-bnep  ifdown-ipv6  ifdown-ppp     ifdown-Team      ifup          ifup-eth   ifup-isdn   ifup-post    ifup-sit       ifup-tunnel       network-functions
ifcfg-lo           ifdown-eth   ifdown-isdn  ifdown-routes  ifdown-TeamPort  ifup-aliases  ifup-ippp  ifup-plip   ifup-ppp     ifup-Team      ifup-wireless     network-functions-ipv6
ifdown             ifdown-ippp  ifdown-post  ifdown-sit     ifdown-tunnel    ifup-bnep     ifup-ipv6  ifup-plusb  ifup-routes  ifup-TeamPort  init.ipv6-global
[root@linuxprobe network-scripts]# cat ifcfg-eno16777728 ## 查看当前网卡配置文件
HWADDR=00:0C:29:E4:F7:B9
TYPE=Ethernet
BOOTPROTO=dhcp
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=eno16777728
UUID=e72a626f-2946-4285-9edf-2f5a6b172712
ONBOOT=no

 

3、使用nmtui命令配置网络参数

[root@linuxprobe network-scripts]# nmtui  ## 执行nmtui命令弹出图形用户界面

选中Edit a connection,回车

 

 

 

选中网卡名称,选中Edit,回车

 

 

 

选中IPv4的Automatic,回车

 

 

 

 

选中Manual,回车

 

 

 

变成如下界面:

 

 

 

选中Show,回车

 

 

 

 

出现如下界面,选中Add,回车:

 

 

 

在Addresses后输入:192.168.10.10/24

 

 

 

选中OK,回车

 

 

 

选中Quit,回车退出

 

 

 

4、设置重启系统自动激活网卡

[root@linuxprobe network-scripts]# ls
ifcfg-eno16777728  ifdown-ippp  ifdown-routes    ifup          ifup-ipv6   ifup-ppp       ifup-tunnel
ifcfg-lo           ifdown-ipv6  ifdown-sit       ifup-aliases  ifup-isdn   ifup-routes    ifup-wireless
ifdown             ifdown-isdn  ifdown-Team      ifup-bnep     ifup-plip   ifup-sit       init.ipv6-global
ifdown-bnep        ifdown-post  ifdown-TeamPort  ifup-eth      ifup-plusb  ifup-Team      network-functions
ifdown-eth         ifdown-ppp   ifdown-tunnel    ifup-ippp     ifup-post   ifup-TeamPort  network-functions-ipv6
[root@linuxprobe network-scripts]# vim ifcfg-eno16777728 
TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=eno16777728
UUID=e72a626f-2946-4285-9edf-2f5a6b172712
ONBOOT=yes  ## 这里设置为yes
HWADDR=00:0C:29:E4:F7:B9
IPADDR0=192.168.10.10
PREFIX0=24
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes

 

5、手动重启网卡

[root@linuxprobe network-scripts]# systemctl restart network

 

6、ifconfig命令查看配置效果

[root@linuxprobe network-scripts]# ifconfig  ## 多出了IP地址
eno16777728: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.10.10  netmask 255.255.255.0  broadcast 192.168.10.255
        inet6 fe80::20c:29ff:fee4:f7b9  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:e4:f7:b9  txqueuelen 1000  (Ethernet)
        RX packets 3  bytes 729 (729.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 30  bytes 4291 (4.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 898  bytes 72716 (71.0 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 898  bytes 72716 (71.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

 

7、使用ping命令测试联通性

[root@linuxprobe network-scripts]# ping -c 3 192.168.10.10  ## 畅通
PING 192.168.10.10 (192.168.10.10) 56(84) bytes of data.
64 bytes from 192.168.10.10: icmp_seq=1 ttl=64 time=0.035 ms
64 bytes from 192.168.10.10: icmp_seq=2 ttl=64 time=0.040 ms
64 bytes from 192.168.10.10: icmp_seq=3 ttl=64 time=0.040 ms

--- 192.168.10.10 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2000ms
rtt min/avg/max/mdev = 0.035/0.038/0.040/0.005 ms

 

posted @ 2020-11-01 16:44  小鲨鱼2018  阅读(8639)  评论(0编辑  收藏  举报