I can get internet on guest by setting vbox adapter 1 to bridged network adapter
and host-guest communication works when I set adapter 2 as a host-only adapter
This is sufficient if I don't want to use a firewall, but I do... with this solution I need to constantly fiddle with UFW to allow adapter 1 communication.
After some reading, I realized that I should be able to set up adapter 1 as a nat adapter and configure port forwarding as shown below.
name|proto| host ip | Host port| Guest IP | Guest Port
SSH | TCP | 127.0.0.1 | 2522 | 192.168.52.1 | 22
This way I should be able to ssh into the guest using:
ssh -vvv -p 2522 -i ~/.ssh/id_rsa [email protected]
My problem is that this method simply freezes without explanation.
OpenSSH_8.2p1 Ubuntu-4ubuntu0.4, OpenSSL 1.1.1f 31 Mar 2020
debug1: Reading configuration data /home/user/.ssh/config
debug1: /home/user/.ssh/config line 41: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug2: resolve_canonicalize: hostname 127.0.0.1 is address
debug2: ssh_connect_direct
debug1: Connecting to 127.0.0.1 [127.0.0.1] port 2522.
debug1: Connection established.
debug1: identity file /home/user/.ssh/id_rsa type 0
debug1: identity file /home/user/.ssh/id_rsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.4
(I tested with UFW disabled.)
Everything, says this should work, but it doesn't... any guesses?
If ssh over NAT works, I can ssh into the box and have host-guest communication without constantly editing my firewall.
Progress:
According to @steeldriver's suggestion and this post the correct ip address for port forwarding should be Guest IP = 10.0.2.15
However, when using that that address, ssh can't connect:
OpenSSH_8.2p1 Ubuntu-4ubuntu0.4, OpenSSL 1.1.1f 31 Mar 2020
debug1: Reading configuration data /home/dragonpharaoh/.ssh/config
debug1: /home/dragonpharaoh/.ssh/config line 41: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug2: resolve_canonicalize: hostname 10.0.2.15 is address
debug2: ssh_connect_direct
debug1: Connecting to 10.0.2.15 [10.0.2.15] port 2522
Adapter 2 Host-only
This is my host-only adapter config:
Adapter 1 NAT
Port Forwarding
This is current output of #ifconfig inside the guest
Netstat confirming Vbox listening port
NOTE: Both the host is fairly fresh install (less than a month) and the guest was made today