updates the networking doc

This commit is contained in:
waldek 2021-05-05 11:51:43 +02:00
parent e0a4b57d55
commit 6f6dc51335
1 changed files with 64 additions and 3 deletions

View File

@ -29,6 +29,23 @@ If you set both machines with addresses in the same range, you should be able to
Have a go at this until you can make it work. Have a go at this until you can make it work.
Which service do you have to restart of reload to apply your changes? Which service do you have to restart of reload to apply your changes?
Restarting your network interfaces can be done in multiple ways.
The most complete restart of all the interfaces can be done by restarting the `networking.service` run by `systemd`.
```bash
sudo systemctl restart networking.service
```
If this does not bring back your network settings you probably forgot to add the `auto $INTERFACENAME` line in the `/etc/network/interfaces` file.
A less brutal and more advised way of bringing an interface down and up is done with the following commands.
It has the added advantage of giving a verbose output to STDOUT with what is happening which can be very handy for debugging purposes.
```bash
sudo ifdown $INTERFACENAME
sudo ifup $INTERFACENAME
```
## Forwarding traffic ## Forwarding traffic
One of our machines is supposed to be a router and the other a client. One of our machines is supposed to be a router and the other a client.
@ -86,9 +103,53 @@ On Debian this is done with [iptables](https://serverfault.com/questions/532569/
## DHCP ## DHCP
We'll start from scratch again now. It gets real tiring real quick to fix the IP address for every new machine we add to the network.
I would like you to create a new mini network of machines. A solution for this is to install a [DHCP](https://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol) server onto our network.
You can install a few new Debian machines, each with a different `hostname` It can be installed onto any machine or ever a new machine but I advise you to install the DHCP server onto the router.
As with most thing Linux there are multiple servers to choose from.
The two most popular ones are:
* [isc-dhcp-server](https://wiki.debian.org/DHCP_Server)
* [dnsmasq](https://wiki.debian.org/dnsmasq)
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.
A simple declaration is as follows:
```bash
subnet 10.0.1.0 netmask 255.255.255.0 {
range 10.0.1.10 10.0.1.100;
}
```
This suffices to get the server up and running without any errors.
### dnsmasq
![big network](./network_big.png) ![big network](./network_big.png)