8.36. VBoxManage natnetwork

Oracle VM VirtualBox

8.36. VBoxManage natnetwork

NAT networks use the Network Address Translation (NAT) service - which works in a similar way to a home router. It groups systems using it into a network and prevents outside systems from directly accessing those inside, while letting systems inside communicate with each other and outside systems using TCP and UDP over IPv4 and IPv6.

A NAT service is attached to an internal network. Virtual machines to make use of one should be attached to it. The name of an internal network is chosen when the NAT service is created, and the internal network will be created if it does not already exist. An example command to create a NAT network:

VBoxManage natnetwork add --netname natnet1 --network "192.168.15.0/24" --enable

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 after the interface address), though this is subject to change.

To add a DHCP server to the NAT network after creation:

VBoxManage natnetwork modify --netname natnet1 --dhcp on

Below are the subcommands for VBoxManage natnetwork

VBoxManage 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>]
    

VBoxManage natnetwork add Creates a new internal network interface, and adds a NAT network service. This command is a prerequisite for enabling attachment of VMs to the NAT network. Parameters:

--netname <name>

Where <name> is the name of the new internal network interface on the host OS.

--network <network>

Where <network> specifies the static(default)/DHCP network address and mask of the NAT service interface.

--enable|--disable

Enables/disables the NAT network service.

--dhcp on|off

Enables/disables DHCP server specified by --netname; its use also indicates that it is a DHCP server.

--port-forward-4 <rule>

Enables IPv4 port forwarding, rule specified by <rule>.

--loopback-4 <rule>

Enables IPv4 loopback interface, rule specified by <rule>.

--ipv6 on|off

Enables/disables IPv6 (default is IPv4, disables gives IPv4).

--port-forward-6 <rule>

Enables IPv6 port forwarding, rule specified by <rule>.

--loopback-6 <rule>

Enables IPv6 loopback interface, rule specified by <rule>.

VBoxManage natnetwork remove --netname <name> 

VBoxManage natnetwork remove Removes a NAT network service, parameters:

--netname <name>

Where <name> specifies an existing NAT network service. Does not remove any DHCP server enabled on the network.

VBoxManage 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>]
    

VBoxManage natnetwork modify Modifies an existing NAT network service, parameters:

--netname <name>

Where <name> specifies an existing NAT network service.

--network <network>

Where <network> specifies the new static(default)/DHCP network address and mask of the NAT service interface.

--enable|--disable

Enables/disables the NAT network service.

--dhcp on|off

Enables (and if absent, adds)/disables (if any) DHCP server.

--port-forward-4 <rule>

Enables IPv4 port forwarding, rule specified by <rule>.

--loopback-4 <rule>

Enables IPv4 loopback interface, rule specified by <rule>.

--ipv6 on|off

Enables/disables IPv6 (default is IPv4, disables gives IPv4).

--port-forward-6 <rule>

Enables IPv6 port forwarding, rule specified by <rule>.

--loopback-6 <rule>

Enables IPv6 loopback interface, rule specified by <rule>.

VBoxManage natnetwork start --netname <name>
    

VBoxManage natnetwork start Starts specified NAT network service and any associated DHCP server, parameters:

--netname <name>

Where <name> specifies an existing NAT network service.

VBoxManage natnetwork stop --netname <name>
    

VBoxManage natnetwork stop Stops specified NAT network service and any DHCP server, parameters:

--netname <name>

Where <name> specifies an existing NAT network service.

VBoxManage natnetwork list [<pattern>] 

VBoxManage natnetwork list Lists all NAT network services with optional filtering, parameters:

[<pattern>]

Where <pattern> is optional filtering pattern.