SSH to a VirtualBox VM with NAT network settings.

If none of the more specific forums is the right place to ask

SSH to a VirtualBox VM with NAT network settings.

Postby hack3rcon » 2019-01-28 07:22

Hello.
How can I SSH to VM that it's network configuration in NAT? My host is "Debian 8.6 x86_64" and VM is "CentOS 7.6 x86_64". The VM IP address is "10.0.2.15" and I set a secondary IP address to my NIC as below:
Code: Select all
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

auto eth1:0
iface eth1:0 inet static
address 10.0.2.14
netmask 255.255.255.0
broadcast 10.0.2.255

and "ifconfig" show me:
Code: Select all
eth1:0    Link encap:Ethernet  HWaddr 00:11:3b:15:4a:32 
          inet addr:10.0.2.14  Bcast:10.0.2.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

But I can't ping "10.0.2.15". What is my problem?

Thank you.
hack3rcon
 
Posts: 105
Joined: 2015-02-16 09:54

Re: SSH to a VirtualBox VM with NAT network settings.

Postby reinob » 2019-01-28 07:57

hack3rcon wrote:Hello.
How can I SSH to VM that it's network configuration in NAT? My host is "Debian 8.6 x86_64" and VM is "CentOS 7.6 x86_64". The VM IP address is "10.0.2.15" and I set a secondary IP address to my NIC as below:
Code: Select all
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

auto eth1:0
iface eth1:0 inet static
address 10.0.2.14
netmask 255.255.255.0
broadcast 10.0.2.255

and "ifconfig" show me:
Code: Select all
eth1:0    Link encap:Ethernet  HWaddr 00:11:3b:15:4a:32 
          inet addr:10.0.2.14  Bcast:10.0.2.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

But I can't ping "10.0.2.15". What is my problem?

Thank you.


If you're using NAT then you need to configure port forwarding on Virtualbox, i.e. that a given address/port combination at your host should map to address/port combination within VM. This is not a debian problem but a Virtualbox issue.
reinob
 
Posts: 597
Joined: 2014-06-30 11:42

Re: SSH to a VirtualBox VM with NAT network settings.

Postby hack3rcon » 2019-01-28 08:02

reinob wrote:
hack3rcon wrote:Hello.
How can I SSH to VM that it's network configuration in NAT? My host is "Debian 8.6 x86_64" and VM is "CentOS 7.6 x86_64". The VM IP address is "10.0.2.15" and I set a secondary IP address to my NIC as below:
Code: Select all
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

auto eth1:0
iface eth1:0 inet static
address 10.0.2.14
netmask 255.255.255.0
broadcast 10.0.2.255

and "ifconfig" show me:
Code: Select all
eth1:0    Link encap:Ethernet  HWaddr 00:11:3b:15:4a:32 
          inet addr:10.0.2.14  Bcast:10.0.2.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

But I can't ping "10.0.2.15". What is my problem?

Thank you.


If you're using NAT then you need to configure port forwarding on Virtualbox, i.e. that a given address/port combination at your host should map to address/port combination within VM. This is not a debian problem but a Virtualbox issue.

Thanks and according to https://www.simplified.guide/virtualbox/port-forwarding my problem solved.
Need I "eth1:0" ?
hack3rcon
 
Posts: 105
Joined: 2015-02-16 09:54

Re: SSH to a VirtualBox VM with NAT network settings.

Postby reinob » 2019-01-28 08:37

hack3rcon wrote:Thanks and according to https://www.simplified.guide/virtualbox/port-forwarding my problem solved.
Need I "eth1:0" ?


Well, how can we answer that?
In your first post you say you've configured eth1:0 with an IP address. You didn't ask why you did it and we can't possibly know that.

Maybe you one (or a few) steps back and tell us what you're try to achieve?
Otherwise we may end up solving a problem that is only there because you think you need a specific solution to another problem...

(In general, if you need a secondary IP address * for a VM guest * it wouldn't cost you anything to tell VirtualBox that you want TWO ethernet interfaces -- they are virtual and don't cost anything! :) -- instead of assigning multiple addresses to an interface.. but again, first tell us what you want to do and why you (think you) need two IP addresses..)
reinob
 
Posts: 597
Joined: 2014-06-30 11:42

Re: SSH to a VirtualBox VM with NAT network settings.

Postby hack3rcon » 2019-01-28 10:23

reinob wrote:
hack3rcon wrote:Thanks and according to https://www.simplified.guide/virtualbox/port-forwarding my problem solved.
Need I "eth1:0" ?


Well, how can we answer that?
In your first post you say you've configured eth1:0 with an IP address. You didn't ask why you did it and we can't possibly know that.

Maybe you one (or a few) steps back and tell us what you're try to achieve?
Otherwise we may end up solving a problem that is only there because you think you need a specific solution to another problem...

(In general, if you need a secondary IP address * for a VM guest * it wouldn't cost you anything to tell VirtualBox that you want TWO ethernet interfaces -- they are virtual and don't cost anything! :) -- instead of assigning multiple addresses to an interface.. but again, first tell us what you want to do and why you (think you) need two IP addresses..)

My problem Solved. I thought that I should set another IP address to my NIC in VirtualBox VM range.
hack3rcon
 
Posts: 105
Joined: 2015-02-16 09:54


Return to General Questions

Who is online

Users browsing this forum: No registered users and 6 guests

fashionable