How to determine Gateway IP address for NAT Network?

This is for discussing general topics about how to use VirtualBox.
Post Reply
ohaya@yahoo.com
Posts: 34
Joined: 17. Jun 2015, 05:21

How to determine Gateway IP address for NAT Network?

Post by ohaya@yahoo.com »

Hi,

Can someone tell me how to determine the IP address for the gateway for an adapter that is configured for "NAT Network"? I know about Files=>Preferences=>Networks, but in the settings for the NAT Network, there isn't a place to set (or display) the IP address of the gateway for a given NAT Network.

This is for the latest version 4.3.30 (Virtualbox for Windows).

I've seen this older thread:

viewtopic.php?f=1&t=49066

but that seems to be somewhat outdated.

Thanks!

Jim

EDIT: P.S. I actually am also needing to find out how to find the IP for the gateway for an adapter that is configured as a Host-only adapter.
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: How to determine Gateway IP address for NAT Network?

Post by Perryg »

NAT
http://www.virtualbox.org/manual/ch09.html#changenat
NAT networking
http://www.virtualbox.org/manual/ch06.h ... at_service

Host-only does not get a gateway since it is not meant to access the Internet. It is for host to guest communication thus the name "Host-Only"
ohaya@yahoo.com
Posts: 34
Joined: 17. Jun 2015, 05:21

Re: How to determine Gateway IP address for NAT Network?

Post by ohaya@yahoo.com »

Hi,

Re. NAT Networking, where it says:
Here, "natnet1" is the name of the internal network to be used and "192.168.15.0/24" is the network address and mask of the NAT service interface. By default in this static configuration the gateway will be assigned the address 192.168.15.1 (the address following the interface address),
and in particular where it says "following the interface address", when they say "the interface address", do they mean the "192.168.15", so, by "following", they mean to tack on the ".1" to the "192.168.15" to get the 192.168.15.1?

So, for NAT Networking, the Gateway IP is always the ".1" IP address for that subnet?


Re. Host-only network, thanks for the clarification. I didn't realize that when Host-only was selected that was only intended for Host TO Guest communication. I'd always interpreted that it only meant that only the host could communicate with the guest adapter (or, putting it another way, that no other external machine could communicate with the host-only adapter). A kind of fine, but important difference :)...

Thanks again,
Jim
BillG
Volunteer
Posts: 5102
Joined: 19. Sep 2009, 04:44
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows 10,7 and earlier
Location: Sydney, Australia

Re: How to determine Gateway IP address for NAT Network?

Post by BillG »

No, the gateway address does not necessarily have to be .1 . That is a common choice for a lot of DHCP servers, but in fact it can be any number from 1 to 154.

What is important is that the gateway address given to client machines by DHCP is actually the gateway router for the subnet.
Bill
ohaya@yahoo.com
Posts: 34
Joined: 17. Jun 2015, 05:21

Re: How to determine Gateway IP address for NAT Network?

Post by ohaya@yahoo.com »

In our case, we won't be using DHCP but rather static IPs, so in this case, will the gateway IP always be the ".1" IP in the subnet, as I think that web page says?
BillG
Volunteer
Posts: 5102
Joined: 19. Sep 2009, 04:44
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows 10,7 and earlier
Location: Sydney, Australia

Re: How to determine Gateway IP address for NAT Network?

Post by BillG »

Yes, the interface address is the last octet in this case. The first three octets "192.168.x" make up the network address if you use a 24-bit network mask (255.255.255.0) and the last octet is the interface address within the subnet.

If you use an 8-bit mask (255.0.0.0) then only the first octet "10." is the network address and the remaining three octets are the interface address within the subnet.

If you use static addresses make sure that the gateway address you give each client is in fact the default gateway. As the message you quoted says, it will be .1 by default. That means it will be .1 unless you changed it to something else.
Bill
ohaya@yahoo.com
Posts: 34
Joined: 17. Jun 2015, 05:21

Re: How to determine Gateway IP address for NAT Network?

Post by ohaya@yahoo.com »

BillG wrote:Yes, the interface address is the last octet in this case. The first three octets "192.168.x" make up the network address if you use a 24-bit network mask (255.255.255.0) and the last octet is the interface address within the subnet.

If you use an 8-bit mask (255.0.0.0) then only the first octet "10." is the network address and the remaining three octets are the interface address within the subnet.

If you use static addresses make sure that the gateway address you give each client is in fact the default gateway. As the message you quoted says, it will be .1 by default. That means it will be .1 unless you changed it to something else.

Hi Bill,

What you said in your last paragraph is what I'm puzzled about. What I mean is the part about "unless you changed it to something else".

Assuming that we are talking about an adapter that is configured for "NAT Network", *CAN* you change the gateway IP? Isn't the IP of the gateway already determined by VBox's "virtual" NAT Network router (or whatever that is)? Or is there a way that we can configure that virtual router? I couldn't find anywhere in the preferences=>network configuration to set the gateway IP of a NAT Network.

