This question is all over the place, but I have found no answers to help me solve it!
I set up a Minecraft Bedrock server (version 18.104.22.168) on an Ubuntu 18.04 VM running on VirtualBox (hosted on my Windows 10 desktop), and have forwarded UDP port 19132 in my router to the VM. (Note: ufw is currently disabled in Ubuntu).
I can happily connect to it from within the LAN (ie. from my Windows 10 computer, using the LAN IP of the server), but any attempt to connect to it via my public IP address fails with the usual 'Unable to connect to world' error message.
Running tcpdump on the VM and watching UDP port 19132, I can see a steady trickle of packets reaching the VM while I have the Minecraft app open and am in the Servers list with my server added at the bottom (using the public rather than private IP), indicating the client is polling the server. The client shows the server as offline though. Similarly, when I try to connect, I see an increased flow of packets arriving and yet no connection. I know my port forwarding is set up correctly (according to the instructions provided), but still no joy.
To be certain, I have also tried connecting to the server using an iPad outside the LAN - no dice.
Most interesting clue I have found so far was the commentary in this bug report: https://bugs.mojang.com/browse/BDS-85
Per the comments there, I tried creating a 'minecraft' user with home directory /opt/minecraft and running the server from there. Sadly, this had no impact.
UPDATE: I have also tried running the server directly on my Windows 10 host now also. Same behaviour results here also (with router port forwarding rule updated to the new host IP).