Networking: Linux Guest, Host-Only+NAT, unable to ssh in.

Discussions related to using VirtualBox on Linux hosts.
Post Reply
refactored
Posts: 21
Joined: 11. Nov 2008, 17:12
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows, Linux

Networking: Linux Guest, Host-Only+NAT, unable to ssh in.

Post by refactored »

Further to another thread, I've configured 2 NICs in my CentOS guest. VBoxAdditions are installed.

eth0 is set to NAT, with DHCP enabled. eth1 is set to "Host Only", with a static IP:

Code: Select all

DEVICE=eth1
ONBOOT=yes
IPADDRESS=192.168.57.101
NETMASK=255.255.255.0
NETWORK=192.168.57.0
BROADCAST=192.168.57.255
BOOTPROTO=none
TYPE=Ethernet
eth0 and eth1 have to be taken down and brought back up after booting before they'll work.

The host-only adapter is set to 192.168.57.1, with DHCP enabled on 192.168.57.100 (range 101 to 254).

The guest can successfully ping itself, ping google.com, and ssh into itself. It can't ping the DHCP server, nor the host on either it's real network address or 192.167.57.1.

The host can successfully ping the guest, but can't be accessed via ssh. It looks as though vboxnet0 is configured correctly on the host.

Can someone advise as to why the host can't communicate with the guest other than by pinging?
 Edit: Fixed a typo. 
Last edited by refactored on 7. Aug 2009, 15:32, edited 1 time in total.
baf
Volunteer
Posts: 829
Joined: 27. Sep 2008, 06:18
Primary OS: Mac OS X Leopard
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: linux,xp,win7
Location: Luleå or Skellefteå, Sweden

Re: Networking: Linux Guest, Host-Only+NAT, unable to ssh in.

Post by baf »

your broadcast does not match the rest
IPADDRESS=192.168.57.101
NETWORK=192.168.57.0
BROADCAST=192.168.56.255
Shouldn't that be a 57 instead?
Some say: "You learn as long as you live".
My way: "You live as long as you learn".
refactored
Posts: 21
Joined: 11. Nov 2008, 17:12
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows, Linux

Re: Networking: Linux Guest, Host-Only+NAT, unable to ssh in.

Post by refactored »

Sorry, it is actually 57 - that was a typo while duplicating the details for the post.
baf
Volunteer
Posts: 829
Joined: 27. Sep 2008, 06:18
Primary OS: Mac OS X Leopard
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: linux,xp,win7
Location: Luleå or Skellefteå, Sweden

Re: Networking: Linux Guest, Host-Only+NAT, unable to ssh in.

Post by baf »

OK how does the output from

Code: Select all

ifconfig -a 
netstat -rn
look from both the host and the guest
also in the guest:

Code: Select all

netstat -an|egrep "^tcp.*LISTE"
Some say: "You learn as long as you live".
My way: "You live as long as you learn".
refactored
Posts: 21
Joined: 11. Nov 2008, 17:12
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows, Linux

Re: Networking: Linux Guest, Host-Only+NAT, unable to ssh in.

Post by refactored »

baf: thanks for the response. I don't have access to the machine right now, but when I get back to it is there anything I should be looking for from those commands that would stand out or might be missing? I know that `ifconfig -a` showed that the IPs were set correctly for both interfaces, and that ssh was listening on `tcp :::22`. I tried ssh changing the Host in /etc/ssh/ssh_config from "*" to "192.168.57.101" but no joy.

I'll give more details when I'm back in-front of the machine. :)
baf
Volunteer
Posts: 829
Joined: 27. Sep 2008, 06:18
Primary OS: Mac OS X Leopard
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: linux,xp,win7
Location: Luleå or Skellefteå, Sweden

Re: Networking: Linux Guest, Host-Only+NAT, unable to ssh in.

Post by baf »

if tcp :::22 was the only mention of 22 then its only listening on ipv6 which probably wont work.
you should also have a line like

Code: Select all

tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN  
Some say: "You learn as long as you live".
My way: "You live as long as you learn".
refactored
Posts: 21
Joined: 11. Nov 2008, 17:12
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows, Linux

Re: Networking: Linux Guest, Host-Only+NAT, unable to ssh in.

Post by refactored »

I see. That's odd, because the machine I'm using right now has the same guest OS and it has the same entry (:::22), doesn't have an entry for 0.0.0.0:22, but I can still SSH in. This guest uses a static IP on the host's network though - not sure whether that would make a difference.

I'll see whether I can find some details on how to configure SSH correctly for dual NICs.

That doesn't explain why I can't ping the host's dhcp server. Is that possible at all, or is it disabled?
baf
Volunteer
Posts: 829
Joined: 27. Sep 2008, 06:18
Primary OS: Mac OS X Leopard
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: linux,xp,win7
Location: Luleå or Skellefteå, Sweden

Re: Networking: Linux Guest, Host-Only+NAT, unable to ssh in.

Post by baf »

Well default config is ipv4+ipv6 all interfaces but have you tried restarting sshd after you have the interfaces started?
It feels odd that you have to bring them up and down.

You could try explicitly enabling it in sshd_config with

Code: Select all

Port 22
AddressFamily any
ListenAddress 0.0.0.0
ListenAddress ::
And then restarting sshd.
Some say: "You learn as long as you live".
My way: "You live as long as you learn".
refactored
Posts: 21
Joined: 11. Nov 2008, 17:12
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows, Linux

Re: Networking: Linux Guest, Host-Only+NAT, unable to ssh in.

Post by refactored »

baf wrote:have you tried restarting sshd after you have the interfaces started?
Yes; I've seen similar issues before. No joy.
baf wrote:It feels odd that you have to bring them up and down.
I'd put this down to the fact that there are 2 NICs - I've heard that if they start in the wrong order, you have to restart them in order to get them working. Usually a problem when they're both the same card make/model. I've just not gotten round to fixing this yet. I'll probably change the 2nd NIC's card model to help with this.

I'll try changing the SSH config and see where I get.

Any idea on pinging the host from the guest? Just so if ssh doesn't work I know they're still communicating.
baf
Volunteer
Posts: 829
Joined: 27. Sep 2008, 06:18
Primary OS: Mac OS X Leopard
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: linux,xp,win7
Location: Luleå or Skellefteå, Sweden

Re: Networking: Linux Guest, Host-Only+NAT, unable to ssh in.

Post by baf »

Well without seeing ifconfig and netstat output its hard to guess.
Some say: "You learn as long as you live".
My way: "You live as long as you learn".
refactored
Posts: 21
Joined: 11. Nov 2008, 17:12
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows, Linux

Re: Networking: Linux Guest, Host-Only+NAT, unable to ssh in.

Post by refactored »

Interesting; with the vbox management program running but without the vm running it still pings.
Post Reply