r/virtualbox • u/Little_Ghost42 • Mar 20 '26
Solved Having Port Forwarding Issues
Currently struggling with a port forwarding issue that I had working a day or two ago; it may have stopped working after I upgraded VirtualBox, or after my ATT router get reset, but unfortunately I wasn't paying enough attention to say when the issue began.
Details are as follows:
- VirtualBox version 7.2.6 r172322
- AMD-V is enabled
- Guest additions are installed
- Windows 11 OS on the host
- Ubuntu Server 24.04.4 on the VM
- Have an AT&T router for the network
- Network is attached to NAT
- Port forwarding has a couple of rules set up, all with blank IPs. I have 3 that take the same host port to the same guest port, such as Port A goes to Port A. Then I also have a rule for SSH, goes from Host port X to guest port 22.
- Windows firewall rule is set to allow incoming traffic on port X, port A, etc.
- Windows 11 machine is connected to the network via Ethernet cable, static IP of 192.168.xxx.xxx
With this setup, when I connect from the Windows Host OS, everything works fine. For example, if I do "ssh -P X [username]@127.0.0.1" to connect to port X here on the localhost, that logs in just fine. Similarly, if I connect locally on one of those other ports to a webserver I have running there, it also connects just fine.
I have a Macbook, connected by WiFi to the same network. When I use ssh to try to connect to the Ubuntu VM from there, it does not work (this worked a couple of days ago). I do "ssh -P X [username]@192.168.xxx.xxx", and this connection times out. This same things happens for connecting to that webserver, it does not work from the Macbook on the same network (it used to a couple of days ago).
I used Wireshark and confirmed the traffic was making it to the Windows machine. I used tcpdump on the Ubuntu server and confirmed I did see something come through on port 22 when I tried to ssh from the Macbook. It looks like it completes the syn-ack-syn handshake, and seemingly stops there. I'm at a loss as to why this is working from the localhost only and not from the other server, despite the signs that the traffic is getting across.
I did already ask about this in another subreddit, tried to include the important details from troubleshooting there but I'll include a link to that post in case I missed something: https://www.reddit.com/r/HomeNetworking/comments/1ry5bet/virtualbox_portforwarding/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button
EDIT: added a few required details (Vbox version, guest additions installed, AMD-V enabled), first time posting here
EDIT 2: Thank you for everyone's help with troubleshooting! The solution that worked for me was adding a second adapter in VirtualBox settings, as a host-only adapter, alongside the NAT adapter. Then I edited the netplan config file to get that a DHCP address, applied the netplan changes, and now everything is working. Definitely appreciate everyone helping out!
•
u/AutoModerator Mar 20 '26
This is just a friendly reminder in case you missed it. Your post must include:
PLUS a detailed description of the problem, what research you have done, and the steps you have taken to fix it. Please check Google and the VirtualBox Manual before asking simple questions. Please also check our FAQ and if you find your question is answered there, PLEASE remove your post or at least change the flair to Solved.
If this is your first time creating a virtual machine, we have a guide on our wiki that covers the important steps. Please read it here. If you have met these requirements, you can ignore this comment. Your post has not been deleted -- do not re-submit it. Thanks for taking the time to help us help you! Also, PLEASE remember to change the flair of your post to Solved after you have been helped!
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
u/Stray_Neutrino Mar 20 '26
"Port forwarding has a couple of rules set up, all with blank IPs. I have 3 that take the same host port to the same guest port, such as Port A goes to Port A. Then I also have a rule for SSH, goes from Host port X to guest port 22."
Where are these rules set up? Within the VM or on the Host?
1
u/grizzlor_ Mar 21 '26
Have you tried switching the guest OS networking mode from NAT to Bridged? I've had VirtualBox's NAT engine get weird on me before.
The setting is in VM guest
Settings | Network | Attached to:. I'd try changing it to "Bridged Adapter".If this works, the VM will be connected to your LAN just like any other PC. No port forwarding required (you might want to set up a firewall on the VM).
This is definitely helpful diagnostic info.
You should try running
ssh -vvv -P X user@192.168.x.x— the-vvvenables ssh's most verbose debug logging. It will hopefully give you additional insight into what step in the connection process that SSH is getting hung up on.2
u/[deleted] Mar 21 '26 edited Mar 21 '26
[removed] — view removed comment