OVH - Use the main IP in virtual machine?

harmonyp

Member
Nov 26, 2020
195
4
23
46
I have come across multiple threads on NAT routing the main IP into a virtual machine but is it possible to use the IP directly inside a virtual machine?
 
Hi,
yes that is possible, you can configure a bridge with no IP, and give that interface to the the VM (you have to configure the correct IP there)

the /etc/network/interface as an example
Code:
auto vmbr0
iface vmbr0 inet static
    bridge-ports eno1
    bridge-stp off
    bridge-fd 0

You will need another network for the VMs so that they can see each other:

Code:
auto vmbr1
iface vmbr1 inet static
    address 192.168.137.5/24
    bridge-ports none
    bridge-stp off
    bridge-fd 0

What are you planning todo?
 
Hi,
yes that is possible, you can configure a bridge with no IP, and give that interface to the the VM (you have to configure the correct IP there)

the /etc/network/interface as an example
Code:
auto vmbr0
iface vmbr0 inet static
    bridge-ports eno1
    bridge-stp off
    bridge-fd 0

You will need another network for the VMs so that they can see each other:

Code:
auto vmbr1
iface vmbr1 inet static
    address 192.168.137.5/24
    bridge-ports none
    bridge-stp off
    bridge-fd 0

What are you planning todo?
Ok thanks will give it a go.

So if the OVH IP is 1.1.1.1 I use the example you set above and configure the virtual machine with what IP and gatewaY?
 
Yes that sounds about right. You just need to make sure that you can reach proxmox on the private IP (in the example above) :).
 
Yes that sounds about right. You just need to make sure that you can reach proxmox on the private IP (in the example above) :).
I can't seem to get this working

Proxmox node:

Code:
auto eth0
iface eth0 inet manual

auto eth1
iface eth1 inet manual

auto vmbr0
iface vmbr0 inet static
    bridge-ports eth0
    bridge-stp off
    bridge-fd 0

auto vmbr1
iface vmbr1 inet static
    address 192.168.137.5/24
    bridge-ports none
    bridge-stp off
    bridge-fd 0


Inside virtual machine:

Code:
auto eth0
iface eth0 inet static
    address 198.244.xxx.151/24
    gateway 198.244.xxx.254

auto eth1
iface eth1 inet static
    address 192.168.137.6/24
netmask 255.0.0.0

While the VM is running I can connect to both IPs above from the node but the public IP 198.244.xxx.151 will not ping externally.

I have the following enabled
Code:
sudo echo 'net.ipv4.ip_forward=1' >> /etc/sysctl.conf
sudo sysctl -p


and tried adding this to network (vmbr0) with no changes
Code:
     up ip route add 198.244.xxx.151/32 dev vmbr0
    post-up echo 1 > /proc/sys/net/ipv4/conf/eth0/proxy_arp

You have done this with OVH? or am I doing something wrong.

VM config:

Code:
agent: 1
boot: c
bootdisk: scsi0
cipassword: $5$BGpxJ/kS$l4Is3wmJsgRVTkRhsr.6mP3Kk/DHNp0HdMVmO9S58o7
ciuser: root
ide2: local:101/vm-101-cloudinit.qcow2,media=cdrom
ipconfig0: ip=198.244.xxx.151/24,gw=198.244.xxx.254
ipconfig1: ip=192.168.137.6/24
memory: 2048
name: test2
net0: virtio=36:F1:75:8D:68:32,bridge=vmbr0,firewall=1
net1: virtio=CA:F1:97:63:05:17,bridge=vmbr1,firewall=1
onboot: 1
scsi0: local:101/vm-101-disk-0.raw,size=2G
scsihw: virtio-scsi-pci
serial0: socket
smbios1: uuid=779264ab-30a5-4dba-8024-d5e6c66f0729
vga: serial0
vmgenid: 65962eaa-9009-4df2-b0ad-10a63447d168
 
Last edited:
I saw that I made a a mistake it should be manual instead of static for the host

Code:
auto vmbr0
iface vmbr0 inet manual
    bridge-ports eth0
    bridge-stp off
    bridge-fd 0

The other thing is that OVH might block unkown mac addresses. This might help you (the part about generating a mac address):
https://support.us.ovhcloud.com/hc/...Connect-a-VM-to-the-Internet-Using-Proxmox-VE
This is why I mentioned OVH. They do not allow you to create a virtual mac on the main interface IP.

Made your changes above still can't get it to work.
 

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!