VirtualBox has multiple options when it comes to it's networking settings.
We've already used two different ones, *NAT* and *bridged*, but we'll now try to create our own *internal* network.
For this we'll need a few minimal Debian installations.
I invite you to install at the least two basic installations.
* One will become our router
* The other one our first client
## Static routing
The most basic way of setting your network settings in Debian can be found in the `/etc/network/interfaces` file.
When you open it you'll notice it mentions it sources a folder called `interfaces.d`.
The choice is up to you whether you set your networking settings in this file or create a new file in the folder but I advise you to go for the second way.
Don't just *copy/paste* the code below, check whether the interface names and ranges make sense!
```bash
auto eth0
iface eth0 inet static
address 10.0.0.1
netmask 255.255.255.0
gateway 10.0.0.1
```
![overview](./network_basic.png)
If you set both machines with addresses in the same range, you should be able to ping each other.
Have a go at this until you can make it work.
Which service do you have to restart of reload to apply your changes?
The *easiest* way to achieve routing between your internal network and the outside world is to enable [NAT](https://en.wikipedia.org/wiki/Network_address_translation) on your router.
In order to do this, you need to do 2 things.
First enable the kernel to actually forward packages, secondly `iptables` needs to do masquerading.
You can do both these things with just to simple commands on you router.
From here on out all your clients *should* have internet access but you won't be able to `ping` your clients from outside your network.
Your clients can ping each other and the internet at large but for clients **outside** of their mini network the router will **masquerade** the IP address.
This means that from outside your network, you'll never be able to ping a specific client, just the router itself.
For the kernel option you should have a look at `/etc/sysctl.conf`.
In this file you can enable, disable or set kernel values.
To save `iptables` rules have a look online but [this](http://www.faqs.org/docs/iptables/iptables-save.html) and [this](https://zertrin.org/projects/iptables-persistent/).
We'll start with isc-dhcp-server because it's an industry standard for large scale networks.
The other one, dnsmasq, is lighter and easier to use but consequently it has less features.
It does however has the added benefit of being a [DNS](https://en.wikipedia.org/wiki/Domain_Name_System) server as well!
If you want to use isc-dhcp-server and add a DNS server to your network as well you'll have to install a secondary service.
Large scale networks often combine it with [bind9](https://wiki.debian.org/Bind9) which is a very powerful, but pretty complicated to configure, server.
For our long term purposes dnsmasq is a better option but we'll start with isc-dhcp-server non the less.
### isc-dhcp-server
Installing isc-dhcp-server is pretty straight forward.
An `sudo apt install isc-dhcp-server` should sort you out but you'll get a bunch of errors.
Don't panic, this is pretty normal because we haven't configured the server yet.
A handy new command you'll learn here is `journalctl`.
This is the main interface towards all logging done by all services `systemd` manages.
The `-x` option will 'Augment log lines with explanation texts from the message catalog.' so will be more verbosen and the `-e` will jump to the end of the logs.
```bash
sudo journalctl -xe
```
We need to edit two files to successfully start the DHCP server.
First we need to specify which interface the server should listen on because by default it listens on no interface.
This first file can be found at `/etc/default/isc-dhcp-server`.
Have a read of this configuration file and you'll quickly understand *where* the second file we need to edit is located.
In this second file we need to add a subnet on which the server will distribute IP addresses.
If want to resolve local domain names on our network we need DNS server.
As mentioned above the classic dns counterpart to isc-dhcp-server is bind9.
An easier to setup DNS server is dnsmasq and as an added benefit it does DHCP as well!
We can't run two DHCP servers on the same machine at the same time, because they will both try to bind to the same port, so we have to stop and disable isc-dhcp-server.
We already know how to stop the server with `systemctl` but disabling is new.
What is the difference?
Well, disabling will prevent the server from starting at boot time.
The counterpart to disable is enable.
```bash
sudo systemctl disable isc-dhcp-server
sudo systemctl stop isc-dhcp-server
```
Now we can install dnsmasq with `sudo apt install dnsmasq`.
The configuration is done by creating a new file at `/etc/dnsmasq.d/`.
You're free to name this file however you want and you can also create multiple files to spread out your configuration.
This can be very handy for larger setups.
At the bare minimum, to replace isc-dhcp-server, we need the following:
```bash
dhcp-range=10.0.1.10,10.1.100,24h
```
The same 90 leases will be available for hand out and each lease is valid for 24 hours.
You restart the service in the same way you restart all other services we did up until now; `sudo systemctl restart dnsmasq.service`.