VirtualBox下为Ubuntu虚机添加第二块网卡
发布时间:2020-07-09 05:18:54  所属栏目:Ubuntu  来源:互联网 
            导读:问题描述 因为做Docker网络实验,需要将原先Ubuntu虚机的一块“桥接”网卡改为“HostOnly”网卡,并且添加另一块“NAT”网卡。几经周折发现只有第一块网卡可以正确配置,ifconfig里根本看不到有第二块网卡。 查找问题 于是上网找了找,找到了一个CentOS虚机的
                
                
                
            
                        问题描述因为做Docker网络实验,需要将原先Ubuntu虚机的一块“桥接”网卡改为“HostOnly”网卡,并且添加另一块“NAT”网卡。几经周折发现只有第一块网卡可以正确配置, 查找问题于是上网找了找,找到了一个CentOS虚机的,不太适用,但思路大概有了,就继续往下搜,找到了Ubuntu的一篇文章。试了试,发现有点门路。 但我的网络设备不是“eth0”,而是“enp0s3”,于是 解决步骤我的解决步骤: 
 schen@scvmu01:/sys/class/net$ ls docker0 enp0s3 enp0s8 lo 
 schen@scvmu01:~$ sudo vi /etc/network/interfaces [sudo] password for schen: # 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 # The user added network interface auto enp0s8 iface enp0s8 inet dhcp ~ ~ (照猫画虎添加最后三行内容) 
 schen@scvmu01:~$ sudo ifup enp0s8 Internet Systems Consortium DHCP Client 4.3.3 Copyright 2004-2015 Internet Systems Consortium. All rights reserved. For info,please visit https://www.isc.org/software/dhcp/ Listening on LPF/enp0s8/08:00:27:13:1e:58 Sending on LPF/enp0s8/08:00:27:13:1e:58 Sending on Socket/fallback DHCPDISCOVER on enp0s8 to 255.255.255.255 port 67 interval 3 (xid=0xee28051e) DHCPREQUEST of 192.168.56.103 on enp0s8 to 255.255.255.255 port 67 (xid=0x1e0528ee) DHCPOFFER of 192.168.56.103 from 192.168.56.100 DHCPACK of 192.168.56.103 from 192.168.56.100 bound to 192.168.56.103 -- renewal in 514 seconds. schen@scvmu01:~$ 
 schen@scvmu01:~$ ifconfig enp0s8
enp0s8    Link encap:Ethernet  HWaddr 08:00:27:13:1e:58  
          inet addr:192.168.56.103  Bcast:192.168.56.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe13:1e58/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:18 errors:0 dropped:0 overruns:0 frame:0
          TX packets:58 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:3073 (3.0 KB)  TX bytes:8585 (8.5 KB)
schen@scvmu01:~$  
 
 schen@scvmu01:~$ sudo reboot 参考文章这篇文章给我提供了思路:  CentOS的同学可以参考这篇文章:  鸣谢以上文章作者! (编辑:莱芜站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!  | 
                  
