0

I have a server with RedHat 6.5, this has the NIC eth2 connected to the internet at address 1.2.3.4. On this server I have installed VirtualBox 4.3.2 and created a VM with Windows Server 2012 SR2, the win VM has a NAT connection and Host Only connection and IP Adress 192.168.56.101. The host only connection is defined at Linux level as vboxnet0, below the partial output of command ip addr show:

4: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
link/ether 2c:76:8a:5a:b4:c2 brd ff:ff:ff:ff:ff:ff
inet 1.2.3.4/27 brd 1.1.1.1 scope global eth2
inet6 fe80::2e76:8aff:fe5a:b4c2/64 scope link
   valid_lft forever preferred_lft forever

9: vboxnet0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000
link/ether 0a:00:27:00:00:00 brd ff:ff:ff:ff:ff:ff
inet 192.168.56.1/24 brd 192.168.56.255 scope global vboxnet0
inet6 fe80::800:27ff:fe00:0/64 scope link
   valid_lft forever preferred_lft forever

Remote desktop is enabled on the VM win box, I can successfully connect from the Linux box using rdesktop 192.168.56.101.

What I want to do is to be able to RDP connect the vm win box from the internet, ie to 1.2.3.4:3389, by forwarding the request to 192.168.56.101:3389. Forwarding is enabled, I am using the following iptables rules, but it doesn't work.

iptables -A INPUT -p tcp --dport 3389  -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -t nat -A PREROUTING -d 1.2.3.4 -p tcp --dport 3389 -j DNAT --to 192.168.56.101:3389 
iptables -A FORWARD -p tcp --dport 3389 -d 192.168.56.101 -j ACCEPT
iptables -t nat -A POSTROUTING -p tcp --dport 3389 -d 192.168.56.101 -s 192.168.56.101 -j MASQUERADE

Can anybody help? I am stuck.

Thanks for any help.

2
  • VirtualBox is not suitable for this. Use the KVM virtualization included with RHEL. Jan 16, 2015 at 18:26
  • Hi thanks for your reply. Why do you think Virtual Box is not suitable? Would the iptables rules in my question work with KVM? thanks Jan 17, 2015 at 9:07

1 Answer 1

0

So I followed Michael Hampton hint, I created a vm using KVM and I added the following iptables rules

iptables -t nat -I PREROUTING -p tcp -d 1.2.3.4 --dport 3389 -j DNAT --to-destination   192.168.122.1:3389
iptables -t nat -I PREROUTING -p udp -d 1.2.3.4 --dport 3389 -j DNAT --to-destination 192.168.122.1:3389
iptables -I FORWARD -m state -d 192.168.122.1 --state NEW,RELATED,ESTABLISHED -j ACCEPT

All is working now. The iptables rules were adapted from the ones provided in this post:

Forwarding ports to guests in libvirt / KVM

Thanks, regards

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .