(ASK) One IP for All VMs and VM Access from RDC

Elisatin Nilawati

New Member
Feb 22, 2019
6
0
1
31
Hi, I want to ask for a tutorial on how to access VMs through RDC which is configured from the NAT network.

I have successfully configured 1 ip for many VMs,

Like the configuration below:

# /etc/network/interfaces:
auto vmbr2
iface vmbr2 inet static
address 10.21.21.254
netmask 255.255.255.0
bridge_ports none
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.21.21.0/24' -o vmbr0 -j MASQUERADE
post-down iptables -t nat -D POSTROUTING -s '10.21.21.0/24' -o vmbr0 -j MASQUERADE
post-up iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 2222 -j DNAT --to 10.21.21.5:22
post-down iptables -t nat -D PREROUTING -i vmbr0 -p tcp --dport 2222 -j DNAT --to 10.21.21.5:22​

However, I have not yet succeeded in accessing any VM that was created through RDC. so I was forced to use Anydesk to access all the VMs ..

Can you all help me so that vm can be accessed from RDC, for example:

ip: 192,227,165.xx: 3301 to 192,227,165.xx: 3324
 
Hi. Yes. RDC = Remote Dekstop Connection :) Please Help Me.
Tutorial Detail. Please


Important to know: If you want to use RDP in order to access to a VM the guest system in the VM must support it! Not like e.g. VirtualBox which itself supports RDP access for any guest system. In other words: the topic is not a Proxmox specific issue.

Assuming you have Windows guests they will listen for RDP connections at port 3389 you have to forward to that port e.g. (when accessing to VM at 10.21.21.5 via port 3301) as follows:

Code:
iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 3301 -j DNAT --to-destination 10.21.21.5:3389
 
hi. Will it be like this later?

Code:
auto vmbr2
iface vmbr2 inet static
    address 10.21.21.254
    netmask 255.255.255.0
    bridge_ports none
    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.21.21.0/24' -o vmbr0 -j MASQUERADE
    post-down iptables -t nat -D POSTROUTING -s '10.21.21.0/24' -o vmbr0 -j MASQUERADE
    post-up iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 3301 -j DNAT --to 10.21.21.1:3389
    post-down iptables -t nat -D PREROUTING -i vmbr0 -p tcp --dport 3301 -j DNAT --to 10.21.21.1:3389
    post-up iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 3302 -j DNAT --to 10.21.21.2:3389
    post-down iptables -t nat -D PREROUTING -i vmbr0 -p tcp --dport 3302 -j DNAT --to 10.21.21.2:3389
    post-up iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 3303 -j DNAT --to 10.21.21.3:3389
    post-down iptables -t nat -D PREROUTING -i vmbr0 -p tcp --dport 3303 -j DNAT --to 10.21.21.3:3389
    post-up iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 3304 -j DNAT --to 10.21.21.4:3389
    post-down iptables -t nat -D PREROUTING -i vmbr0 -p tcp --dport 3304 -j DNAT --to 10.21.21.4:3389
    post-up iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 3305 -j DNAT --to 10.21.21.5:3389
    post-down iptables -t nat -D PREROUTING -i vmbr0 -p tcp --dport 3305 -j DNAT --to 10.21.21.5:3389
    post-up iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 3306 -j DNAT --to 10.21.21.6:3389
    post-down iptables -t nat -D PREROUTING -i vmbr0 -p tcp --dport 3306 -j DNAT --to 10.21.21.6:3389

Explanation please. thank you
 

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!