Open bingoogolapple opened 7 years ago
1.跳转到 network-scripts 目录
➜ centosthree cd /etc/sysconfig/network-scripts/
➜ network-scripts
2.查看新网卡 MAC 地址,我这里是 eth1 的 08:00:27:15:bc:91
➜ network-scripts dmesg | grep -in eth
395:[ 1.701685] e1000 0000:00:03.0 eth0: (PCI:33MHz:32-bit) 08:00:27:57:fb:76
396:[ 1.701692] e1000 0000:00:03.0 eth0: Intel(R) PRO/1000 Network Connection
422:[ 2.069056] e1000 0000:00:08.0 eth1: (PCI:33MHz:32-bit) 08:00:27:15:bc:91
423:[ 2.069061] e1000 0000:00:08.0 eth1: Intel(R) PRO/1000 Network Connection
➜ network-scripts
3.为新网卡生成 UUID
➜ network-scripts uuidgen enp0s8
c75d2c52-2974-45f9-82c7-a14c95afef1f
➜ network-scripts
4.拷贝 ifcfg-enp0s3 命名为 ifcfg-enp0s8,并编辑
➜ network-scripts cp ifcfg-enp0s3 ifcfg-enp0s8
➜ network-scripts vim ifcfg-enp0s8
5.修改 ifcfg-enp0s8 中的「NAME」和「DEVICE」为 enp0s8 修改「BOOTPROTO」为 static 修改「UUID」为第3步中的 c75d2c52-2974-45f9-82c7-a14c95afef1f 新增「HWADDR」为第2步中的 08:00:27:15:bc:91 新增「IPADDR」为 192.168.56.223(改成你自己需要的 ip) 下面是配置完后的 ifcfg-enp0s8
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=enp0s8
UUID=c75d2c52-2974-45f9-82c7-a14c95afef1f
DEVICE=enp0s8
HWADDR=08:00:27:15:bc:91
IPADDR=192.168.56.223
ONBOOT=yes
DNS1=8.8.8.8
DNS2=8.8.4.4
6.先断开网卡 enp0s8
➜ network-scripts ifdown enp0s8
成功断开设备 'enp0s8'。
7.然后再激活网卡 enp0s8
➜ network-scripts ifup enp0s8
成功激活的连接(D-Bus 激活路径:/org/freedesktop/NetworkManager/ActiveConnection/2)
1.sudo vim /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto enp0s3
iface enp0s3 inet dhcp
# 下面这一段是需要新添加的
auto enp0s8
iface enp0s8 inet static
address 192.168.56.111
network 192.168.56.0
netmask 255.255.255.0
broadcast 192.168.56.255
2.重启网卡
sudo /etc/init.d/networking restart
NAT 方式配置端口转发,提供外部网络的连接
NAT 方式 CentOS 无法上网