Search code examples
virtualboxfirewallnat

Virtualbox: Using firewall in ubuntu guest


I have windows 7 pro host with ubuntu server 12.10 as guest. The host has a static ip. The networking mode is NAT with port forwarding from host port 22 to guest port 22. I don't want to use use bridged networking because of company policies.

I need to ssh (port: 22) into the guest from the internet and I want to limit inbound connections to guest port 22 to certain ip addresses. So I enabled ufw in the guest and added rules to it. When I try to ssh into the guest from one of the allowed ip addresses, it's not connecting. If I disable ufw, it works.

What could be wrong? I don't know much about NAT and guest firewalls.

Thanks in advance for your response.


Solution

  • this is normal, because the guest VM (Ubuntu) will receive the connection from the NAT Gateway IP (ie the host (Win7) address) and not the client who is connecting to ssh.

    to solve this issue , you will need to remove ufw rules and set the same rules in the host windows firewall.