具有多个静态 IP 的 KVM 网络桥接

具有多个静态 IP 的 KVM 网络桥接

我目前有 64 个 IP 地址,我正在尝试制作 64 个面向公众的 kvms vm,每个 vm 都有自己的专用 IP。

我对如何编辑这件事有点困惑/etc/network/interfaces。我知道ubuntu 16.04 +你必须建立一座桥梁。

目前我ifconfig的如下

$ ifconfig -a
eno1      Link encap:Ethernet  HWaddr 24:6e:96:05:ae:b0  
          inet addr:38.124.224.67  Bcast:38.124.224.127  Mask:255.255.255.192
          inet6 addr: fe80::266e:96ff:fe05:aeb0/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:80805370 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8423241 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:8071366410 (8.0 GB)  TX bytes:1468297158 (1.4 GB)

eno2      Link encap:Ethernet  HWaddr 24:6e:96:05:ae:b2  
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

eno3      Link encap:Ethernet  HWaddr 24:6e:96:05:ae:b4  
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Memory:dae80000-daefffff 

eno4      Link encap:Ethernet  HWaddr 24:6e:96:05:ae:b5  
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Memory:daf00000-daf7ffff 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:222 errors:0 dropped:0 overruns:0 frame:0
          TX packets:222 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1 
          RX bytes:21049 (21.0 KB)  TX bytes:21049 (21.0 KB)

virbr0    Link encap:Ethernet  HWaddr 52:54:00:e8:92:ec  
          inet addr:192.168.122.1  Bcast:192.168.122.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:17562 errors:0 dropped:0 overruns:0 frame:0
          TX packets:12619 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:2628722 (2.6 MB)  TX bytes:2405500 (2.4 MB)

virbr0-nic Link encap:Ethernet  HWaddr 52:54:00:e8:92:ec  
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

vnet0     Link encap:Ethernet  HWaddr fe:54:00:f8:af:b5  
          inet6 addr: fe80::fc54:ff:fef8:afb5/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:17467 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4431751 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:2865065 (2.8 MB)  TX bytes:232190543 (232.1 MB)

vnet1     Link encap:Ethernet  HWaddr fe:54:00:91:95:55  
          inet6 addr: fe80::fc54:ff:fe91:9555/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:95 errors:0 dropped:0 overruns:0 frame:0
          TX packets:70414 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:9525 (9.5 KB)  TX bytes:3686541 (3.6 MB)

我被分配了以下 IP 地址块

Ip block 38.124.224.65/26 
Subnet: 255.255.255.192
Gateway: 38.124.224.65

br0因此,当建立一个名为“我的当前/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 eno1
iface eno1 inet static
        address 38.124.224.67
        netmask 255.255.255.192
        network 38.124.224.64
        broadcast 38.124.224.127
        gateway 38.124.224.65
        # dns-* options are implemented by the resolvconf package, if installed
        dns-nameservers 4.2.2.2

我是否只需添加到此文件底部

auto br0

iface br0 inet static

address 38.124.224.65/26
    netmask 255.255.255.192
    broadcast 38.x.x.x
    dns-nameservers 8.8.8.8 
    bridge_ports eno1
    bridge_stp off
    bridge_fd 0
    bridge_maxwait 0

我只是不确定是否必须添加每个静态 ip 或者是否可以设置一个块并且它会自动为每个 kvm 分配一个静态?

相关内容