Skip to content

Instantly share code, notes, and snippets.

@sutlxwhx
Last active March 13, 2024 14:44
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 9 You must be signed in to fork a gist
  • Save sutlxwhx/176198f9ffbdd40eec178817b3d9b988 to your computer and use it in GitHub Desktop.
Save sutlxwhx/176198f9ffbdd40eec178817b3d9b988 to your computer and use it in GitHub Desktop.
Enable RDP and access to the virtual machines for your Proxmox installation

Introduction

This tuturial will help you configure network for your fresh Proxmox istallation.
Be aware that Proxmox configuration was made using this tutorial.

Installation

Backup your current /etc/network/interfaces using this command:

cp /etc/network/interfaces /etc/network/interfaces.backup

Download it to your local machine. You may need it for debugging later.
Then you need to configure your /etc/network/interfaces as in the following example:

### Hetzner Online GmbH installimage

source /etc/network/interfaces.d/*

auto lo
iface lo inet loopback
iface lo inet6 loopback

# The followind three things will be here somewhere when you open this file for the first time.
# Depending on your server provider you may not be needed to change anything in this section
# $IP - your IP address.
# $GT - your network gateway.
# $NT - your network netmask.
# $RT - you network route. It consist of first three values from your IP and the last one is used from your netmask.
# For example if you have IP 111.2.33.4 and netmask 255.255.255.666 your RT will look like 111.2.33.666

auto eno1
iface eno1 inet static
	address $IP
	netmask $NT
	gateway $GT
	up route add -net $RT netmask $NT gw $GT dev eno1

# Here you will have your own default IPv6 settings
# If you don't need to customize IPv6 access for your Proxmox then leave the default settings

iface eno1 inet6 static
	address aaaa:bbb:ccc:ddd::2
	netmask 64
	gateway eeee::1

# In the following section we will setup new network interface for our virtual machines
# I used it with Intel network adapter for my Windows virtual machine in Proxmox

auto vmbr1
iface vmbr1 inet static
address 192.168.1.1
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 '192.168.1.0/24' -o eno1 -j MASQUERADE
post-down iptables -t nat -D POSTROUTING -s '192.168.1.0/24' -o eno1 -j MASQUERADE

Now we will need to save this file and enable the custom network interface that we created earlier.
Use the following command to do this:

ifup vmbr1

If you want to use RDP for your virtual Windows OS machine you need to create this port forwading rule for a default 3389 Windows RDP port:

iptables -t nat -A PREROUTING -i eno1 -p tcp --dport 13389 -j DNAT --to 192.168.1.2:3389

Repeat that as a template for any other port / application you need. I just appended 1 to the 3389 port and now I can acess my Windows virtual machine at $IP:13389
If you want to use RDP for your virtual Ubuntu OS machine you need to setup the neccessary environment:

apt-get -y update
apt-get -y install openssh-server
apt-get -y install xrdp
apt-get -y install mate-core mate-desktop-environment mate-notification-daemon
echo -e "mate-session" >> /etc/xrdp/startwm.sh
service xrdp restart
iptables -t nat -A PREROUTING -i eno1 -p tcp --dport 23389 -j DNAT --to 192.168.1.4:3389

Here I appended 2 to the 3389 port so my Ubuntu OS was accessible at $IP:23399

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment