I’m using Ubuntu 20.04, so all the manipulations are going to be made with netplan
.
Also, I’m using singe ordered IPs, not subnets, so I can also order virtual MAC address for each of the IPs. Otherwise, you might want to look into routing options.
This is my original netplan
once after OS is installed on my dedicated server. You can find it under /etc/netplan/
### Hetzner Online GmbH installimage
network:
version: 2
renderer: networkd
ethernets:
enp41s0:
addresses:
- X1.X1.X1.X1/32
- X6:X6:X6:X6::X6/64
routes:
- on-link: true
to: 0.0.0.0/0
via: Y1.Y1.Y1.Y1
gateway6: Y16::1
nameservers:
addresses:
- 185.12.64.1
- 2a01:4ff:ff00::add:2
- 185.12.64.2
- 2a01:4ff:ff00::add:1
We are switching it to a bridget network, so VMs can use the bridge with its own IPs to be accessible over SSH protocol.
network:
version: 2
renderer: networkd
ethernets:
enp41s0:
dhcp4: no
dhcp6: no
bridges:
br0:
interfaces: [enp41s0]
dhcp4: no
dhcp6: no
addresses:
- X1.X1.X1.X1/32
- X6:X6:X6:X6::X6/64
routes:
- on-link: true
to: 0.0.0.0/0
via: Y1.Y1.Y1.Y1
gateway6: Y16::1
nameservers:
addresses:
- 185.12.64.1
- 2a01:4ff:ff00::add:2
- 185.12.64.2
- 2a01:4ff:ff00::add:1
parameters:
stp: true
forward-delay: 4
So, for the interface enp41s0
we disable DHCP, and set up the br0
bridge with the same settings.
Then use one or a conjunction of these commands to apply the settings
netplan generate
netplan try
netplan apply
Next, we need to edit VM settings to use that bridge and virtual MAC address
virsh edit $VM_NAME
And change interface
part to look like this
<interface type='bridge'>
<mac address='AA:AA:AA:AA:AA:AA'/>
<source bridge='br0'/>
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
</interface>
Finally, update VM’s netplan
. Login into VM
virsh console $VM_NAME
cd /etc/netplan
ls
nano 50-cloud-init.yaml
And this is what I’ve set up
network:
version: 2
renderer: networkd
ethernets:
enp1s0:
addresses:
- X2.X2.X2.X2/32
routes:
- to: 0.0.0.0/0
via: Y2.Y2.Y2.Y2
on-link: true
nameservers:
addresses:
- 185.12.64.1
- 2a01:4ff:ff00::add:2
- 185.12.64.2
- 2a01:4ff:ff00::add:1
That’s it, reboot everything is it should be working.
This is how to allow SSH
access
apt install openssh-server
systemctl status ssh
ufw allow ssh
To allow root
access over SSH
nano /etc/ssh/sshd_config
And set PermitRootLogin yes
.
Leave a Reply