Port forwarding from host to VM's troubleshooting

dkintop

New Member
Nov 30, 2022
2
0
1
hello all. As a developer by trade, I decided to try my luck with setting up a small home virtualization lab using an old laptop as my proxmox host. My physical network setup currently is proxmox host connected to main PC directly via ethernet, main PC has wifi connection.

So far I have successfully configured proxmox and am able to reach the proxmox admin console web gui from my main pc. I have spun up a Turnkey Linux VM and have reached the point where i am able to ping the VM from the proxmox host as well as get a successful html response using curl which indicates to me that there is no issues between the host and the vm (i could be wrong)

now everyone's favorite part, Port Forwarding! this is where im having issues. With my current network setup I believe my only option is to do port forwarding from the host to the vm in order to be able to reach resources running on VMs from my main PC (please let me know if there is a better way with my current setup, I am relatively innexperienced when it comes to the network side of things.)

After trialing a mix of different solutions, so far i have failed at attempting to forward from a port on the host to a port on the vm. My current Network configurations look like this:

Proxmox Host:

auto lo
iface lo inet loopback

iface eno2 inet manual

auto vmbr0
iface vmbr0 inet static
address 10.0.0.76
netmask 255.255.255.0
gateway 192.168.100.1
bridge-ports eno2
bridge-stp off
bridge-fd 0
post-up echo 1 > /proc/sys/net/ipv4/ip_forward
post-up iptables -t nat -A POSTROUTING -s '10.0.0.76/24' -o vmbr0 -j MASQUERADE
post-down iptables -t nat -D POSTROUTING -s '10.0.0.76/24' -o vmbr0 -j MASQUERADE


iface wlo1 inet manual

# LAMP-1 10.0.0.74
post-up iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 9006 -j DNAT --to 10.0.0.74
post-down iptables -t nat -D PREROUTING -i vmbr0 -p tcp --dport 9006 -j DNAT --to 10.0.0.74

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

VM:
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 10.0.0.74
netmask 255.255.255.0
gateway 10.0.0.76
dns-nameservers 8.8.8.8


additional proxmox network info in case it is relevant
1669844184595.png
My initial goal is to be able to hit 10.0.0.76:9006 in browser from my main PC (same one i use to reach proxmox gui) that will then result in the html page from my VM at 10.0.0.74. or even simply being able to ping the vm from my main pc.

attempting to make https request to 10.0.0.76:9006 with the above configurations results in what i perceive to be a 404, but i may be missing something, i dont know that ive seen this type of response in my normal day to day failures. makes me think their could possibly be an issue with the hosts configuration? (i've only worked in windows environments up until now)1669845273281.png

I know someone out their is itching to school a noob, any tips or reccomendations are highly welcome! Thank you all in advance. will provide additional information if requested.
 
hello all. As a developer by trade, I decided to try my luck with setting up a small home virtualization lab using an old laptop as my proxmox host. My physical network setup currently is proxmox host connected to main PC directly via ethernet, main PC has wifi connection.

So far I have successfully configured proxmox and am able to reach the proxmox admin console web gui from my main pc. I have spun up a Turnkey Linux VM and have reached the point where i am able to ping the VM from the proxmox host as well as get a successful html response using curl which indicates to me that there is no issues between the host and the vm (i could be wrong)

now everyone's favorite part, Port Forwarding! this is where im having issues. With my current network setup I believe my only option is to do port forwarding from the host to the vm in order to be able to reach resources running on VMs from my main PC (please let me know if there is a better way with my current setup, I am relatively innexperienced when it comes to the network side of things.)

After trialing a mix of different solutions, so far i have failed at attempting to forward from a port on the host to a port on the vm. My current Network configurations look like this:

Proxmox Host:

auto lo
iface lo inet loopback

iface eno2 inet manual

auto vmbr0
iface vmbr0 inet static
address 10.0.0.76
netmask 255.255.255.0
gateway 192.168.100.1
bridge-ports eno2
bridge-stp off
bridge-fd 0
post-up echo 1 > /proc/sys/net/ipv4/ip_forward
post-up iptables -t nat -A POSTROUTING -s '10.0.0.76/24' -o vmbr0 -j MASQUERADE
post-down iptables -t nat -D POSTROUTING -s '10.0.0.76/24' -o vmbr0 -j MASQUERADE


iface wlo1 inet manual

# LAMP-1 10.0.0.74
post-up iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 9006 -j DNAT --to 10.0.0.74
post-down iptables -t nat -D PREROUTING -i vmbr0 -p tcp --dport 9006 -j DNAT --to 10.0.0.74

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

VM:
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 10.0.0.74
netmask 255.255.255.0
gateway 10.0.0.76
dns-nameservers 8.8.8.8


additional proxmox network info in case it is relevant
View attachment 43978
My initial goal is to be able to hit 10.0.0.76:9006 in browser from my main PC (same one i use to reach proxmox gui) that will then result in the html page from my VM at 10.0.0.74. or even simply being able to ping the vm from my main pc.

attempting to make https request to 10.0.0.76:9006 with the above configurations results in what i perceive to be a 404, but i may be missing something, i dont know that ive seen this type of response in my normal day to day failures. makes me think their could possibly be an issue with the hosts configuration? (i've only worked in windows environments up until now)View attachment 43979

I know someone out their is itching to school a noob, any tips or reccomendations are highly welcome! Thank you all in advance. will provide additional information if requested.
As long as you want to access to your VM's application only from home LAN (it is the case AFAIU) no port forwarding is necessary. VM is in the same subnet as your PC. Despite this port forwarding would work theoretically but in this case the tcp connection would be asymmetric: for the client destination is 10.0.0.76 but responses will arrive from 10.0.0.74 which is sometimes not tolerated. The solution would be to add also a 'MASQUERADE' rule; but as mentioned: currently not necessary, but if you plan to reach the VM also from internet you will need this (as well as port forwarding in your home router).

Not directly related: gateway 192.168.100.1 is contradictory to subnet 10.0.0.0/24. I gues it comes from WLAN wlo1 which is not controlled by Proxmox settings (rather from DHCP at your home router to internet but currently not active).
 
As long as you want to access to your VM's application only from home LAN (it is the case AFAIU) no port forwarding is necessary. VM is in the same subnet as your PC. Despite this port forwarding would work theoretically but in this case the tcp connection would be asymmetric: for the client destination is 10.0.0.76 but responses will arrive from 10.0.0.74 which is sometimes not tolerated. The solution would be to add also a 'MASQUERADE' rule; but as mentioned: currently not necessary, but if you plan to reach the VM also from internet you will need this (as well as port forwarding in your home router).

Not directly related: gateway 192.168.100.1 is contradictory to subnet 10.0.0.0/24. I gues it comes from WLAN wlo1 which is not controlled by Proxmox settings (rather from DHCP at your home router to internet but currently not active).
thank you for the response! If I understand correctly, I should be able to reach the vm directly at 10.0.0.74 not only from the host but also from my pc connected to the host via ethernet? that would be even better, I actually can't remember if I tried this first or not...
 

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!