LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Virtualization and Cloud (https://www.linuxquestions.org/questions/linux-virtualization-and-cloud-90/)
-   -   VirtualBox NAT to access Linux server as guest (https://www.linuxquestions.org/questions/linux-virtualization-and-cloud-90/virtualbox-nat-to-access-linux-server-as-guest-903863/)

dashesy 09-19-2011 11:44 AM

VirtualBox NAT to access Linux server as guest
 
I asked this question in networking, but it seems more appropriate in this forum.
I have a Linux server with static IP address, and I want to SSH/SMB to it.
In qemu it is easy with "-net user,net=192.168.136.0/24 -redir tcp:22:192.168.136.222:22 -redir tcp:445:192.168.136.222:445"

VirtualBox Host-only adapter also works after setting static IP address to it in the same network. Both SSH and SMB work fine in Windows7 host, but then it may conflict with my network, so I prefer using NAT instead and connect to localhost.

In Windows7 host if I do "VBoxManage.exe modifyvm "my server" --natpf1 "guestssh,tcp,127.0.0.1,2222,192.168.136.222,22", or equivalently use the dialog, then in Cygwin "ssh -v -p 2222 root@127.0.0.1" connects to the port but here is what I get:

Code:

OpenSSH_5.8p1, OpenSSL 0.9.8r 8 Feb 2011
debug1: Connecting to 127.0.0.1 [127.0.0.1] port 2222.
debug1: Connection established.
debug1: identity file /home/ehsan/.ssh/id_rsa type -1
debug1: identity file /home/ehsan/.ssh/id_rsa-cert type -1
debug1: identity file /home/ehsan/.ssh/id_dsa type -1
debug1: identity file /home/ehsan/.ssh/id_dsa-cert type -1
debug1: identity file /home/ehsan/.ssh/id_ecdsa type -1
debug1: identity file /home/ehsan/.ssh/id_ecdsa-cert type -1
ssh_exchange_identification: Connection closed by remote host

Since qemu as well as VirtualBox host-only adapter both work fine, SSH server (and root SSH access) should be working fine.
I tried turning off the firewall/add rules but it has same result.

I appreciate any insight, solution for similar problems, thanks

dashesy 09-19-2011 02:18 PM

I found the solution, here is the documentation.
For the static IP address because my static IP is not the default I had to specify the NAT network, it is not something with a dialog option so the only way would be through this:
Code:

VBoxManage.exe modifyvm "my server" --natnet1 "192.168.136.0/24"
After this addition, similar to qemu NAT works flawlessly

Tinkster 09-25-2011 01:23 PM

Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is being closed because it is a duplicate.

http://www.linuxquestions.org/questi...arding-903403/


All times are GMT -5. The time now is 09:21 PM.