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
linux使用vim编辑文件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 3192.168.10.10  ## 畅通
PING 192.168.10.10 (192.168.10.10) 56(84) bytes of data.
64 bytes from192.168.10.10: icmp_seq=1 ttl=64 time=0.035 ms
64 bytes from192.168.10.10: icmp_seq=2 ttl=64 time=0.040 ms
64 bytes from192.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

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。