I got a new dedicated server and installed KVM on it. I've created a virtual machine but I got some problems managing public IP to that VM. In addition, the Ubuntu 18.0.4 LTS server has installed on the host VM.
The host network details
ifconfig
:
eno1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 88.44.31.30 netmask 255.255.255.255 broadcast 0.0.0.0
inet6 fe81::b62e:99fd:fecd:fd13 prefixlen 64 scopeid 0x20<link>
inet6 2a02:4f8:232:1b07::2 prefixlen 64 scopeid 0x0<global>
ether b2:2e:99:fb:3b:aa txqueuelen 1000 (Ethernet)
RX packets 2934329 bytes 1525163180 (1.5 GB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 2799211 bytes 3794187248 (3.7 GB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 16 memory 0x51200000-51220000
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 246437 bytes 3598125972 (3.5 GB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 246437 bytes 3598125972 (3.5 GB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
virbr0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether 52:53:0b:a6:6f:f0 txqueuelen 1000 (Ethernet)
RX packets 15954 bytes 1189621 (1.1 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 27979 bytes 283208200 (283.2 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
vnet0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe81::fc50:56af:fbb0:6aa4 prefixlen 64 scopeid 0x20<link>
ether fe:50:56:00:67:ab txqueuelen 1000 (Ethernet)
RX packets 870 bytes 100801 (100.8 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 21441 bytes 2188836 (2.1 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
/etc/netplan/01-netcfg.yaml
:
network:
version: 2
renderer: networkd
ethernets:
eno1:
addresses:
- 88.44.31.30/32
- 2a02:4f8:232:1b07::2/64
routes:
- on-link: true
to: 0.0.0.0/0
via: 88.44.31.1
gateway6: fe81::1
nameservers:
addresses:
- 213.133.98.98
- 213.133.99.99
- 213.133.100.100
- 2a01:4f8:0:1::abd:9912
- 2a01:4f8:0:1::abd:1022
- 2a01:4f8:0:1::abd:9844
route -n
:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 88.44.31.1 0.0.0.0 UG 0 0 0 eno1
192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0
The VM network details
ifconfig
:
enp1s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.122.178 netmask 255.255.255.0 broadcast 192.168.122.255
inet6 fe81::fc50:bbaf:fab0:6aa5 prefixlen 64 scopeid 0x20<link>
ether 00:bb:56:aa:67:ab txqueuelen 1000 (Ethernet)
RX packets 797 bytes 302823 (302.8 KB)
RX errors 0 dropped 590 overruns 0 frame 0
TX packets 165 bytes 19312 (19.3 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 90 bytes 6966 (6.9 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 90 bytes 6966 (6.9 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
/etc/netplan/00-installer-config.yaml
:
network:
ethernets:
enp1s0:
dhcp4: true
version: 2
route -n
:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.122.1 0.0.0.0 UG 100 0 0 enp1s0
192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 enp1s0
192.168.122.1 0.0.0.0 255.255.255.255 UH 100 0 0 enp1s0
The ISP gives me the following address:
address 88.44.31.10
netmask 255.255.255.224
gateway 88.44.31.1
Therefore, I need to access the VM from the outside/internet by 88.44.31.10
but dunno how to configure the host and the VM.
Thanks in advance.
You will need to create a bridge on your external interface. Then you can have an device&IP on that bridge for your host, but also connect your guest to it to work on the same externally facing network.
An example of such a configuration can be found on the netplan.io example page.
You can later on go bigger considering OpenVswitch as an alternative, but that will be more complex and therefore only useful if you need it's advanced features.