Virtual Machine with Bridged Adapter to Centos not accepting ssh from host machine

1

I have a bridged connection on VirtualBox from os/x 10.8.5 host to Centos 5.8 client.

But I suspect this is more of a general issue than specific to the host and precise version of linux.

Shown below are the networking info from the VirtualBox and from within the guest

sshd is running on port 22:

[root@oracle-linux ~]# ps -ef | grep sshd | grep -v grep
root      3103     1  0 20:22 ?        00:00:00 /usr/sbin/sshd
root     14994  3103  0 21:23 ?        00:00:00 sshd: root@pts/1 

Netstat:

[root@oracle-linux ~]# netstat -an |  grep tcp | grep LIST
tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN      
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      
tcp        0      0 127.0.0.1:631               0.0.0.0:*                   LISTEN      
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      
tcp        0      0 0.0.0.0:954                 0.0.0.0:*                   LISTEN      
tcp        0      0 127.0.0.1:2207              0.0.0.0:*                   LISTEN      
tcp        0      0 127.0.0.1:2208              0.0.0.0:*                   LISTEN      
tcp        0      0 :::22                       :::*                        LISTEN      

Firewall is disabled:

[root@oracle-linux init.d]# service iptables status
Firewall is stopped.

Here are ip addresses, GUEST (after change to BRIDGE): :

[root@oracle-linux ~]# ifconfig -a
eth0      Link encap:Ethernet  HWaddr 08:00:27:B9:E5:79  
          inet addr:10.0.15.100  Bcast:10.0.15.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:feb9:e579/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:46 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 b)  TX bytes:6754 (6.5 KiB)

eth1      Link encap:Ethernet  HWaddr 08:00:27:B4:86:8A  
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

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:1064 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1064 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:1799516 (1.7 MiB)  TX bytes:1799516 (1.7 MiB)

HOST:

c1166313@ma2-gbip-lap105's password: 
06:46:37/shared:7 $ifconfig -a
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
    options=3<RXCSUM,TXCSUM>
    inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 
    inet 127.0.0.1 netmask 0xff000000 
    inet6 ::1 prefixlen 128 
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
stf0: flags=0<> mtu 1280
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    ether b8:f6:b1:15:dd:bf 
    inet6 fe80::baf6:b1ff:fe15:ddbf%en0 prefixlen 64 scopeid 0x4 
    inet 10.0.0.7 netmask 0xffffff00 broadcast 10.0.0.255
    media: autoselect
    status: active
p2p0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 2304
    ether 0a:f6:b1:15:dd:bf 
    media: autoselect
    status: inactive
vboxnet0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    ether 0a:00:27:00:00:00 
    inet 192.168.7.1 netmask 0xffffff00 broadcast 192.168.7.255

I can ssh to the guest from the guest:

root@oracle-linux ~]# ssh 10.0.3.15
The authenticity of host '10.0.3.15 (10.0.3.15)' can't be established.
RSA key fingerprint is ef:08:19:72:95:4d:e5:28:af:f3:6f:54:07:84:ba:04.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.0.3.15' (RSA) to the list of known hosts.
root@10.0.3.15's password: 
Last login: Mon Oct 21 21:24:12 2013 from 10.0.15.100

But can NOT ssh from the host to the guest:

18:27:04/shared:11 $ssh  root@10.0.3.15
ssh: connect to host 10.0.15.100 port 22: Operation timed out
lost connection

Here is bridged connection infO;

enter image description here

Adapter 2 is a NAT, shown below

enter image description here

In case NAT is causing any issues, i shut it down and restarted networking.

[root@oracle-linux ~]# /etc/init.d/network restart
Shutting down interface eth0:                              [  OK  ]
Shutting down interface eth1:  

Still No joy..

18:27:04/shared:11 $ssh  root@10.0.3.15
ssh: connect to host 10.0.15.100 port 22: Operation timed out
lost connection

BTW: as part of troubleshooting I brought up a different Centos VM (version 6.2). This other VM is from a different vendor (cloudera) but I configured it also as Bridged adapter. The second VM works fine.

07:03:23/shared:12 $ping  10.0.0.9
PING 10.0.0.9 (10.0.0.9): 56 data bytes
64 bytes from 10.0.0.9: icmp_seq=0 ttl=64 time=0.350 ms
64 bytes from 10.0.0.9: icmp_seq=1 ttl=64 time=0.337 ms
64 bytes from 10.0.0.9: icmp_seq=2 ttl=64 time=0.339 ms

javadba

Posted 2013-10-22T02:02:33.177

Reputation: 2 201

Can you show Adapter 2 bridged connection info. – HTTP500 – 2013-10-22T02:14:39.117

@http500 added adapter 2 info, and tried killing NAT. No change. – javadba – 2013-10-22T02:24:00.333

did you configure the firewall on the host? – Ben Plont – 2013-10-22T03:41:27.240

What's the IP info for your host? Are they on the same subnet? What are the routing info for your host and your guest? Note: if you have Adapter 2 as NAT, then you're not bridging, you're NAT'ing. Those are two different things. Also, why does your guest need 2 adapters? – CIA – 2013-10-22T03:43:51.183

@BenPlont I have many virtual machines including other Centos that had been working fine with bridged adapters. Just this one is not working. – javadba – 2013-10-22T05:04:44.790

@CIA I do not need two adapters. I have tried various combinations: including just Bridged, just NAT. No change. It beats me. – javadba – 2013-10-22T05:05:37.010

@javadba don't use NAT. For the bridged adapter, make it one of the physical NICs and not the wifi NIC. Show us the guest and host ifconfig. Show us the host and guest netstat -rn – CIA – 2013-10-22T12:17:40.147

@CIA thanks for helping! I am adding the items requested. The guest ifconfig was already there. I have replaced netstat -an with netstat -m per your request. – javadba – 2013-10-22T13:50:37.533

@CIA netstat -m does not exist, but I updated the output for netstat -an – javadba – 2013-10-22T13:58:34.600

@javadba Your laptop is on the 10.0.0.0/24 network and your guestVM is either on the 10.0.15.0/24 or 10.0.3.0/24 network. I can't tell, because you keep changing configs and not updating the info in the question. Unless you have a route built that points 10.0.0.0/16 to the bridge point, these two networks will never communicate properly. This indicates you don't have a proper bridge set up; otherwise, they'd be on the same subnet. – CIA – 2013-10-22T14:34:18.070

@CIA Apparently dhclient is not doing the right thing - i should not have to manually set the network. I will look into how to do that. – javadba – 2013-10-22T14:37:21.570

@CIA After running dhclient I got a CORRECT ip address (on the same network as host) on the GUEST 10.0.0.11. Now it WORKED. – javadba – 2013-10-22T14:38:55.687

Answers

1

The issue was that /etc/network-scripts/ifcfg-eth0 had static IP address set:

BOOTPROTO=static
BROADCAST=10.0.15.255

The solution was to remove those and set dhcp:

BOOTPROTO=dhcp

Note: user CIA started to point the way here by mentioning the incorrect subnet for the guest.

javadba

Posted 2013-10-22T02:02:33.177

Reputation: 2 201

-1

You can specify host to host network for your VM and you should be able to ssh from host to guest.

Sanjaya Athukorala

Posted 2013-10-22T02:02:33.177

Reputation: 1