Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

SSH to a VirtualBox VM with NAT network settings.

If none of the specific sub-forums seem right for your thread, ask here.
Post Reply
Message
Author
hack3rcon
Posts: 746
Joined: 2015-02-16 09:54
Has thanked: 48 times

SSH to a VirtualBox VM with NAT network settings.

#1 Post by hack3rcon »

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.

reinob
Posts: 1196
Joined: 2014-06-30 11:42
Has thanked: 99 times
Been thanked: 47 times

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

#2 Post by reinob »

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.

hack3rcon
Posts: 746
Joined: 2015-02-16 09:54
Has thanked: 48 times

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

#3 Post by hack3rcon »

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" ?

reinob
Posts: 1196
Joined: 2014-06-30 11:42
Has thanked: 99 times
Been thanked: 47 times

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

#4 Post by reinob »

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..)

hack3rcon
Posts: 746
Joined: 2015-02-16 09:54
Has thanked: 48 times

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

#5 Post by hack3rcon »

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.

Post Reply