This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
virtualisation:kvm [2018/07/18 11:08] Luc Nieland [Distribution: Ubuntu 18.04 LTS] |
virtualisation:kvm [2020/02/13 17:05] (current) Luc Nieland CentOS-8: bond + vlan + bridge |
||
---|---|---|---|
Line 207: | Line 207: | ||
Remove all .yaml files in /etc/netplan/ (or rename them to *.disabled) | Remove all .yaml files in /etc/netplan/ (or rename them to *.disabled) | ||
- | ==One bridge with static IP== | + | ==One network, one bridge== |
+ | A simple configuration for a simple network. The server has one bridge, with a static IP on the bridge. | ||
Add to /etc/netplan/10-netconfig-bridge-static.yaml | Add to /etc/netplan/10-netconfig-bridge-static.yaml | ||
Line 234: | Line 236: | ||
==One bridge per VLAN== | ==One bridge per VLAN== | ||
- | When the system is directly connected to a network-trunk, with one or more VLANs on it: | + | A more complex setup. The system has one physical NIC. This is connected to a switch. This port is in trunc-mode, and has four VLANs configured on this port. |
+ | |||
+ | On the server, the four VLANs are split, and for every VLAN a bridge is created. A static IP number is configured on one bridge, to access the server. | ||
+ | |||
+ | |||
+ | Remove alle files in /etc/netplan/ and create the file /etc/netplan/10-netconfig-bridge-per-vlan.yaml with the following: | ||
- | Add to /etc/netplan/10-netconfig-bridge-per-vlan.yaml | ||
<code> | <code> | ||
network: | network: | ||
Line 244: | Line 250: | ||
eno1: | eno1: | ||
dhcp4: no | dhcp4: no | ||
+ | dhcp6: no | ||
bridges: | bridges: | ||
- | br0099: | + | br0010: |
interfaces: | interfaces: | ||
- | - vlan0099 | + | - vlan0010 |
parameters: | parameters: | ||
stp: false | stp: false | ||
forward-delay: 0 | forward-delay: 0 | ||
- | dhcp4: no | + | addresses: |
- | br0102: | + | - 192.168.10.42/24 |
+ | gateway4: 192.168.10.1 | ||
+ | nameservers: | ||
+ | addresses: | ||
+ | - 1.1.1.1 | ||
+ | - 8.8.8.8 | ||
+ | br0011: | ||
interfaces: | interfaces: | ||
- | - vlan0102 | + | - vlan0011 |
parameters: | parameters: | ||
stp: false | stp: false | ||
forward-delay: 0 | forward-delay: 0 | ||
- | addresses: | + | dhcp4: no |
- | - 192.168.2.203/24 | + | dhcp6: no |
- | gateway4: 192.168.2.1 | + | br0012: |
- | nameservers: | + | |
- | addresses: | + | |
- | - 194.109.6.66 | + | |
- | - 194.109.9.99 | + | |
- | br0103: | + | |
interfaces: | interfaces: | ||
- | - vlan0103 | + | - vlan0012 |
parameters: | parameters: | ||
stp: false | stp: false | ||
forward-delay: 0 | forward-delay: 0 | ||
dhcp4: no | dhcp4: no | ||
- | br1001: | + | dhcp6: no |
+ | br0013: | ||
interfaces: | interfaces: | ||
- | - vlan1001 | + | - vlan0013 |
parameters: | parameters: | ||
stp: false | stp: false | ||
forward-delay: 0 | forward-delay: 0 | ||
dhcp4: no | dhcp4: no | ||
+ | dhcp6: no | ||
vlans: | vlans: | ||
- | vlan0099: | + | vlan0010: |
accept-ra: no | accept-ra: no | ||
- | id: 99 | + | id: 10 |
link: eno1 | link: eno1 | ||
- | vlan0102: | + | vlan0011: |
accept-ra: no | accept-ra: no | ||
- | id: 102 | + | id: 11 |
link: eno1 | link: eno1 | ||
- | vlan0103: | + | vlan0012: |
accept-ra: no | accept-ra: no | ||
- | id: 103 | + | id: 12 |
link: eno1 | link: eno1 | ||
- | vlan1001: | + | vlan013: |
accept-ra: no | accept-ra: no | ||
- | id: 1001 | + | id: 13 |
link: eno1 | link: eno1 | ||
</code> | </code> | ||
Line 303: | Line 313: | ||
<code> | <code> | ||
[Match] | [Match] | ||
- | Name=br0* | + | Name=br00* |
[Network] | [Network] | ||
Line 310: | Line 320: | ||
</code> | </code> | ||
- | Explanation. This is to bring up the anonymous bridges (the ones which have no ip-address on it). Due to a bug in netplan in combination networkd, these (anonymous) bridges will have operational status 'off' after boot. This can be checked with: | + | Explanation. This is to bring up the anonymous bridges automatically after boot (the bridges which have no ip-address configured on it). Due to a bug in the combination of netplan and networkd, anonymous bridges will have operational status 'off' after boot. |
+ | |||
+ | This can be checked with: | ||
networkctl list | networkctl list | ||
Line 316: | Line 328: | ||
This can be solved manually with: | This can be solved manually with: | ||
- | ip link set dev br0099 up | + | ip link set dev br0011 up |
- | ip link set dev br0103 up | + | ip link set dev br0012 up |
- | ip link set dev br1001 up | + | ip link set dev br0013 up |
for the above netplan yaml example. | for the above netplan yaml example. | ||
Line 335: | Line 347: | ||
- | =====Distribution: CentOS 6.0 ===== | + | =====Distribution: CentOS ===== |
===preparation=== | ===preparation=== | ||
- | Install a minimal CentOS 6.0 system with a static IP-number. | + | Install a minimal CentOS system with a static IP-number. |
+ | |||
+ | |||
+ | |||
+ | ===network config CentOS-8=== | ||
+ | |||
+ | With nmcli | ||
+ | |||
+ | Add to /etc/sysconfig/ | ||
+ | |||
+ | Bonding: | ||
+ | <code> | ||
+ | nmcli con add type bond con-name bond0 ifname bond0 autoconnect yes \ | ||
+ | ipv4.method disabled \ | ||
+ | ipv6.method ignore | ||
+ | nmcli con add type ethernet ifname eno1 con-name bond0-sl1 master bond0 | ||
+ | nmcli con add type ethernet ifname eno2 con-name bond0-sl2 master bond0 | ||
+ | <code> | ||
+ | |||
+ | |||
+ | Split the trunc-datastream to VLAN's: | ||
+ | <code> | ||
+ | nmcli con add type vlan ifname vlan20 con-name vlan20 vlan.id 20 \ | ||
+ | vlan.parent bond0 \ | ||
+ | ipv4.method disabled \ | ||
+ | ipv6.method ignore | ||
+ | # repeat per VLAN | ||
+ | <code> | ||
+ | |||
+ | |||
+ | Create a bridge per VLAN: | ||
+ | <code> | ||
+ | BR_NAME="br20" | ||
+ | BR_INT="vlan20" | ||
+ | SUBNET_IP="192.168.103.32/24" | ||
+ | GW="192.168.103.1" | ||
+ | DNS1="192.168.102.144" | ||
+ | DNS2="192.168.102.146" | ||
+ | nmcli connection add type bridge con-name ${BR_NAME} ifname ${BR_NAME} autoconnect yes | ||
+ | nmcli connection modify ${BR_NAME} ipv4.method manual ipv4.addresses ${SUBNET_IP} | ||
+ | nmcli connection modify ${BR_NAME} ipv4.gateway ${GW} | ||
+ | nmcli connection modify ${BR_NAME} ipv4.dns ${DNS1} +ipv4.dns ${DNS2} | ||
+ | nmcli connection up ${BR_NAME} | ||
+ | nmcli connection add type bridge-slave con-name ${BR_INT} ifname ${BR_INT} master ${BR_NAME} autoconnect yes | ||
+ | nmcli connection up ifname ${BR_INT} | ||
+ | # | ||
+ | ip r add default via 192.168.103.1 | ||
+ | # | ||
+ | <code> | ||
+ | |||
+ | ===hypervisor kvm=== | ||
Install the software: | Install the software: | ||
yum install kvm virt-manager libvirt | yum install kvm virt-manager libvirt | ||
+ | |||
+ | |||
Line 632: | Line 697: | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | ======Migration of VMs to another host ====== | ||
+ | Instructions how to migrate VMs to another hypervisor-host. | ||
+ | |||
+ | ====Offline==== | ||
+ | |||
+ | Create a destination KVM-hypervisor system, including bridges on the required networks and VLANs. Try to use the same names for bridges, filesystems, logical-volumes. Else use "virsh edit" to make the modifications befor starting the VM on the destination hypervisor. | ||
+ | |||
+ | |||
+ | ===On the source-hypervisor=== | ||
+ | |||
+ | create a definition-file: | ||
+ | virsh list --all | ||
+ | virsh dumpxml --security-info vpstest2 > /var/lib/libvirt/images/vpstest2.xml | ||
+ | virsh shutdown vpstest2 | ||
+ | virsh destroy vpstest2 # if needed | ||
+ | |||
+ | |||
+ | ===On the destination-hypervisor=== | ||
+ | |||
+ | Create the required logical-volumes, and symlinks: | ||
+ | lvcreate -L 4G -n vpstest2 vg0 | ||
+ | ln -s /dev/mapper/vg0-vpstest2 /var/lib/libvirt/images/vpstest2.img | ||
+ | |||
+ | And get the raw-logical-volume with a dd piped through ssh: | ||
+ | ssh root@sourcehyp "dd if=/dev/mapper/vg0-vpstest2" | dd of=/dev/mapper/vg0-vpstest2 | ||
+ | |||
+ | And get the config-definition-file: | ||
+ | scp root@sourcehyp:/var/lib/libvirt/images/vpstest2.xml /var/lib/libvirt/images/vpstest2.xml | ||
+ | |||
+ | And create the VM: | ||
+ | virsh define /var/lib/libvirt/images/vpstest2.xml | ||
+ | |||
+ | And start the VM: | ||
+ | virsh start vpstest2 | ||
+ | |||
+ | |||
+ | |||
+ | | ||