LinuxProbe 发表于 2021-4-14 22:12:41

Linux系统自定义网卡并更改网卡接口


本文档详细介绍给RHEL7添加一张自定义网卡并更改网卡接口的方法
环境
VMware Workstation Pro
Red Hat Enterprise Linux Server release 7.3查看当前网卡信息
# cat /etc/redhat-release Red Hat Enterprise Linux Server release 7.3 (Maipo)# ifconfigens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>mtu 1500      inet 192.168.10.11netmask 255.255.255.0broadcast 192.168.10.255      inet6 fe80::250:56ff:fe2b:88bfprefixlen 64scopeid 0x20      ether 00:50:56:2b:88:bftxqueuelen 1000(Ethernet)      RX packets 454bytes 44638 (43.5 KiB)      RX errors 0dropped 0overruns 0frame 0      TX packets 339bytes 33150 (32.3 KiB)      TX errors 0dropped 0 overruns 0carrier 0collisions 0lo: flags=73<UP,LOOPBACK,RUNNING>mtu 65536      inet 127.0.0.1netmask 255.0.0.0      inet6 ::1prefixlen 128scopeid 0x10      looptxqueuelen 1(Local Loopback)      RX packets 112bytes 9492 (9.2 KiB)      RX errors 0dropped 0overruns 0frame 0      TX packets 112bytes 9492 (9.2 KiB)      TX errors 0dropped 0 overruns 0carrier 0collisions 0添加网卡
https://www.linuxprobe.com/wp-content/uploads/2020/04/1-25.pnghttps://www.linuxprobe.com/wp-content/uploads/2020/04/2-14.pnghttps://www.linuxprobe.com/wp-content/uploads/2020/04/3-6.png取消红框内的钩
https://www.linuxprobe.com/wp-content/uploads/2020/04/4-6.pnghttps://www.linuxprobe.com/wp-content/uploads/2020/04/5-5.pnghttps://www.linuxprobe.com/wp-content/uploads/2020/04/6-4.pnghttps://www.linuxprobe.com/wp-content/uploads/2020/04/7-3.pnghttps://www.linuxprobe.com/wp-content/uploads/2020/04/8-2.png查看网卡信息
# ifconfigens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>mtu 1500      inet 192.168.10.11netmask 255.255.255.0broadcast 192.168.10.255      inet6 fe80::250:56ff:fe2b:88bfprefixlen 64scopeid 0x20      ether 00:50:56:2b:88:bftxqueuelen 1000(Ethernet)      RX packets 488bytes 47935 (46.8 KiB)      RX errors 0dropped 0overruns 0frame 0      TX packets 356bytes 35698 (34.8 KiB)      TX errors 0dropped 0 overruns 0carrier 0collisions 0ens38: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>mtu 1500      ether 00:0c:29:46:f9:b8txqueuelen 1000(Ethernet)      RX packets 5bytes 594 (594.0 B)      RX errors 0dropped 0overruns 0frame 0      TX packets 0bytes 0 (0.0 B)      TX errors 0dropped 0 overruns 0carrier 0collisions 0lo: flags=73<UP,LOOPBACK,RUNNING>mtu 65536      inet 127.0.0.1netmask 255.0.0.0      inet6 ::1prefixlen 128scopeid 0x10      looptxqueuelen 1(Local Loopback)      RX packets 112bytes 9492 (9.2 KiB)      RX errors 0dropped 0overruns 0frame 0      TX packets 112bytes 9492 (9.2 KiB)      TX errors 0dropped 0 overruns 0carrier 0collisions 0配置网卡并更改网卡接口
# cd /etc/sysconfig/network-scripts/# lsifcfg-ens33ifdown-ipv6    ifdown-TeamPortifup-ippp   ifup-routes       network-functionsifcfg-lo   ifdown-isdn    ifdown-tunnel    ifup-ipv6   ifup-sit          network-functions-ipv6ifdown       ifdown-post    ifup             ifup-isdn   ifup-Teamifdown-bnepifdown-ppp   ifup-aliases   ifup-plip   ifup-TeamPortifdown-eth   ifdown-routesifup-bnep      ifup-plusbifup-tunnelifdown-ib    ifdown-sit   ifup-eth         ifup-post   ifup-wirelessifdown-ipppifdown-Team    ifup-ib          ifup-ppp    init.ipv6-global添加网卡后,需要创建对应的网卡配置文件
# cp ifcfg-ens33 ifcfg-ens34 # vim ifcfg-ens34          TYPE=EthernetBOOTPROTO=staticDEFROUTE=yesPEERDNS=yesPEERROUTES=yesIPV4_FAILURE_FATAL=noNAME=ens34DEVICE=ens34ONBOOT=yesIPADDR=172.16.100.100NETMASK=255.255.255.0          禁用ens38接口
# ip link set ens38 down# ifconfigens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>mtu 1500      inet 192.168.10.11netmask 255.255.255.0broadcast 192.168.10.255      inet6 fe80::250:56ff:fe2b:88bfprefixlen 64scopeid 0x20      ether 00:50:56:2b:88:bftxqueuelen 1000(Ethernet)      RX packets 812bytes 74791 (73.0 KiB)      RX errors 0dropped 0overruns 0frame 0      TX packets 537bytes 61780 (60.3 KiB)      TX errors 0dropped 0 overruns 0carrier 0collisions 0lo: flags=73<UP,LOOPBACK,RUNNING>mtu 65536      inet 127.0.0.1netmask 255.0.0.0      inet6 ::1prefixlen 128scopeid 0x10      looptxqueuelen 1(Local Loopback)      RX packets 112bytes 9492 (9.2 KiB)      RX errors 0dropped 0overruns 0frame 0      TX packets 112bytes 9492 (9.2 KiB)      TX errors 0dropped 0 overruns 0carrier 0collisions 0重命名ens38接口为ens34
# ip link set ens38 name ens34启用修改完成的ens34接口
# ip link set ens34 up                      # systemctl restart network# ifconfig               ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>mtu 1500      inet 192.168.10.11netmask 255.255.255.0broadcast 192.168.10.255      inet6 fe80::250:56ff:fe2b:88bfprefixlen 64scopeid 0x20      ether 00:50:56:2b:88:bftxqueuelen 1000(Ethernet)      RX packets 1389bytes 123239 (120.3 KiB)      RX errors 0dropped 0overruns 0frame 0      TX packets 913bytes 117924 (115.1 KiB)      TX errors 0dropped 0 overruns 0carrier 0collisions 0ens34: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>mtu 1500      inet 172.16.100.100netmask 255.255.255.0broadcast 192.168.100.255      ether 00:0c:29:46:f9:b8txqueuelen 1000(Ethernet)      RX packets 5bytes 594 (594.0 B)      RX errors 0dropped 0overruns 0frame 0      TX packets 2bytes 120 (120.0 B)      TX errors 0dropped 0 overruns 0carrier 0collisions 0lo: flags=73<UP,LOOPBACK,RUNNING>mtu 65536      inet 127.0.0.1netmask 255.0.0.0      inet6 ::1prefixlen 128scopeid 0x10      looptxqueuelen 1(Local Loopback)      RX packets 148bytes 12552 (12.2 KiB)      RX errors 0dropped 0overruns 0frame 0      TX packets 148bytes 12552 (12.2 KiB)      TX errors 0dropped 0 overruns 0carrier 0collisions 0总结
以上就是给RHEL7添加一张自定义网卡并更改网卡接口的方法,希望能帮助到大家!

wjlovezzd 发表于 2021-4-15 07:42:49

{:6_267:}{:6_267:}{:6_267:}{:6_267:}{:6_267:}{:6_267:}{:6_267:}{:6_267:}

邦德猪 发表于 2021-4-15 09:28:08

顶一个
页: [1]
查看完整版本: Linux系统自定义网卡并更改网卡接口