本文最后更新于 319 天前,其中的信息可能已经过时,如有错误请发送邮件到wuxianglongblog@163.com
nmtui命令
使用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