云服务器CentOS8 Stream 网卡配置操作

[复制链接] |主动推送
查看37 | 回复0 | 2024-9-11 17:54:22 | 显示全部楼层 |阅读模式
CentOS8 Stream 网卡配置操作
CentOS8  已废弃network.service,网卡操作需要使用nmcli ,当前整理配置文件操作及相关命令
命令:nmcli
配置文件:/etc/sysconfig/network-scripts/ifcfg-eth0配置单个ipv4地址
IP:60.247.159.221    掩码:255.255.255.0     网关:60.247.159.1
[root@ebs-113436 ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0

# 申明网卡eth0
DEVICE=eth0
BOOTPROTO=static
IPADDR=60.247.159.221
NETMASK=255.255.255.0
GATEWAY=60.247.159.1
TYPE=Ethernet
ONBOOT=yes配置多个ipv4地址
IP1:60.247.159.221  掩码1:255.255.255.0  网关1:60.247.159.152
IP2:60.247.159.221  掩码2:255.255.255.0
多ip配置一般只需要配置一个GATEWAY0 网关即可
[root@ebs-113436 ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0

# 申明网卡eth0
DEVICE=eth0
BOOTPROTO=static
TYPE=Ethernet
ONBOOT=yes
IPADDR0=60.247.159.221
IPADDR1=60.247.159.152
NETMASK0=255.255.255.0
NETMASK1=255.255.255.0
.
.
.
.
.
.
GATEWAY0=60.247.159.1
几个依此添加即可,如果ip较多,一个IP段添加。
先通过http://tool.520101.com/wangluo/ipjisuan/ 计算ip地址
154542uwz883hnjtkj3zqz.png


获取到第一个和最后一个可用ip尾数为193和254,以及掩码255.255.255.192,并注意服务器上网络连接名称,加入
for I in $(seq 193 254); do nmcli con mod eth0 +ipv4.addresses 192.168.1.${I}/26; done

单个ipv6配置
ipv4:60.247.159.221     掩码:255.255.255.0    网关:60.247.159.1
ipv6:240E:D9:C200:160:9404::1A80   掩码位数:64   网关:240e:d9:c200:160::1
[root@ebs-113436 ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0

# 申明网卡eth0
DEVICE=eth0
BOOTPROTO=static
IPADDR=60.247.159.221
NETMASK=255.255.255.0
GATEWAY=60.247.159.1
TYPE=Ethernet
ONBOOT=yes
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6ADDR=240E:D9:C200:160:9404::1A80/64
IPV6_DEFAULTGW=240e:d9:c200:160::1多个ipv6配置
ipv4:60.247.159.221     掩码:255.255.255.0    网关:60.247.159.1
ipv6:240E:D9:C200:160:9404::1A80-240E:D9:C200:160:9404::1a9f   掩码位数:64   网关:240e:d9:c200:160::1
[root@ebs-113436 ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0

# 申明网卡eth0
DEVICE=eth0
BOOTPROTO=static
IPADDR=60.247.159.221
NETMASK=255.255.255.0
GATEWAY=60.247.159.1
TYPE=Ethernet
ONBOOT=yes
# IPV6配置
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6ADDR=240E:D9:C200:160:9404::1A80/64
IPV6_DEFAULTGW=240e:d9:c200:160::1
# 多IPV6配置  用空格分开
IPV6ADDR_SECONDARIES="240E:D9:C200:160:9404::1a80/64  240E:D9:C200:160:9404::1a81/64  240E:D9:C200:160:9404::1a82/64  240E:D9:C200:160:9404::1a83/64  240E:D9:C200:160:9404::1a84/64  240E:D9:C200:160:9404::1a85/64  240E:D9:C200:160:9404::1a86/64  240E:D9:C200:160:9404::1a87/64  240E:D9:C200:160:9404::1a88/64  240E:D9:C200:160:9404::1a89/64  240E:D9:C200:160:9404::1a8a/64  240E:D9:C200:160:9404::1a8b/64  240E:D9:C200:160:9404::1a8c/64  240E:D9:C200:160:9404::1a8d/64  240E:D9:C200:160:9404::1a8e/64  240E:D9:C200:160:9404::1a8f/64  240E:D9:C200:160:9404::1a90/64  240E:D9:C200:160:9404::1a91/64  240E:D9:C200:160:9404::1a92/64  240E:D9:C200:160:9404::1a93/64  240E:D9:C200:160:9404::1a94/64  240E:D9:C200:160:9404::1a95/64  240E:D9:C200:160:9404::1a96/64  240E:D9:C200:160:9404::1a97/64  240E:D9:C200:160:9404::1a98/64  240E:D9:C200:160:9404::1a99/64  240E:D9:C200:160:9404::1a9a/64  240E:D9:C200:160:9404::1a9b/64  240E:D9:C200:160:9404::1a9c/64  240E:D9:C200:160:9404::1a9d/64  240E:D9:C200:160:9404::1a9e/64  240E:D9:C200:160:9404::1a9f/64"
ipv6 批量配置教程https://www.west.cn/faq/list.asp?unid=2276


以上配置后需要重启网卡生效;

网卡服务重启
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则