Cannot connect to my Virtual Box Ubuntu system
Solution 1
So here are in one answer a summary of my comments.
You have 3 solutions depending on your environment:
A. Your Windows host is connected to a network
1- Use "Bridge networking"
And select the Windows network interface that is configured under Windows to have network access.
Make sure you have no firewall on Ubuntu: sudo iptables -L
should give you no rules.
2- Use "NAT" with port-forwarding
Select NAT and unflod the advanced settings of the NAT interface in VirtualBox settings. Then you click on the Port Forwarding
button and create a new rule, you name it "telnet" (or whatever you prefer), protocol should be "TCP", leave the fields Host and Guest IP empty, but set the Host and Guest Port to 23.
Check the external IP address of the VM to access it. This IP address is the same one as for the VirtualBox Host-only network, you can check the IP in Windows networking center by clicking on the interface and displaying its status/details. Or you can check in VirtualBox preferences (not the VM Settings, but the VirtualBox preferences) under network, check the IP address of the Host-only ethernet adpater (click on the Edit button of this interface).
Make sure you have no firewall on Ubuntu: sudo iptables -L
should give you no rules.
B. Your Windows host has no network
Use "Host-only" networking. Nothing else to configure.
The IP address to use is the one given in Ubuntu when you run ifconfig
.
Make sure you have no firewall on Ubuntu: sudo iptables -L
should give you no rules.
Solution 2
I'm pretty sure this is problem with network configuration on you VirtualBox.
Open up VM settings:
Make sure you select Bridged Adapter ( I expect you have NAT configured which does not allows to route connections from outside to your VM)
Select available network card (I used MS Loopback adapter, on your PC it will be different)
Related videos on Youtube
Preeyah
Professional Software Testing Engineer specializing in automation with Open Source tools. Interested in: Test automation: Selenium, BDD, Cucumber Programming: Java, Python, Spring Data scraping Audio: recording/mixing
Updated on September 18, 2022Comments
-
Preeyah over 1 year
I have a VirtualBox running an Ubuntu OS. I'd like to access this Ubuntu machine using
ssh
ortelnet
. In order to do that I've performed the following steps:sudo apt-get install telnetd
sudo /etc/init.d/openbsd-inetd restart
Then I tried to access this system using telnet from another machine but unfortunately the connection become timed out:
# telnet 10.125.31.176 Trying 10.125.31.176... telnet: connect to address 10.125.31.176: Connection timed out telnet: Unable to connect to remote host: Connection timed out
Also I'd like to mention that I could easily ping this machine (both ways):
# ping 10.125.31.176 PING 10.125.31.176 (10.125.31.176) 56(84) bytes of data. 64 bytes from 10.125.31.176: icmp_seq=1 ttl=57 time=2.34 ms 64 bytes from 10.125.31.176: icmp_seq=2 ttl=57 time=1.81 ms
EDIT: I have also performed the open ports scan and it seems ok:
$ sudo nmap -p 20-2550 localhost Starting Nmap 5.00 ( http://nmap.org ) at 2012-06-11 15:31 IDT Warning: Hostname localhost resolves to 2 IPs. Using 127.0.0.1. Interesting ports on localhost (127.0.0.1): Not shown: 2526 closed ports PORT STATE SERVICE 22/tcp open ssh 23/tcp open telnet 25/tcp open smtp 587/tcp open submission 631/tcp open ipp Nmap done: 1 IP address (1 host up) scanned in 1.54 seconds
EDIT2: ifconfig from the VirtualBox Ubuntu:
eth0 Link encap:Ethernet HWaddr 08:00:27:0d:43:7d inet addr:10.125.31.176 Bcast:10.125.31.255 Mask:255.255.255.0 inet6 addr: fe80::a00:27ff:fe0d:437d/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:9247631 errors:0 dropped:0 overruns:0 frame:0 TX packets:10147 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:3145994247 (3.1 GB) TX bytes:727714 (727.7 KB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:30446 errors:0 dropped:0 overruns:0 frame:0 TX packets:30446 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:1280714 (1.2 MB) TX bytes:1280714 (1.2 MB)
Windows IP Configuration
Ethernet adapter Local Area Connection: Connection-specific DNS Suffix . : xxx.com IP Address. . . . . . . . . . . . : 10.125.31.170 Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : 10.125.31.1 Ethernet adapter VirtualBox Host-Only Network: Connection-specific DNS Suffix . : IP Address. . . . . . . . . . . . : 192.168.56.1 Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . :
Any ideas?
-
milo5b almost 12 yearsDid you check if the correct port is open with nmap or similar programs?
-
Preeyah almost 12 yearsYeah, sure. I added and EDIT to my answer.
-
Alex Chamberlain almost 12 yearsCan you run
ifconfig
on both host and VM please? -
Preeyah almost 12 years@AlexChamberlain Added as EDIT2!
-
Alex Chamberlain almost 12 yearsSo, is it a Windows host and Ubuntu VM? Are there any logs on the Ubuntu machine if you try and SSH in?
-
Preeyah almost 12 years@AlexChamberlain This is correct. I have an Ubuntu running on Virtual Box. Can you pleas elaborate which logs do you mean?
-
Alex Chamberlain almost 12 years
less /var/log/auth.log
-
Preeyah almost 12 years@AlexChamberlain I've performed
tail -f
on that file and triet to access the machine withtelnet
andssh
, but nothing reflected in that log. It remained as it was.. -
lgarzo almost 12 yearsIs this a bridged interface?
-
Preeyah almost 12 years@lgarzo Yes, I've configured Network Adapter to be "Bridged Adapter" in Virtual Box manager for that machine.
-
lgarzo almost 12 yearsWhat about the windows firewall? Is it enabled?
-
Preeyah almost 12 years@lgarzo I'm not sure. How can I check it? Could this be the issue, since I can ping both ways..
-
lgarzo almost 12 yearsOn Windows XP: Control Panel > Windows Firewall. There is an option to turn the firewall off. On later versions something similar, with UAC intervention (depending on the configuration).
-
Preeyah almost 12 years@lgarzo The firewall is not running.
-
lgarzo almost 12 yearsCan you telnet localhost in the VM? Also I'd try a full VM restart and see if the problem goes away.
-
jippie almost 12 yearsTelnetd is considered bad practice these days. Don't use it, don't run the daemon on your system. Use sshd instead. Spend your time learning about a secure way of connecting to your system instead of something that makes your server vulnerable by design.
-
Huygens almost 12 yearsOr you can leave it to NAT, but you have to click on the
Port Forwarding
button and Set a new rule, you name it "telnet", protocol should be "TCP", leave the fileds Hos and Guest IP empty, but set the Host and Guest Port to 23. -
Poochie almost 12 years@Huygens, +1 you are correct, but I think for OP is probably more easy to setup it this way.You can also post this as answer.
-
lgarzo almost 12 yearsIt is a bridged adapter (as was discussed in the comments). But selecting the correct adapter might help.
-
Preeyah almost 12 yearsThank you for your answer. So regarding the first point, I do have Bridged Adapter configured. I've configured the "Microsoft Loopback Adapter", as you proposed (I had to install it on my Windows first). But then, after I restarted the virtual machine, I was not able to reach the PC from the VM and vice versa.
-
Preeyah almost 12 yearsI'm sorry for being such a noob but I'm not sure I know how to do that. Maybe you could give me some directions here? The IP of the PC on which the VirtualBox is running is 10.125.31.170 and the IP I see from the VM is 10.125.31.176 (it all appears in my question). When you say that I should reconfigure the IP, you mean that I should manually enter the TCP/IP properties for that Loopback adapter? Thank you!
-
Huygens almost 12 yearsI think you don't need to use the Loopback adapter unless your windows computer is not connected to a network. But in this case, I would use "Host-only networking" VirtualBox will configure an internal loopback interface automatically for you.
-
Preeyah almost 12 yearsThank you for your detailed answer! So since I have my Windows host connected to the network I used the first option, which is using Bridged Connection. I chose the "Broadcom NetXtreme 57xx Gigabit Controller" which is an actual physical controller installed on the PC. I've also checked that there are no firewall configured in Ubuntu. After starting the machine I got the exact condition I had from the very beginning.. I can ping both ways inside the network (I have few Linuxes in the network). I can ssh to all these from Ubuntu. The only problem is that I cannot ssh TO this Ubuntu system.
-
Huygens almost 12 yearsWhen you are on one of your Linux boxes, what does ssh tells you when you ask it to be verbose? Like with
ssh -v <USER VM>@<IP VM>
? And you confirm that from another Linux boxes you canping <IP VM>
and it is working? What aboutsudo nmap -A <IP VM>
(not using localhost, but really being from another Linux machine and entering the IP address of the VM)? -
Preeyah almost 12 yearsVerbose output of the ssh give only the following:
OpenSSH_4.3p2, OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008 debug1: Reading configuration data /etc/ssh/ssh_config debug1: Applying options for * debug1: Connecting to 10.125.31.176 [10.125.31.176] port 22
. I afraid it will be impossible tonmap
from another machine since the rest of them are Red Hats with nonmap
on them.. -
Preeyah almost 12 yearsI've just noticed that I can
telnet
ANDssh
to that Ubuntu system from Windows(on which the VB is running) and the connection succeeded! However I still can'tssh
to that Ubuntu from any other Linux system. This is really getting strange for me.. -
Preeyah almost 12 yearsI have installed an nmap for windows application and scanned the Ubuntu from windows. According to its results, the 22 ssh port is open. Moreover, since I just realized that I actually can ssh to this system from windows, it seems that the issue now is "No ssh access to Ubuntu system from another Linux machine". It's getting really complicated to explain all this.. It seems that there is something blocking ssh only to this Ubuntu (ssh to other Linuxes is fine). Any ideas?
-
Huygens almost 12 years@EugeneS to me it looks like Windows (which is hosting your VM) can access your VM as it should be whereas outside computers cannot (please confirm this view), so I would say that something on the Windows host is blocking access to your VM. Checl all possible security tools installed on your Windows (Antivirus, Firewall, etc.) try to temprarily inhibit them (don't connect to the internet from this host while doing so) and see if it gets better. Finally, try to get Ubuntu on a USB Stick and start an external machine with it, install nmap and scan the VM from there.