9 Advanced topics anywhere, provided the user running VirtualBox has the permission to create a new file in the directory. The final command above defines that VirtualBox acts as a server, i.e. it creates the named pipe itself instead of connecting to an already existing one. 9.10 Fine-tuning the VirtualBox NAT engine 9.10.1 Configuring the address of a NAT network interface In NAT mode, the guest network interface is assigned to the IPv4 range 10.0.x.0/24 by default where x corresponds to the instance of the NAT interface +2. So x is 2 when there is only one NAT instance active. In that case the guest is assigned to the address 10.0.2.15, the gateway is set to 10.0.2.2 and the name server can be found at 10.0.2.3. If, for any reason, the NAT network needs to be changed, this can be achieved with the follow- ing command: VBoxManage modifyvm "VM name" --natnet1 "192.168/16" This command would reserve the network addresses from 192.168.0.0 to 192.168.254.254 for the first NAT network instance of “VM name”. The guest IP would be assigned to 192.168.0.15 and the default gateway could be found at 192.168.0.2. 9.10.2 Configuring the boot server (next server) of a NAT network interface For network booting in NAT mode, by default VirtualBox uses a built-in TFTP server at the IP address 10.0.2.3. This default behavior should work fine for typical remote-booting scenarios. However, it is possible to change the boot server IP and the location of the boot image with the following commands: VBoxManage modifyvm "VM name" --nattftpserver1 10.0.2.2 VBoxManage modifyvm "VM name" --nattftpfile1 /srv/tftp/boot/MyPXEBoot.pxe 9.10.3 Tuning TCP/IP buffers for NAT The VirtualBox NAT stack performance is often determined by its interaction with the host’s TCP/IP stack and the size of several buffers (SO_RCVBUF and SO_SNDBUF). For certain setups users might want to adjust the buffer size for a better performance. This can by achieved using the following commands (values are in kilobytes and can range from 8 to 1024): VBoxManage modifyvm "VM name" --natsettings1 16000,128,128,0,0 This example illustrates tuning the NAT settings. The first parameter is the MTU, then the size of the socket’s send buffer and the size of the socket’s receive buffer, the initial size of the TCP send window, and lastly the initial size of the TCP receive window. Note that specifying zero means fallback to the default value. Each of these buffers has a default size of 64KB and default MTU is 1500. 9.10.4 Binding NAT sockets to a specific interface By default, VirtualBox’s NAT engine will route TCP/IP packets through the default interface assigned by the host’s TCP/IP stack. (The technical reason for this is that the NAT engine uses sockets for communication.) If, for some reason, you want to change this behavior, you can tell the NAT engine to bind to a particular IP address instead. Use the following command: VBoxManage modifyvm "VM name" --natbindip1 "10.45.0.2" After this, all outgoing traffic will be sent through the interface with the IP address 10.45.0.2. Please make sure that this interface is up and running prior to this assignment. 146
Previous Page Next Page