我在 KVM 和开放星云论坛以及一般虚拟化论坛上阅读过多篇提出同样问题的帖子,但只找到了部分或虚假的答案。
一些信息:
- 目标:能够租用部署在 ON 上的 VPS
- Ubuntu Server 18.04 前几天安装的,更新了
- ON 为单主机配置(前端和主机合为一体)
- 我有一个 /29 IP 块,想在虚拟机上使用这些 IP
以下是我迄今为止收集到的(并尝试过的)信息:
根据 OpenNebula 文档我已经像这样设置了 OVS 桥:
# Create bridge and add port
ovs-vsctl add-br ovsbr0
ovs-vsctl add-port ovsbr0 enp3s0
# Change external IP address from port to bridge
ip addr flush dev enp3s0
ip addr add xxx.xxx.110.50/29 dev ovsbr0
ip link set ovsbr0 up
ip route add default via xxx.xxx.110.49 dev ovsbr0
这样我就可以正常访问互联网了,并且桥接设置就像他们的例子一样:
dba23490-cd85-40f4-a3b5-dfe9c4e2e60a
Bridge "ovsbr0"
Port "enp3s0"
Interface "enp3s0"
Port "ovsbr0"
Interface "ovsbr0"
type: internal
ovs_version: "2.9.2"
太棒了!好吧,这就是我迷茫的地方。现在怎么办?我如何将其添加到 Open Nebula 以便我的新虚拟机具有外部 IP?
如果我彻底失败了,我还能用什么其他方法解决?
其他一些可能有用的信息:
# 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: enp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master ovs-system state UP group default qlen 1000
link/ether 00:25:90:62:f9:60 brd ff:ff:ff:ff:ff:ff
3: enp4s0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether 00:25:90:62:f9:61 brd ff:ff:ff:ff:ff:ff
4: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether 52:54:00:c6:e4:3e brd ff:ff:ff:ff:ff:ff
inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
valid_lft forever preferred_lft forever
5: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc fq_codel master virbr0 state DOWN group default qlen 1000
link/ether 52:54:00:c6:e4:3e brd ff:ff:ff:ff:ff:ff
17: ovs-system: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether fa:1d:97:0a:8e:1c brd ff:ff:ff:ff:ff:ff
18: ovsbr0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default qlen 1000
link/ether 00:25:90:62:f9:60 brd ff:ff:ff:ff:ff:ff
inet xxx.xxx.110.50/29 scope global ovsbr0
valid_lft forever preferred_lft forever
# ip route
default via xxx.xxx.110.49 dev ovsbr0
xxx.xxx.110.48/29 dev ovsbr0 proto kernel scope link src xxx.xxx.110.50
192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 linkdown
提前致谢。 链接至我的 OpenNebula 论坛帖子
答案1
终于让它工作了!
这是我的虚拟网络模板:
BRIDGE = "ovsbr0"
BRIDGE_TYPE = "openvswitch"
DESCRIPTION = "Network with public IPs"
DNS = "8.8.8.8"
GATEWAY = "xxx.xxx.110.49"
OUTER_VLAN_ID = ""
PHYDEV = ""
SECURITY_GROUPS = "0"
VLAN = "YES"
VLAN_ID = ""
VN_MAD = "ovswitch"
# optional QoS params
INBOUND_AVG_BW = "5785"
INBOUND_PEAK_BW = "9000"
INBOUND_PEAK_KB = "20000"
OUTBOUND_AVG_BW = "4200"
OUTBOUND_PEAK_BW = "9000"
OUTBOUND_PEAK_KB = "20000"
事实证明,这些信息并不在部署指南,但在操作指南您可以在其中找到 vnet 模板。
他们给出的例子:
# Configuration attributes (OpenvSwitch driver)
NAME = "Public"
DESCRIPTION = "Network with public IPs"
BRIDGE = "br1"
VLAN = "YES"
VLAN_ID = 12
DNS = "8.8.8.8"
GATEWAY = "130.56.23.1"
LOAD_BALANCER = 130.56.23.2
AR=[ TYPE = "IP4", IP = "130.56.23.2", SIZE = "1"]
AR=[ TYPE = "IP4", IP = "130.56.23.34", SIZE = "1"]
AR=[ TYPE = "IP4", IP = "130.56.23.24", SIZE = "1"]
AR=[ TYPE = "IP4", IP = "130.56.23.17", MAC= "50:20:20:20:20:21", SIZE = "1"]
AR=[ TYPE = "IP4", IP = "130.56.23.12", SIZE = "1"]