2

I installed ubuntu server as VM in VirtualBox and then installed Docker in it to run some containers. Installed Portainer in it (so it means the VM is connected to the internet). Now I typed ifconfig to see my IP address and I saw this:

br-70e261a4f7c8: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
    inet 172.18.0.1  netmask 255.255.0.0  broadcast 172.18.255.255
    inet6 fe80::42:66ff:fe9b:a3f7  prefixlen 64  scopeid 0x20<link>
    ether 02:42:66:9b:a3:f7  txqueuelen 0  (Ethernet)
    RX packets 211  bytes 3306540 (3.3 MB)
    RX errors 0  dropped 0  overruns 0  frame 0
    TX packets 228  bytes 33889 (33.8 KB)
    TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
    inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
    ether 02:42:41:c6:88:8c  txqueuelen 0  (Ethernet)
    RX packets 0  bytes 0 (0.0 B)
    RX errors 0  dropped 0  overruns 0  frame 0
    TX packets 0  bytes 0 (0.0 B)
    TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
    inet 10.0.2.15  netmask 255.255.255.0  broadcast 10.0.2.255
    inet6 fe80::a00:27ff:feab:bbc0  prefixlen 64  scopeid 0x20<link>
    ether 08:00:27:ab:bb:c0  txqueuelen 1000  (Ethernet)
    RX packets 89848  bytes 118364599 (118.3 MB)
    RX errors 0  dropped 0  overruns 0  frame 0
    TX packets 39603  bytes 2588176 (2.5 MB)
    TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
    inet 127.0.0.1  netmask 255.0.0.0
    inet6 ::1  prefixlen 128  scopeid 0x10<host>
    loop  txqueuelen 1000  (Local Loopback)
    RX packets 836  bytes 3376136 (3.3 MB)
    RX errors 0  dropped 0  overruns 0  frame 0
    TX packets 836  bytes 3376136 (3.3 MB)
    TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

vethfaa59c1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
    inet6 fe80::c4fd:4aff:fe13:a309  prefixlen 64  scopeid 0x20<link>
    ether c6:fd:4a:13:a3:09  txqueuelen 0  (Ethernet)
    RX packets 211  bytes 3309494 (3.3 MB)
    RX errors 0  dropped 0  overruns 0  frame 0
    TX packets 215  bytes 32719 (32.7 KB)
    TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

This is what I get when using traceroute 8.8.8.8:

traceroute screenshot

The host OS is Windows 7. This made me really confused. I have to say I am really new to Linux, have been using Linux Unity for only around the last 6 months.

At first, I thought 10.0.2.15 is my IP address but I can’t SSH into the VM through PuTTY using it. The only way I can SSH is through port forwarding in the VM and then using 127.0.0.1 through that port from PuTTY but the internet does not work through this process and as expected it will work only on the host os, not outside.

To open Portainer I have to enter https://serverip:port, but what is my server IP? And why can’t I ssh into my VM?

P.S. If I use 10.0.2.15 in putty then it says connection refused and the other "inet's" give connection timed out. I even went as far as to install Openbox and Firefox to check Portainer and localhost:port worked flawlessly... but only inside the VM.

EDIT: This is what I want my server to do (if possible)

  1. I open my computer, run my server VM, open PuTTY and SSH into VM from Windows host but internet connection should be there

  2. Take out my laptop running Windows and then SSH into the VM on my PC from PuTTY

  3. Open browser on my host OS and type https://serverip:port, where port is the port no. of Portainer in my VM server

  4. Take out my laptop and open browser and do step 3 to open Portainer

  5. Take my laptop and go 10 km away from home and do step 2 and 4

The last step will come later but right now none of them are working. Any suggestions?

Melebius
  • 11,750
spamman
  • 21

1 Answers1

0

Wow after so much tinkering, I was able to solve the questions 1,2,3 and 4. maybe it was a very easy thing and i made it complicated for no reason. any way thanks @George Uderson for the website it helped a lot. here is what i did

1) I opened network settings in vm and opened the port forwarding tab. gave a name and put host ip as 127.0.0.1 , port as 22 or anything really, then put guest ip as 10.0.2.x whatever it is and port as 22. open putty and put ip as 127.0.0.1 and port 22 and voila! you are in

2)For this its better to have a fixed ip address of your pc running the vm. i changed it easily in the network properties in win 7. then we can follow the previous step but in place of 127.0.0.1 we put our fixed ip address. then we can use that ip address in putty easily.

3) do same as step 2 or 1 but in place of ports we put the ports used by the container i.e. xxxx

4)same as 3 but only with fixed ip address.

5)dont know how to make that work out of home network.

please correct or edit if i am wrong somewhere. but this worked for me. thanks

spamman
  • 21