首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Ubuntu 16.04 LTS与虚拟接口

Ubuntu 16.04 LTS与虚拟接口
EN

Ask Ubuntu用户
提问于 2019-06-05 10:34:27
回答 2查看 2.1K关注 0票数 1

嗨,尝试了不同的谷歌搜索建议。

至于今天,我有:

描述:Ubuntu16.04.6 LTS发行版: 16.04代码: xenial

更新为昨天

试图使:

代码语言:javascript
运行
复制
sudo ip address add 192.168.0.7/24 dev enz3   ;  
sudo ip address add 192.168.0.8/24 dev enz3

永久的

我将etc/network/interfaces文件修改为:

代码语言:javascript
运行
复制
 # interfaces(5) file used by ifup(8) and ifdown(8)
auto lo 
iface lo inet loopback


iface enz3 inet static
address 192.168.0.2
netmask 255.255.255.0
gateway 192.168.0.1


auto enz3:1
allow-hotplug enz3:1
iface enz3:1 inet static
address 192.168.0.7
netmask 255.255.255.0
gateway 192.168.0.1

auto enz3:2
allow-hotplug enz3:2
iface enz3:2 inet static
address 192.168.0.8
netmask 255.255.255.0
gateway 192.168.0.1

然后重新启动网络服务。

代码语言:javascript
运行
复制
systemctl restart networking

我收到一个错误:

代码语言:javascript
运行
复制
xx@xx-VBox:~$ systemctl status  networking.service
networking.service - Raise network interfaces
   Loaded: loaded (/lib/systemd/system/networking.service; enabled; vendor preset: enabled)

Drop-In: /run/systemd/generator/networking.service.d
           └─50-insserv.conf-$network.conf
 Active: failed (Result: exit-code) since mer 2019-06-05 12:15:39 CEST; 5s ago
     Docs: man:interfaces(5)
Process: 4423 ExecStop=/sbin/ifdown -a --read-environment --exclude=lo (code=exited, status=0/SUCCESS)
Process: 4963 ExecStart=/sbin/ifup -a --read-environment (code=exited, status=1/FAILURE)
Process: 4959 ExecStartPre=/bin/sh -c [ "$CONFIGURE_INTERFACES" != "no" ] && [ -n "$(ifquery --read-environment --list --exclu
Main PID: 4963 (code=exited, status=1/FAILURE)

giu 05 12:15:38 xx-VBox systemd[1]: Starting Raise network interfaces...
giu 05 12:15:38 xx-VBox ifup[4963]: RTNETLINK answers: File exists
giu 05 12:15:38 xx-VBox ifup[4963]: Failed to bring up enz3:2.
giu 05 12:15:39 xx-VBox systemd[1]: networking.service: Main process exited, code=exited, status=1/FAILURE
giu 05 12:15:39 xx-VBox systemd[1]: Failed to start Raise network interfaces.
giu 05 12:15:39 xx-VBox systemd[1]: networking.service: Unit entered failed state.
giu 05 12:15:39 xx-VBox systemd[1]: networking.service: Failed with result 'exit-code'.

但尽管如此

代码语言:javascript
运行
复制
ip addr

显示

代码语言:javascript
运行
复制
 enz3:  mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    inet 192.168.0.2/24 brd 192.168.0.255 scope global enz3
       valid_lft forever preferred_lft forever
    inet 192.168.0.7/24 brd 192.168.0.255 scope global secondary enz3:1
       valid_lft forever preferred_lft forever
    inet 192.168.0.8/24 brd 192.168.0.255 scope global secondary enz3:2
       valid_lft forever preferred_lft forever
    inet6 XXXXXXXXXXXXXXXXXXXXXXXXXX scope link 
       valid_lft forever preferred_lft forever

代码语言:javascript
运行
复制
ifconfig

显示

代码语言:javascript
运行
复制
  enz3

  enz3:1

  enz3:2

我能够连接和可视化apache2 index.html

来自于192.168.0.2地址的默认for服务器

对于两个虚拟主机,分别为192.168.0.7和192.168.0.8

我错过了什么?我为什么要犯这个错误?其他的东西不适用于这个设置吗?

编辑

该系统只用于访问apache2 can服务器:从外部可以访问: 192.168.0.02 192.168.0.07 192.168.0.08

从内部(192.168.0.2)我可以访问: localhost 192.168.0.7 192.168.0.8

但我不能从外面(192.168.0.3)或从里面上网( 192.168.0.2 )。我可以在VM内部打开主机192.168.0.3 (192.168.0.2是VirtualBox上的VM )

从VM内部查找剂量工作(192.168.0.2)

EN

回答 2

Ask Ubuntu用户

发布于 2019-06-05 15:39:54

debian手册上说

代码语言:javascript
运行
复制
    iproute2 method

Also, ifupdown supports specifying multiple interfaces by repeating iface sections with the same interface name. The key difference from the method described above is that all such sections are treated by ifupdown as just one interface, so user can't add or remove them individually. However, up/down commands, as well as scripts, are called for every section as it used to be.

Note however that this method is dangerous! Certain driver/hardware combinations may sometimes fail to bring the link up if no labels are assigned to the alias interfaces. (Seen this on Debian Wheezy and Jessie with RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 01) auto-negotiating to 10/full. A similar warning from another person exists in the history of this page.)

This /etc/network/interfaces text assigns three IP addresses to eth0.

auto eth0
allow-hotplug eth0
iface eth0 inet static
    address 192.168.1.42/24
    gateway 192.168.1.1

iface eth0 inet static
    address 192.168.1.43/24

iface eth0 inet static
    address 192.168.1.44/24

# adding IP addresses from different subnets is also possible
iface eth0 inet static
    address 10.10.10.14/24

但即使使用标签(或者至少我认为我在使用它们):

代码语言:javascript
运行
复制
    auto enz3
allow-hotplug enz3
iface enz3 inet static
    address 192.168.0.2
    netmask 255.255.255.0
    gateway 192.168.0.1


iface enz3:1 inet static
    address 192.168.0.7
    netmask 255.255.255.0



iface enz3:2 inet static
    address 192.168.0.8
    netmask 255.255.255.0

我仍然会发现错误:

代码语言:javascript
运行
复制
giu 05 17:38:43 dv-VBox systemd[1]: Stopped Raise network interfaces.
giu 05 17:38:43 xx-VBox systemd[1]: Starting Raise network interfaces...
giu 05 17:38:43 xx-VBox ifup[5004]: RTNETLINK answers: File exists
giu 05 17:38:43 xx-VBox ifup[5004]: Failed to bring up enz3.
giu 05 17:38:43 xx-VBox systemd[1]: networking.service: Main process exited, code=exited, status=1/FAILURE
giu 05 17:38:43 xx-VBox systemd[1]: Failed to start Raise network interfaces.
giu 05 17:38:43 xx-VBox systemd[1]: networking.service: Unit entered failed state.
giu 05 17:38:43 xx-VBox systemd[1]: networking.service: Failed with result 'exit-code'.

接下来我该试试什么呢?

票数 0
EN

Ask Ubuntu用户

发布于 2019-06-05 14:55:10

也许这就是答案?

如何使用/etc/网络/接口而不是网络管理器?

也不确定16.04是否有效?

不是

代码语言:javascript
运行
复制
 [ifupdown] 
managed=false

已经到了

票数 -1
EN
页面原文内容由Ask Ubuntu提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://askubuntu.com/questions/1148762

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档