CentOS7添加网卡

linux7添加网卡

博主本人平和谦逊,热爱学习,读者阅读过程中发现错误的地方,请帮忙指出,感激不尽


 

虚拟机添加网卡会遇到的问题:

使用VMware Workstation虚拟机安装好CentOS7虚拟机后,添加第二块网卡以后,进入CentOS 7系统后,看不到网卡配置文件。

解决方案:

  • 使用nmcli con show命令,查看网卡的UUID信息,记下UUID值
  • 使用ip addr命令查看网卡信息,记下ens35网卡的MAC地址(原配置文件没有这个内容,手动增加)
  • 将 /etc/sysconfig/network-scripts/目录中ifcfg-ens32文件复制一份,并命名为 ifcfg-ens35,重新修改配置文件,注意修改必要的硬件信息。
  • 最后重新启动网卡即可。

操作案例:添加ens35网卡,IP设置为192.168.247.231(先在虚拟机外面添加网卡):

1.查看HWDDR:

[root@system01 ~]# ip address 
…….
    link/ether 00:0c:29:b2:90:f9 brd ff:ff:ff:ff:ff:ff

2.查看UUID:

[root@system01 ~]# nmcli connection show 
NAME                UUID                                  TYPE      DEVICE 
…
Wired connection 2  80ce6376-8603-3c4b-8ee7-1432cebb924a  ethernet  ens35  

3.添加网卡配置

[root@system01 network-scripts]# cp -a ifcfg-ens32  ifcfg-ens35
修改ens35配置:
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
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=ens35
HWADDR=00:0c:29:b2:90:f9
UUID=80ce6376-8603-3c4b-8ee7-1432cebb924a
DEVICE=ens35
ONBOOT=yes
IPADDR=192.168.247.231
GATEWAY=192.168.247.2
DNS1=8.8.8.8
DNS2=8.8.4.4
PREFIX=24

4.重启与验证

[root@system01 ~]# service network restart
[root@system01 ~]# ifconfig ens35
ens35: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.247.231  netmask 255.255.255.0  broadcast 192.168.247.255
        inet6 fe80::8be8:ead6:ec47:e743  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:b2:90:f9  txqueuelen 1000  (Ethernet)
        RX packets 1065  bytes 128768 (125.7 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 532  bytes 98711 (96.3 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
[root@system01 ~]# 

如上,网卡添加完成!

如果虚拟机是最小化安装,一般的可以安装一些工具方便使用:

查看IP:
[root@localhost ~]# ip a  (或是:ip addr)
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens32: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:a8:58:94 brd ff:ff:ff:ff:ff:ff
    inet 192.168.247.12/24 brd 192.168.247.255 scope global noprefixroute ens32
       valid_lft forever preferred_lft forever
    inet6 fe80::59b6:8294:5009:8ceb/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
[root@localhost ~]# 

网络连通测试:
[root@localhost ~]# ping www.baidu.com
PING www.a.shifen.com (183.232.231.174) 56(84) bytes of data.
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=1 ttl=128 time=6.36 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=2 ttl=128 time=6.68 ms

安装wget:
[root@localhost ~]# yum install wget 
配置yum源:
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# mv C* yum_backup/
[root@localhost yum.repos.d]# wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
[root@localhost yum.repos.d]# yum clean all
或是:
[root@rhcsa ~]# yum-config-manager --add-repo="http://mirrors.163.com/.help/CentOS7-Base-163.repo"     

安装vim编辑器:
[root@localhost ~]# yum install vim -y
安装ifconfig:
[root@localhost ~]# yum install net-tools -y
安装bind-utils:
[root@localhost ~]# yum provides nslookup
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Warning: 3.0.x versions of yum would erroneously match against filenames.
 You can use "*/nslookup" and/or "*bin/nslookup" to get that behaviour
[root@localhost ~]# yum provides *bin/nslookup
[root@localhost ~]# yum install bind-utils -y
[root@localhost ~]# nslookup www.baidu.com  

[root@localhost yum.repos.d]# yum install openssh-clients-5.3p1-124.el6_10.x86_64 -y

转载需注明出处

上一篇:Linux 中如何使用 IP 命令


下一篇:Linux 中如何使用 IP 命令