首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何将kvm虚拟机直接连接到外部IP

如何将kvm虚拟机直接连接到外部IP
EN

Server Fault用户
提问于 2016-04-01 19:19:04
回答 1查看 4K关注 0票数 1

我知道有人到处问这个问题,但对我来说没有答案。在谷歌上搜索了几个小时后,我想不出来了。我有Ubuntu 14服务器,我需要制作很少的虚拟服务器--我想要一些像DigitalOcean中的VPS一样的东西--带有外部IP的虚拟机。

所以我有一个有两个I的Ubuntu服务器,但是只有一个物理网卡。

主机系统只能在主地址198.201.29.211之前访问。

当然,虚拟机的行为应该像正常的物理服务器一样,并且能够连接到主机服务器。

这是我的/etc/组网/接口文件:

代码语言:javascript
复制
# Loopback device:
auto lo
iface lo inet loopback
iface lo inet6 loopback

# device: eth0
auto  eth0
iface eth0 inet static
  address   198.201.29.211
  netmask   255.255.255.192
  gateway   198.201.29.193
  # default route to access subnet
  up route add -net 198.201.29.192 netmask 255.255.255.192 gw 198.201.29.193 eth0

auto eth0:0
iface eth0:0 inet static
  address 198.201.29.247
  netmask 255.255.255.192

auto eth0:1
iface eth0:0 inet static
  address 198.201.29.248
  netmask 255.255.255.192

auto eth0:2
iface eth0:0 inet static
  address 198.201.29.249
  netmask 255.255.255.192

每个IP (除了主IP: 198.201.29.211在eth0上)都应该完全附加到适当的虚拟机(在eth0上)。

EN

回答 1

Server Fault用户

发布于 2016-04-01 21:59:50

事实证明,正确的配置非常简单。(互联网上有这么多令人困惑的答案)。网络源设置(我使用)应该设置为Host eth0 (Bridge 'br0')。

虚拟机的地址只需要在使用虚拟机的虚拟机中设置,而不需要在主机上设置。

虚拟机/etc/组网/接口如下所示:

代码语言:javascript
复制
auto  eth0
    iface eth0 inet static
      address   198.201.29.248
      netmask   255.255.255.192
      gateway   198.201.29.211

这是我的工作/etc/联网/接口(在主机上):

代码语言:javascript
复制
# Loopback device:
auto lo
iface lo inet loopback
iface lo inet6 loopback

# device: eth0
auto  eth0
iface eth0 inet static
  address   198.201.29.211
  netmask   255.255.255.192
  gateway   198.201.29.193
  # default route to access subnet
  up route add -net 198.201.29.192 netmask 255.255.255.192 gw 198.201.29.193 eth0

auto br0
iface br0 inet static
  address   198.201.29.211
  netmask   255.255.255.192
  gateway   198.201.29.193
  bridge_ports eth0
  bridge_stp off
  bridge_fd 0
  bridge_maxwait 0

KVM/Libvirt桥接/路由网络不在新的客户内核上工作:我发现由于我的服务器位于Hertzner,所以我还必须关闭ICMP重定向:

代码语言:javascript
复制
for file in `find /proc/ -iname send_redirects`; do echo 0 > $file; done
票数 1
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/767644

复制
相关文章

相似问题

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