RHEL7添加一张自定义网卡并更改网卡接口

本篇文章重点为大家讲解一下RHEL7添加一张自定义网卡并更改网卡接口具体方法,有需要的小伙伴可以参考一下。

环境

VMware Workstation Pro Red Hat Enterprise Linux Server release 7.3

查看当前网卡信息

[root@Jaking ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.3 (Maipo)
[root@Jaking ~]# ifconfig
ens33: flags=4163
  
     mtu 1500        inet 192.168.10.11  netmask 255.255.255.0  broadcast 192.168.10.255        inet6 fe80::250:56ff:fe2b:88bf  prefixlen 64  scopeid 0x20        ether 00:50:56:2b:88:bf  txqueuelen 1000  (Ethernet)        RX packets 454  bytes 44638 (43.5 KiB)        RX errors 0  dropped 0  overruns 0  frame 0        TX packets 339  bytes 33150 (32.3 KiB)        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0 lo: flags=73
   
      mtu 65536        inet 127.0.0.1  netmask 255.0.0.0        inet6 ::1  prefixlen 128  scopeid 0x10        loop  txqueuelen 1  (Local Loopback)        RX packets 112  bytes 9492 (9.2 KiB)        RX errors 0  dropped 0  overruns 0  frame 0        TX packets 112  bytes 9492 (9.2 KiB)        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0 
   
  

添加网卡

取消红框内的钩

查看网卡信息

[root@Jaking ~]# ifconfig
ens33: flags=4163
  
     mtu 1500        inet 192.168.10.11  netmask 255.255.255.0  broadcast 192.168.10.255        inet6 fe80::250:56ff:fe2b:88bf  prefixlen 64  scopeid 0x20        ether 00:50:56:2b:88:bf  txqueuelen 1000  (Ethernet)        RX packets 488  bytes 47935 (46.8 KiB)        RX errors 0  dropped 0  overruns 0  frame 0        TX packets 356  bytes 35698 (34.8 KiB)        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0 ens38: flags=4163
   
      mtu 1500        ether 00:0c:29:46:f9:b8  txqueuelen 1000  (Ethernet)        RX packets 5  bytes 594 (594.0 B)        RX errors 0  dropped 0  overruns 0  frame 0        TX packets 0  bytes 0 (0.0 B)        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0 lo: flags=73
    
       mtu 65536        inet 127.0.0.1  netmask 255.0.0.0        inet6 ::1  prefixlen 128  scopeid 0x10        loop  txqueuelen 1  (Local Loopback)        RX packets 112  bytes 9492 (9.2 KiB)        RX errors 0  dropped 0  overruns 0  frame 0        TX packets 112  bytes 9492 (9.2 KiB)        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0 
    
   
  

配置网卡并更改网卡接口

[root@Jaking ~]# cd /etc/sysconfig/network-scripts/
[root@Jaking network-scripts]# ls
ifcfg-ens33  ifdown-ipv6    ifdown-TeamPort  ifup-ippp   ifup-routes       network-functions
ifcfg-lo     ifdown-isdn    ifdown-tunnel    ifup-ipv6   ifup-sit          network-functions-ipv6
ifdown       ifdown-post    ifup             ifup-isdn   ifup-Team
ifdown-bnep  ifdown-ppp     ifup-aliases     ifup-plip   ifup-TeamPort
ifdown-eth   ifdown-routes  ifup-bnep        ifup-plusb  ifup-tunnel
ifdown-ib    ifdown-sit     ifup-eth         ifup-post   ifup-wireless
ifdown-ippp  ifdown-Team    ifup-ib          ifup-ppp    init.ipv6-global

添加网卡后,需要创建对应的网卡配置文件

[root@Jaking network-scripts]# cp ifcfg-ens33 ifcfg-ens34
[root@Jaking network-scripts]# vim ifcfg-ens34          
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
NAME=ens34
DEVICE=ens34
ONBOOT=yes
IPADDR=172.16.100.100
NETMASK=255.255.255.0          

禁用ens38接口

[root@Jaking network-scripts]# ip link set ens38 down  
[root@Jaking network-scripts]# ifconfig
ens33: flags=4163
  
     mtu 1500        inet 192.168.10.11  netmask 255.255.255.0  broadcast 192.168.10.255        inet6 fe80::250:56ff:fe2b:88bf  prefixlen 64  scopeid 0x20        ether 00:50:56:2b:88:bf  txqueuelen 1000  (Ethernet)        RX packets 812  bytes 74791 (73.0 KiB)        RX errors 0  dropped 0  overruns 0  frame 0        TX packets 537  bytes 61780 (60.3 KiB)        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0 lo: flags=73
   
      mtu 65536        inet 127.0.0.1  netmask 255.0.0.0        inet6 ::1  prefixlen 128  scopeid 0x10        loop  txqueuelen 1  (Local Loopback)        RX packets 112  bytes 9492 (9.2 KiB)        RX errors 0  dropped 0  overruns 0  frame 0        TX packets 112  bytes 9492 (9.2 KiB)        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0 
   
  

重命名ens38接口为ens34

[root@Jaking network-scripts]# ip link set ens38 name ens34

启用修改完成的ens34接口

[root@Jaking network-scripts]# ip link set ens34 up        
             
[root@Jaking network-scripts]# systemctl restart network
[root@Jaking network-scripts]# ifconfig                
ens33: flags=4163
  
     mtu 1500        inet 192.168.10.11  netmask 255.255.255.0  broadcast 192.168.10.255        inet6 fe80::250:56ff:fe2b:88bf  prefixlen 64  scopeid 0x20        ether 00:50:56:2b:88:bf  txqueuelen 1000  (Ethernet)        RX packets 1389  bytes 123239 (120.3 KiB)        RX errors 0  dropped 0  overruns 0  frame 0        TX packets 913  bytes 117924 (115.1 KiB)        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0 ens34: flags=4163
   
      mtu 1500        inet 172.16.100.100  netmask 255.255.255.0  broadcast 192.168.100.255        ether 00:0c:29:46:f9:b8  txqueuelen 1000  (Ethernet)        RX packets 5  bytes 594 (594.0 B)        RX errors 0  dropped 0  overruns 0  frame 0        TX packets 2  bytes 120 (120.0 B)        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0 lo: flags=73
    
       mtu 65536        inet 127.0.0.1  netmask 255.0.0.0        inet6 ::1  prefixlen 128  scopeid 0x10        loop  txqueuelen 1  (Local Loopback)        RX packets 148  bytes 12552 (12.2 KiB)        RX errors 0  dropped 0  overruns 0  frame 0        TX packets 148  bytes 12552 (12.2 KiB)        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0 
    
   
  

文章来源网络,作者:运维,如若转载,请注明出处:https://shuyeidc.com/wp/220352.html<

(0)
运维的头像运维
上一篇2025-04-14 13:01
下一篇 2025-04-14 13:02

相关推荐

  • 瑞典荷兰hosthatchVPS测评,hosthatchVPS怎么样?hosthatchVPS测评

    在 2026 年,若追求极致性价比与欧洲低延迟,瑞典 HostHatch VPS 是建站首选,而荷兰节点则在数据隐私与抗 DDoS 能力上略胜一筹,具体选择需结合业务落地地域与合规需求,HostHatch 2026 核心架构与性能实测随着 2026 年全球数据中心向绿色能源与 NVMe 全闪存架构转型,Host……

    2026-05-02
    0
  • CloudCone VPS测评,2美元/月性能如何?CloudCone VPS测评怎么样

    CloudCone 2 美元/月 VPS 实测结论:该方案在 2026 年仍具备极高的性价比,适合个人开发者搭建轻量级应用或学习 Linux 环境,但受限于共享带宽与 I/O 性能,不建议用于高并发生产环境或大型数据库服务,在 2026 年的 VPS 市场中,CloudCone 依然以其极低的入门门槛占据着特定……

    2026-05-02
    0
  • justhostVPS测评怎么样?justhostVPS测评真实体验

    justhostVPS 在 2026 年依然具备极高的性价比,特别适合预算有限但追求稳定性的中小型建站需求,其核心优势在于价格亲民与基础性能扎实,但在高端 I/O 性能上略逊于顶级云厂商,在 2026 年云计算市场高度内卷的背景下,justhostVPS 凭借其独特的“高性价比”定位,依然是许多站长和开发者在构……

    2026-05-02
    0
  • justhostVPS测评靠谱吗,justhostVPS真实性能怎么样

    2026 年实测结论:justhost VPS 以 1.74 美元/月的极致性价比,在轻量级建站与边缘计算场景下表现优异,但受限于共享带宽与单核性能,不适合高并发企业级应用,在 2026 年云计算市场格局中,justhost VPS 核心性能实测与定位分析随着全球算力成本波动,74 美元/月价格带下的真实吞吐能……

    2026-05-02
    0
  • HostSailor独立服务器测评,HostSailor独立服务器怎么样

    HostSailor 独立服务器在 2026 年实测中展现出卓越的高频交易承载能力与低延迟特性,是构建高性能金融级应用与海外跨境电商业务的理想选择,其性价比在同等配置下优于主流竞品,在云计算资源日益碎片化的 2026 年,企业对于独立服务器租用的需求已从单纯的“资源获取”转向“性能确定性”,HostSailor……

    2026-05-02
    0

发表回复

您的邮箱地址不会被公开。必填项已用 * 标注