0

I asked this question some time ago, and searched for an answer all over the place. But everyone seems to be dodging the question. Or at least that's how a newbie like me sees it. All I find is stuff about connecting to my guest OS, which is the Linux Ubuntu 18.04 on the VirtualBox, from my host OS, which is a Windows 10. However, the point everyone misses is that those two are both on a LAN level. I want to connect to my VM from outside the LAN. I'm learning to setup a proper server and so I want to test everything on a VM before actually buying a Raspberry Pi and starting my server.

Anyways, I have three network cards on my VM. one uses NAT, one uses the Host-Only Network and the other uses Bridged Network. I've configured the port forwarding for my VM's NAT network to use 127.0.0.1 as the Host IP, 2222 as the Host Port, 10.0.2.4 as Guest IP and 22 as Guest Port. I have also executed the sudo ufw allow 22 and sudo ufw allow 2222 commands, as well as configured /etc/netplan/50-cloud-init.yaml file and given my enp0s8, which is the Host-Only interface, a static IP of 192.168.56.101, while the other interfaces each get their IPs from DHCP4. Now, sshing through 127.0.0.1 works fine when doing it from the host OS. So does sshing through the 192.168.56.101 and 192.168.0.194 addresses. I can also ssh from my android phone with JuiceSSH (while connected to the same WLAN, of course!) using the 192.168.0.194 address (the bridged one). But any attempt at trying to connect from outside the (W)LAN ends with a connection failed or timed out error. Oh and I don't have access to my router. Any and I mean ANY help is MUCH appreciated. I'm near losing my mind!!

EDIT1: Sorry if I sound a bit rude or arrogant or anything. It's just that I'm kinda new to the whole networking thing and I've been trying to make this happen for the last 3 weeks. I just want to start my own OpenVPN server and then add a Samba file server to it if I have enough nerves left... But securing a ssh has a higher priority, for maintenance and other stuff

EDIT2: Is it even possible to do this? considering a virtual machine is literally virtual and only exists in it's host machince? Like, let's suppose I did all of the above on a Raspberry Pi. Would I then be able to remotely access my server from outside the (W)LAN?

5
  • The 10. * . * . * host-only network cannot talk to anything outside the host under any circumstances. That's why it is called "host-only."
    – user535733
    Jan 1, 2020 at 23:58
  • Creating a static IP for each VM is the hard part for most folks. Glad to see you figured it out. Since you can connect from another machine on the LAN, it means that your server and firewall are correctly configured. Good job!
    – user535733
    Jan 2, 2020 at 0:00
  • 2
    The problem you have now seems to connecting to the LAN from outside (WAN). The normal way to do this is to use the port-forwarding feature on the router AND by adjusting the router's firewall to not block your connections. Since you cannot control your router, you cannot do this. You can look up how to create a reverse-ssh tunnel to get around the router...BUT that kind of workaround may be considered a very rude (sanctionable!) thing to do on somebody else's network. TALK to the network owner before doing anything...they might be willing to simply set up port forwarding for you.
    – user535733
    Jan 2, 2020 at 0:06
  • reverse-ssh, as in connecting to my host and then forwarding the connection to my guest OS? @user535733
    – CubeMage
    Jan 2, 2020 at 10:46
  • Also, could you copy and paste your three comments into an answer so I can mark this as an answered question?
    – CubeMage
    Jan 2, 2020 at 10:47

1 Answer 1

0

Your problem is different from most folks' first problem, which is usually connecting within the LAN, or creating a predictable IP address on the LAN to connect to. Since you CAN successfully connect to your server within the LAN, your Ubuntu system is configured properly. Congratulations!

The problem you have seems to connecting to the LAN from outside (WAN). The normal way to do this is to use the port-forwarding feature on the router AND by adjusting the router's firewall to not block your connections. Since you cannot control your router, you cannot do this.

You can look up how to create a reverse-ssh tunnel to get around the router...BUT that kind of workaround may be considered a rude thing to do on somebody else's network, and discovery of the reverse-ssh service may cause sanctions (like getting banned from the LAN). Whether it's rude or not depends upon the culture you are operating within.

TALK to the network owner before doing anything...they might be willing to simply set up port forwarding for you. Do not install a reverse-ssh to bypass their router and firewall without their approval.

You must log in to answer this question.

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