How can you link two Virtual Machine networks?

TheNoob

New Member
Mar 13, 2020
7
0
1
33
I want a database server and web server on two different machines but same network (for less latency), I created a Bridge in the UI, and then in the first virtual machine I did something like this. But it's not working (This is on Debian 10)

Code:
source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface which can access the outside world

auto ens18
iface ens18 inet static
address <virt_machine_address>
netmask 255.255.255.0
gateway xxx.xxx.xxx.254
dns-nameservers 8.8.8.8 1.1.1.1


# The secondary internal network interface meant for communication between two different virtual machines

auto ens19
iface ens19 inet static
address 10.10.10.1
netmask 255.255.255.0
bridge-ports 53
bridge-stp off
bridge-fd 0

Then I gave both Virtual Machines the same Mac Address, and vmbr1 bridge
 
Hi,
Never use two times the same MAC-Address onto one bridge. This will let to collissions and never work.

Inside VM1:

enXX1 linked to vmbr0 on proxmox-Host
enXX2 linked to vmbr1 on proxmox-Host

auto enXX1
iface enXXX1 inet static
address 192.168.X.XX1
netmask 255.255.255.0
gateway 192.168.X.254

auto enXX2
iface enXXX2 inet static
address 10.10.10.1
netmask 255.255.255.0

Inside VM2:

enXX1 linked to vmbr0 on proxmox-Host
enXX2 linked to vmbr1 on proxmox-Host

auto enXX1
iface enXXX1 inet static
address 192.168.X.XX2
netmask 255.255.255.0
gateway 192.168.X.254

auto enXX2
iface enXX2 inet static
address 10.10.10.2
netmask 255.255.255.0

On the proxmox-Host:

iface enXHOSTX inet manual

auto vmbr0
iface vmbr0 inet static
address 192.168.X.253
netmask 24
gateway 192.168.X.254
bridge-ports "enXHOSTXX" #192.168.X.X/24
bridge-stp off
bridge-fd 0

auto vmbr1
iface vmbr1 inet manual
bridge-ports none
bridge-stp off
bridge-fd 0

So you get:

VM1/ enXXX ---10.10.10.1/24 -----> vmbr1 <------10.10.10.2/24 --- VM2/enXXX

VM1/enXX1 ----192.168.X.1/24+gw--> vmbr0 <-- 192.168.X.2/24+gw ---VM1/enXXX

Don't just copy'n paste. Adapt example to your needs.
 
  • Like
Reactions: TheNoob
Yes, you're right.
Now you tell your Database on VM2 to just bind on the NIC connected to vmbr1 and your webserver to connect to the Database also through its NIC on vmbr1.
That scenario the Webserver and Database get not disturbed by othe traffic, which can get routed through vmbr0.
 
They are also on the same network with the default bridge and will have the same latency as if they were on another bridge.

So if I connect to the database using 51.xxx.xxx.xxx compared to 10.10.10.2, it'll have the same latency? I thought that if I was connecting the first way, then it would try doing the connection remotely instead of locally within the same network.
 
Don't just copy'n paste. Adapt example to your needs.

This worked thank you! Is it normal for response time to be around 0.2ms? Because when I ping localhost response time is more around 0.02ms? If it's normal, then the use-case for this would be to close the database server from the rest of the world?
 
Sounds normal.
Ping uses ICMP which is much faster than a connect using TCP with it's Handshakes and Acknowlodges and so on.
One can't compare ICMP Latency with TCP Stuff.
And of course it's a good idea to not expose a database-Server to the public.
Not only because of latency but security.

If you're confident just marc this as Solved
Have a good week.
 
So if I connect to the database using 51.xxx.xxx.xxx compared to 10.10.10.2, it'll have the same latency? I thought that if I was connecting the first way, then it would try doing the connection remotely instead of locally within the same network.

The packets do not leave your computer, so the there is no "remote", just "local".
 
prox.png

Red connection from Client to Webserer has higher latency assuming some more traffic is going through router et all.
Greenish connection has low-latency, as long as WEBSERVER using vmbr1 to query DATABASE.
Hope this makes it clear, how the rivers flow.
 
  • Like
Reactions: TheNoob

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!