在 CentOS Minimal(最小化安装) 中,默认没有图形界面,网络需要手动配置。下面按常见场景给你一套 通用、可操作的联网方法。
ip addr
或旧版本:
ifconfig
如果能看到 eth0、ens33、enp0s3 之类的网卡,说明驱动正常。
CentOS 7/8/Stream 默认使用 NetworkManager。
nmcli device status
nmcli connection show
一般类似:
ens33 ethernet connected
nmcli connection up ens33
或:
nmcli connection modify ens33 ipv4.method auto
nmcli connection up ens33
测试网络:
ping -c 3 www.baidu.com
✅ 如果能 ping 通,说明已联网。
nmcli connection modify ens33 \
ipv4.method manual \
ipv4.addresses 192.168.1.100/24 \
ipv4.gateway 192.168.1.1 \
ipv4.dns "8.8.8.8 114.114.114.114"
nmcli connection up ens33
适用于 CentOS 7 Minimal
vi /etc/sysconfig/network-scripts/ifcfg-ens33
BOOTPROTO=dhcp
ONBOOT=yes
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.1.100
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=8.8.8.8
DNS2=114.114.114.114
systemctl restart network
⚠️ CentOS 8 已移除 network 服务
nmcli networking on
nmcli connection up ens33
确保:
nslookup www.baidu.com
或:
cat /etc/resolv.conf
ip route
ip addr
nmcli device status
journalctl -xe
你可以直接告诉我:
ip addr 的输出截图或文字我可以一步一步帮你把网络配好 ✅