当前位置:网站首页>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]#
此时就可以联网了。
边栏推荐
猜你喜欢
随机推荐
【Metaverse系列一】元宇宙的奥秘
CAD如何自定义快捷键
Weekly recommended short video: In order to fill the gap of learning resources, the author specially wrote a book?
星巴克输血赶不上流血
@resource和@autowired的区别
cell delay and net delay
【机器学习】机器学习基本概念/术语3
【云驻共创】【HCSD大咖直播】亲授大厂面试秘诀
leetcode-每日一题899. 有序队列(思维题)
【用户运营】用这4个最佳客户服务策略,减少客户流失率
【Deliberately practice the view of the back tube】deliberately practice
Web3 security risks daunting?How should we respond?
How to install and start VNC remote desktop service on cloud GPU?
isNotBlank与isNotEmpty
Trie思想及模板
分享 14 个你必须知道的 JS 函数
【保姆级示例向】观察者模式
Execution plan of mysql
CC2530_ZigBee+华为云IOT:设计一套属于自己的冷链采集系统
什么是鉴权?一篇文章带你了解postman的多种方式