当前位置:网站首页>rhel8.3 系统下修改有线网卡配置信息实现联网
rhel8.3 系统下修改有线网卡配置信息实现联网
2022-08-03 17:45:00 【多于少的区别】
rhel8.3 系统下修改有线网卡配置信息实现联网
问题描述:
因为之前实验的原因,宿主机的有线网卡ip被修改了,导致无法上网,需要重新配置有线网卡信息来实现联网。
问题解决:
1.查找宿主机所在局域网中空闲的IP
首先可以通过将网卡设置为DHCP模式,获取所在局域网的路由器分配的空闲IP地址。
[[email protected] network-scripts]# pwd
/etc/sysconfig/network-scripts
[[email protected] network-scripts]# cat ifcfg-enp6s0f4u2u1
NAME=enp6s0f4u2u1
DEVICE=enp6s0f4u2u1
ONBOOT=yes
BOOTPROTO=dhcp
[[email protected] network-scripts]# nmcli connection reload
[[email protected] network-scripts]# nmcli connection down enp6s0f4u2u1
Connection 'enp6s0f4u2u1' successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/15)
[[email protected] network-scripts]# nmcli connection up enp6s0f4u2u1
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/16)
[[email protected] network-scripts]# ip addr show enp6s0f4u2u1
2: enp6s0f4u2u1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 2c:16:db:a5:e3:e2 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.27/24 brd 192.168.1.255 scope global dynamic noprefixroute enp6s0f4u2u1
valid_lft 86394sec preferred_lft 86394sec
[[email protected] network-scripts]#
## 2.将IP通过nmcli命令工具生存ifcfg配置文件,设置为静态IP
两种方式:
1)方式一:nmcli modify直接修改
[[email protected] network-scripts]# nmcli connection modify enp6s0f4u2u1 con-name enp6s0f4u2u1 ifname enp6s0f4u2u1 ipv4.method manual ipv4.addresses 192.168.1.27/24 ipv4.gateway 192.168.1.1 ipv4.dns 114.114.114.114
[[email protected] network-scripts]# nmcli connection down enp6s0f4u2u1
Connection 'enp6s0f4u2u1' successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/17)
[[email protected] network-scripts]# nmcli connection up enp6s0f4u2u1
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/18)
[[email protected] network-scripts]#
[[email protected] network-scripts]# cat ifcfg-enp6s0f4u2u1
NAME=enp6s0f4u2u1
DEVICE=enp6s0f4u2u1
ONBOOT=yes
BOOTPROTO=none
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
IPADDR=192.168.1.27
PREFIX=24
GATEWAY=192.168.1.1
DNS1=114.114.114.114
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=no
UUID=3fb4a032-24a9-637d-d7a8-15a0744daa71
2)方式二:删除ifcfg文件,再通过nmcli命令添加
[[email protected] network-scripts]# rm -f ifcfg-enp6s0f4u2u1
[[email protected] network-scripts]# nmcli connection add con-name enp6s0f4u2u1 ifname enp6s0f4u2u1 ipv4.method manual ipv4.addresses 192.168.1.27/24 ipv4.gateway 192.168.1.1 ipv4.dns 114.114.114.114 type ethernet
Warning: There is another connection with the name 'enp6s0f4u2u1'. Reference the connection by its uuid 'baba6b0a-f1db-4e23-b120-dd8336227a54'
Connection 'enp6s0f4u2u1' (baba6b0a-f1db-4e23-b120-dd8336227a54) successfully added.
[[email protected] network-scripts]# nmcli connection reload
[[email protected] network-scripts]# nmcli connection down enp6s0f4u2u1
Connection 'enp6s0f4u2u1' successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/19)
[[email protected] network-scripts]# nmcli connection up enp6s0f4u2u1
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/20)
[[email protected] network-scripts]# cat ifcfg-enp6s0f4u2u1-1
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
IPADDR=192.168.1.27
PREFIX=24
GATEWAY=192.168.1.1
DNS1=114.114.114.114
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=enp6s0f4u2u1
UUID=baba6b0a-f1db-4e23-b120-dd8336227a54
DEVICE=enp6s0f4u2u1
ONBOOT=yes
[[email protected] network-scripts]#
此时就可以联网了。
边栏推荐
猜你喜欢
随机推荐
图像传感第一章学习心得
Discuz新闻资讯GBK模板
你想知道的 Watch App 开发
论文解读(JKnet)《Representation Learning on Graphs with Jumping Knowledge Networks》
软件测试<进阶篇-->测试分类>
高效的组织信息共享知识库是一种宝贵的资源
一加Ace值得买吗?用实力诠释性能的强大
【指针初解】
es6新增-Generator(异步编程的解决方案2)
CC2530_ZigBee+华为云IOT:设计一套属于自己的冷链采集系统
【技术白皮书】第一章:OCR智能文字识别新发展——深度学习的文本信息抽取
【用户运营】用这4个最佳客户服务策略,减少客户流失率
WPF 实现柱形统计图
opencv 直方图比较
关于 Intel 在 micro-vm 快速启动的探索及实例演示 | 第 36-38 期
mysql之数据库账户管理与优化
341. Flatten Nested List Iterator
mysql之的执行计划
PTA递归练习
select......for update 语句的功能是什么? 会锁表还是锁行?