Building an Ubuntu Router Part 1 - Network Interfaces

Introduction

In this guide a router will be built, with some additional functions, that perhaps a router does not offer, as the design develops, it will change because of the services that are added to it.

What is needed:

  • A machine running Ubuntu: This guide will use Ubuntu Server 18.04.1
  • At least two network interfaces: One for the LAN and the other for the WAN.

Configuring the Interfaces

With the ip link command, you can see the available interfaces, you will get something that looks like this:

1
2
3
4
5
6
7
8
~$ ip link

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
link/ether 08:00:27:ee:d8:f9 brd ff:ff:ff:ff:ff:ff
3: enp0s8: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/ether 08:00:27:12:2f:66 brd ff:ff:ff:ff:ff:ff

The interface enp0s3 will be connected directly to the modem and will have an ip through dhcp, enp0s8 should also have an ip but this must be static in order to correctly configure DHCP server later.

It is important to backup the files to be edited.

1
2
sudo cp /etc/netplan/50-cloud-init.yaml{,.bak}
sudo nano /etc/netplan/50-cloud-init.yaml

We will assign the static ip 128.0.0.1 to the interfaceenp0s8.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
version: 2
ethernets:
enp0s3:
dhcp4: yes
enp0s8:
dhcp4: no
dhcp6: no
addresses: [128.0.0.1/27]
gateway4: 10.55.15.58
nameservers:
addresses: [1.1.1.1, 1.0.0.1]

address: Is the static ip of the server.

gateway: Is the ip address of theenp0s3 interface, that has an internet connection.

nameservers: Dns server.

For the new configuration to take effect you can reboot or just restart the networking service with:

1
sudo netplan apply

And with ifconfig you can see the changes:

Check the interface

© 2020 Juvenal Yescas All Rights Reserved.
Theme by hiero