Thanks,
Jim
BillG
Volunteer
Posts: 5102
Joined: 19. Sep 2009, 04:44
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows 10,7 and earlier
Location: Sydney, Australia

Re: How to determine Gateway IP address for NAT Network?

Post by BillG »

See answer in your other thread.
Bill
ohaya@yahoo.com
Posts: 34
Joined: 17. Jun 2015, 05:21

Re: How to determine Gateway IP address for NAT Network?

Post by ohaya@yahoo.com »

BillG wrote:See answer in your other thread.
Hi,

That "other thread" is about Host-only networking. But anyway, what command are you referring to to configure the NAT Network, including the gateway IP address?

Thanks,
Jim
ohaya@yahoo.com
Posts: 34
Joined: 17. Jun 2015, 05:21

Re: How to determine Gateway IP address for NAT Network?

Post by ohaya@yahoo.com »

ohaya@yahoo.com wrote:
BillG wrote:See answer in your other thread.
Hi,

That "other thread" is about Host-only networking. But anyway, what command are you referring to to configure the NAT Network, including the gateway IP address?

Thanks,
Jim

I just tried the vboxmanage command to list natnetworks and got:
e:\Ziptemp>vboxmanage list natnetworks
NetworkName: NatNetwork
IP: 10.0.2.1
Network: 10.0.2.0/24
IPv6 Enabled: No
IPv6 Prefix:
DHCP Enabled: Yes
Enabled: Yes
loopback mappings (ipv4)
127.0.0.1=2
Is the "IP" that is shown the gateway for the NAT Network?

I was also checking the vboxmanage to see if there was a way to SET the gateway IP for when creating a NAT network, but it doesn't seem like there is?
natnetwork add --netname <name>
--network <network>
[--enable|--disable]
[--dhcp on|off]
[--port-forward-4 <rule>]
[--loopback-4 <rule>]
[--ipv6 on|off]
[--port-forward-6 <rule>]
[--loopback-6 <rule>]

natnetwork remove --netname <name>

natnetwork modify --netname <name>
[--network <network>]
[--enable|--disable]
[--dhcp on|off]
[--port-forward-4 <rule>]
[--loopback-4 <rule>]
[--ipv6 on|off]
[--port-forward-6 <rule>]
[--loopback-6 <rule>]

natnetwork start --netname <name>

natnetwork stop --netname <name>
BillG
Volunteer
Posts: 5102
Joined: 19. Sep 2009, 04:44
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows 10,7 and earlier
Location: Sydney, Australia

Re: How to determine Gateway IP address for NAT Network?

Post by BillG »

I really don't know why you are making such heavy weather of this.

What I was referring to was the information you quoted about creating a NAT network.

Here, "natnet1" is the name of the internal network to be used and "192.168.15.0/24" is the network address and mask of the NAT service interface. By default in this static configuration the gateway will be assigned the address 192.168.15.1 (the address following the interface address)

This is the command which creates the virtual network, and the value specified as the default gateway is the address which will be configured as the IP address of the interface on the host which is part of this virtual network. This is the default gateway of the virtual network since it is the only interface in the network which is on the host, and the only interface which can see other networks. It does not exist before you create the NAT network, so it cannot have an IP address other than the one you assign when you create the NAT network. I don't know any way to make it clearer than that.

Are you simply concerned about the working in the statement? By default is a common phrase and means what will happen by default ie unless you override it. So the default gateway created by this command will be x.x.x.1 by default but you can alter it if you like, but you would have to use some other means to do it.

The simplest way to know if the default gateway in in fact .1 would be to set a client machine to use it and see it you can access other networks.
Bill
Martin
Volunteer
Posts: 2560
Joined: 30. May 2007, 18:05
Primary OS: Fedora other
VBox Version: PUEL
Guest OSses: XP, Win7, Win10, Linux, OS/2

Re: How to determine Gateway IP address for NAT Network?

Post by Martin »

I think the main point here is being told "you can set the gateway IP address to something else than .1" but VirtualBox doesn't have a setting or command to do this.
ohaya@yahoo.com
Posts: 34
Joined: 17. Jun 2015, 05:21

Re: How to determine Gateway IP address for NAT Network?

Post by ohaya@yahoo.com »

Martin wrote:I think the main point here is being told "you can set the gateway IP address to something else than .1" but VirtualBox doesn't have a setting or command to do this.

Hi Martin,

Yes, what you said is exactly accurate. That was what I was asking about. I wanted to know (a) was the ".1" IP always the IP of the network gateway and (b) I got the impression from earlier posts above that it was possible to change/set that IP of the gateway, but couldn't find any way, so I was curious what that way was (apparently, there is no way to set that IP address).

Thanks,
Jim
Post Reply