Cumulus Linux 101
Cumulus Linux 101
Gorilla
Guide to…®
Linux
Networking 101
Open the cover and:
• Discover how Linux continues its march
toward world domination
• Learn basic Linux administration tips
• See how easy it can be to build your entire
network on a Linux foundation
• Find out how Cumulus Linux is your ticket
to networking freedom
David M. Davis
ActualTech Media
www.actualtechmedia.com
The Gorilla Guide To…
Linux Networking 101
Author
David M. Davis, ActualTech Media
Editors
Hilary Kirchner, Dream Write Creative, LLC
Christina Guthrie, Guthrie Writing & Editorial, LLC
Madison Emery, Cumulus Networks
ActualTech Media
Okatie Village Ste 103-157
Bluffton, SC 29909
www.actualtechmedia.com
Entering the Jungle
Introduction: Six Reasons
You Need to Learn Linux ....................................................... 7
1. Linux is the future ........................................................................ 9
2. Linux is on everything .................................................................. 9
3. Linux is adaptable ....................................................................... 10
4. Linux has a strong community and ecosystem ........................... 10
5. Linux is fun!................................................................................ 10
6. Linux is open-source and sometimes free ................................... 10
Chapter 2: Basics of
Linux Administration........................................................... 23
Where Do I Get Linux? ................................................................... 23
How Do I Log In to Linux?............................................................. 24
How Do I Know What Type of Linux I Am Using? ........................ 26
Where Do I Find Things?................................................................ 27
Where Are the Applications, and How Do I Run Them? ............... 31
How Do I Install Applications?....................................................... 33
Linux Processes, Programs, and Services ........................................ 37
Importance of Linux Log Files ....................................................... 39
Users and Superusers ...................................................................... 40
Files and Permissions...................................................................... 42
Summary ........................................................................................ 44
Chapter 3: Basics of
Linux Network Administration .......................................... 45
Understanding Linux Network Interfaces ...................................... 45
MAC Addresses .............................................................................. 48
IP Addressing.................................................................................. 49
DHCP ....................................................................................... 51
DNS .......................................................................................... 53
Network Statistics and Counters .................................................... 55
How to Configure Network Interfaces ........................................... 57
Network Interface Bonding ....................................................... 60
Summary ........................................................................................ 63
Chapter 4: Understanding
Linux Internetworking......................................................... 64
Layer 2 vs. Layer 3 Internetworking ............................................... 66
Layer 2 Internetworking on Linux Systems .................................... 68
Bridging .................................................................................... 68
Spanning Tree ........................................................................... 70
Layer 3 Internetworking View on Linux Systems ........................... 73
Neighbor Table ......................................................................... 73
IP Routing ................................................................................. 74
Virtual LANs (VLANs) ................................................................... 76
Overlay Networks with VXLAN ..................................................... 79
Summary ........................................................................................ 82
Over time, the data center landscape has changed — and for the better,
particularly given that the application landscape has also morphed into
something radically different from what was seen in the past. The
number of business-critical applications is on the rise, and, unlike their
older stay-at-home cousins, modern applications are distributed
between on-premises infrastructure, between partner networks, and
across the public cloud. End user and company data moves around the
globe at light speed, and it’s happening constantly. New applications
are being built today and torn down tomorrow in favor of even newer
applications. Change is happening fast, and the network is adapting to
support these changes.
The key piece of the previous paragraph and the focus of this book is
this: Linux networking is the future for almost every use case. But to
leverage a Linux-based networking solution, you need to understand
Linux, and that’s where this book comes in.
Definitions Abound!
If you don’t know what some of these words mean, don’t worry!
We’ll define them during your Linux 101 journey. By the end of this
book, you’ll be using these phrases in casual conversation!
2. Linux is on everything
Linux runs more than two-thirds of the servers on the Internet, all
Android phones, most consumer network gear, such as NetGear and
Linksys devices, 99% of the top supercomputers in the world, many
Internet of Things (IoT) devices, Tesla cars, and even PlayStation
gaming consoles.
Introduction 9
3. Linux is adaptable
The very reason everything is on Linux is “because it’s such an adaptable
operating system. Thanks to Linux’s modularity and open-source
nature, you can choose the pieces you need for your product or service
and develop any pieces that may not already exist. You can install tiny
versions of Linux for specialized use cases (such as operating water
sprinklers in the gorilla exhibit at the zoo), modify it to work on
appliances that route packets across a large enterprise network, or use it
as your desktop operating system. Your choices are practically endless.
5. Linux is fun!
Linux is a lot of fun because you can do just about anything with it.
Linux is commonly used in Internet of Things (IoT) projects; it runs on
tiny Raspberry Pi computers commonly used by hobbyists, and it even
makes a great operating system on your laptop or desktop computer.
More examples of the many uses of Linux are found throughout the
book.
Introduction 10
Ready to start learning Linux?
Head to the first chapter in this Gorilla Guide and find out the answer
to the burning question: What is Linux?
Introduction 11
Chapter 1
What Is Linux?
As you get started learning about Linux, you’ll likely have many of the
same questions that thousands of other people have had since the
beginning of Linux time. For that reason, we’ll start this chapter by
answering the most common questions about Linux.
What Is Linux? 13
What Is an Operating System?
The short answer is that an operating system, or OS, is software that you
load on your hardware to make it “do things.” Without an operating
system, most hardware is useless. For example, you might have a Dell
computer that runs the Windows 10 operating system from which you
run your applications. You might have an iPhone that runs the iOS
operating system. You may also have an Apple MacBook that runs the
Apple macOS operating system. The operating systems on these
hardware platforms are what enable them to run applications, as shown
in Figure 1-2.
APPLICATIONS
SYSTEM
LIBRARIES SHELLS TOOLS
DAEMONS
OPERATING SYSTEM
KERNEL
HARDWARE
What Is Linux? 14
The Components that Comprise the Linux
Operating System
Linux is an open-source OS that can be installed on a variety of different
types of hardware to allow you to develop software, run applications,
and more. At the heart of Linux is the kernel. Linux was developed in C
and assembly language to run on i386 personal computers, but it has
since been ported to more hardware than just about any other operating
system in history. Today, Linux is the most installed operating system
globally. In fact, the Space X Falcon 9 rocket and the International Space
Station both use Linux!
Linux is typically administered from a command line interface (CLI),
also known as a shell. Besides the kernel, which manages the hardware
and software processes, Linux distributions include a collection of Linux
software, such as device drivers for accessing and controlling hardware,
shared libraries, applications, and system daemons, which run the in
background and respond to network requests. Figure 1-3 shows an
example of what a common Linux distribution might look like.
Numerous programming languages are available for Linux, as well as
more than 70,000 different applications. Applications are installed from
packages, which contain the application itself and metadata about the
application.
Definition: Metadata
Metadata is data about data. In essence, metadata describes the
kind of information that an underlying data set will store. Take, for
instance, a file system on a computer. When you view a directory
listing, you see the file name, file size, create date, last modified date,
and so forth. These are basic examples of metadata associated with
each object in that directory.
What Is Linux? 15
What is a Linux Daemon?
A system daemon in Linux is typically a background
system process that awaits a specific set of
conditions before jumping into action. For
example, your Linux system may have a daemon
called sshd, which stands for Secure Shell daemon.
This system daemon runs in the background and accepts authorized
incoming requests to log into the Linux host. System daemons do not
interact with users and are not typically under the direct control of
users, but rather of the system itself.
What Is a Distribution?
Often called a “distro,” a Linux distribution is the combination of specific
versions of the Linux kernel with other libraries, system daemons,
development tools, applications, packaging, and life-cycle management
tools that are compatible with each other and tested for interoperability.
The most common way that people acquire Linux today is by
downloading one of the many different Linux distributions.
Distributions are available not just for servers, desktop, and laptop
computers, but also for a huge variety of more specialized devices that
run Linux. Examples of Linux distributions are Ubuntu, Debian, Fedora,
openSUSE, and Cumulus Linux.
What Is Linux? 16
APPLICATIONS
DATABASE, WEB SERVER, NETWORK MONITOR, ETC.
LINUX KERNEL
SCHEDULER, DRIVERS, SECURITY, NETWORKING
In short, the separation between user space and kernel space is made to
ensure that Linux is as reliable and secure an operating system as
possible.
What Is Linux? 17
USER APPLICATIONS (DBs, WEB, NET TOOLS, ETC.)
SHARED LIBRARIES
LINUX KERNEL
KERNEL
SPACE
Figure 1-4. User Space and Kernel Space in the Linux kernel
What Is Linux? 18
• Scalability. At this point, you already know that Linux is
eminently scalable and is able to run on everything from
wristwatches to supercomputers to globally distributed
computing clusters. Of course, the benefit of this scalability isn't
just the device mix, but also that its basic functionality —
command line tools, configuration, automation, and code-
compatibility — remains the same no matter where you're
using it.
What Is Linux? 19
• Full function networking. Over the years, Linux has built up
a strong set of networking capabilities, including networking
tools for providing and managing routing, bridging, DNS,
DHCP, network troubleshooting, virtual networking, and
network monitoring.
• Package management. The Linux package management
system allows you to easily install new services and applications
with just a few simple commands.
You will learn more about package management later in this book.
What Is Linux? 20
How Is Linux Used in the Enterprise?
Many modern ideas in data center computing have Linux
underpinnings. Here are just a few examples:
• Big data. More and more companies are having to deal with
exponentially increasing amounts of data in their data center,
and because Linux offers such scalability and performance, it
has become the go-to operating system for crunching big data
via applications like Hadoop. Even Microsoft recently
announced a big data solution based on Linux.
What Is Linux? 21
• Containers. Linux can also be used to run containerized
applications, such as Docker containers, which are being used
more and more by many companies. In fact, Linux is the
foundation of the modern container movement; all container
packaging and orchestration relies on Linux namespace and
isolation mechanisms in order to operate.
Knowledge Check
Answer the following questions to check your knowledge
concerning the basics of Linux:
Summary
In this chapter, you learned what Linux is, where it came from, how it’s
being used, and how powerful it is. With that knowledge, it’s time to get
started using Linux yourself! In the next chapter, you will learn where
to download a Linux distribution, discover the basics of Linux
administration, including how the Linux file system works, how to
manage processes, how to log into Linux, and how to deploy new
packages.
What Is Linux? 22
Chapter 2
Basics of Linux
Administration
Even though this chapter is titled “Basics of Linux Administration,” you
should know that this chapter is meant for anyone getting started with
Linux, whether or not you plan to be a Linux administrator in the
future. You can consider this chapter a “getting started with Linux”
resource.
For example, if you want to start with the Debian distribution, you can
download an ISO-formatted image that you would use to install Debian
Linux from https://www.debian.org/distrib/
While some people will want to run Linux directly on a physical server,
desktop, or laptop, many people start learning Linux for the first time
by running it inside of a virtual machine. With a VM option, you can
run Linux inside your existing Microsoft Windows or Apple macOS
operating system using virtualization tools such as VMware
Workstation or VMware Fusion, both of which both offer a free, limited-
time evaluation license. You can also go with a free product from Oracle
called VirtualBox. Another option is to run Linux as a VM in the public
cloud via a provider such as Amazon Web Services or Microsoft Azure.
In this book, I’ll skip the steps on how to install Linux because you won’t
have to perform the typical installation if you use a live image. Instead,
we will focus on building a skill set on the administrative tasks needed
to understand and navigate Linux.
Most Linux servers are set up to allow users to connect via the network
using the Secure Shell (SSH), an encrypted communications protocol.
As you can see, with SSH, you connect using the command ssh,
followed by the Username, an @ symbol, and then the Hostname or IP
Address of the Linux host to which you are trying to connect. You will
be prompted for your password to log in. In the example above, the
password is required, but is not echoed and therefore not shown.
The uname command shows the basic type of operating system you are
using, like this:
david@debian:~$ uname -a
Linux debian 3.16.0-4-686-pae #1 SMP Debian 3.16.43-2
(2017-04-30) i686 GNU/Linux
And the hostnamectl command shows you the hostname of the Linux
server as well as other system information, like the machine ID,
virtualization hypervisor (if used), operating system, and Linux kernel
version. Here’s an example:
david@debian:~$ hostnamectl
Static hostname: debian
Icon name: computer-vm
As shown above, this host is running Linux. More specifically, the host
is running Debian GNU Linux version 8 (codename jessie) with a Linux
3.16 version kernel on an x86 CPU architecture. Among other things,
you can also see that this Linux installation is running on a virtual
machine with VMware as the hypervisor. Cool, huh?
If you’re new to Linux, you might be wondering how the Linux file
system compares to something familiar like the Microsoft Windows file
system. In Windows, you may be used to drive letters (like the C: drive)
being used as the highest point of a storage volume. Linux represents
the highest level of the volume differently. The Linux file system can
span multiple physical drives, which are all a part of the same tree. The
highest point of the Linux file system is the “/,” or “root,” with all other
directories branching down the tree from there, as shown in Figure 2-1.
Let’s do a quick exercise. First, by using the pwd command, you can see
what directory I’m currently in.
david@debian:~$ pwd
/home/david
Next, to change to the root directory, you can use the cd command.
david@debian:~$ cd /
To get a simple list of files, you can use the ls command. This will
display a very concise list of the files and folders that exist in the current
directory.
But, in most cases, you probably want more information than just a
simple list of files. Linux uses command line flags or switches to extend
what a command can do. For example, to list out all the files and folders
in the current directory, along with full details about each one, you
would type ls -la. This long listing format then shows you each file
and directory, as well as the permissions and access rights for each object
(we’ll cover file permissions later in this chapter), the name of the user
that owns the object (root), the name of the group that owns the object
(again, root), the file size, and the data and time that the object was last
modified. Here’s what this output looks like for the root folder on my
test system:
david@debian:/$ ls -la
total 88
drwxr-xr-x 21 root root 4096 May 15 11:50 .
drwxr-xr-x 21 root root 4096 May 15 11:50 ..
drwxr-xr-x 2 root root 4096 May 15 12:11 bin
drwxr-xr-x 3 root root 4096 May 15 15:53 boot
drwxr-xr-x 18 root root 3200 Jul 14 01:52 dev
drwxr-xr-x 134 root root 12288 Jul 14 01:55 etc
drwxr-xr-x 3 root root 4096 May 15 15:53 home
lrwxrwxrwx 1 root root 33 May 15 11:50 initrd.img -
> /boot/initrd.img-3.16.0-4-686-pae
drwxr-xr-x 19 root root 4096 May 17 00:41 lib
drwx------ 2 root root 16384 May 15 11:49 lost+found
drwxr-xr-x 3 root root 4096 May 15 11:49 media
drwxr-xr-x 2 root root 4096 May 15 11:49 mnt
drwxr-xr-x 2 root root 4096 May 15 11:49 opt
dr-xr-xr-x 150 root root 0 Jul 14 01:52 proc
drwx------ 2 root root 4096 May 16 14:29 root
drwxr-xr-x 23 root root 880 Jul 14 01:57 run
• /home. Where user home directories are stored, one for each
user.
• /var. Where variable-length files, like log files, are stored.
• Of course, not all applications play nice, and not all Linux
administrators are consistent. This is just where stuff is supposed
to go, but things occasionally end up where they don’t belong.
While there may be some differences between Linux
distributions when it comes to where things are located, in
general, the baseline directory structure and usage of it should
be the same because this is defined by the file system Hierarchy
Standard (FHS). For more information on the FHS see:
https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard
The $PATH variable includes all the locations that are searched when
you run a command in the CLI. Because the /bin directories are in your
path, when you execute the name of any of these sample tools, they will
be found. Here’s what your $PATH variable might look like (shown by
using the echo command to show the $PATH variable):
(the “dot slash” refers to the current folder, with the full
command saying “in the current directory, execute ‘my app’”)
david@debian:~$ /opt/app/bin/myapp
Besides the standard types of Linux tools, there are tens of thousands of
applications you can install into Linux in just a few commands. Linux
distributions offer package managers that help you search online package
or application repositories and then download and install just about any
application you might want. Package managers also make it easy to
update your packages to get the latest version. Examples of package
managers are apt, dpkg, rpm, and yum. The package manager that is
available to you will be determined by the Linux distribution that you
have installed. Linux running on Android mobile devices also has its
own package manager (similar to the Apple “App Store”).
On Debian and
Ubuntu systems, you can run
apt list --installed and get a list of the packages that are already
installed, like this:
david@debian:~$ apt list --installed
accountsservice/stable,now 0.6.37-3+b1 i386
[installed,automatic]
acl/stable,now 2.2.52-2 i386 [installed]
acpi/stable,now 1.7-1 i386 [installed]
acpi-support-base/stable,now 0.142-6 all [installed]
(Output truncated)
Any apt list command will result in very long output, so you may
consider piping it to the “less” pager tool, like this:
apt list | less. This will show you the output page by page and
allow you to press the space bar after each page to see the next page.
Important!
For commands requiring elevated privileges, we’ll be
prepending those commands with the sudo command, which will be
discussed later in this book. For now, you just need to understand that
sudo allows you to run the command as an administrator.
In the above example, we used apt install to install the Apache web
server. To verify that a package is installed correctly (and that you
installed what you think you installed), you can use apt show.
Getting help
Linux commands can, at times, be confusing and can
become complex. In Linux, help is always
available!
david@Debian$ man ls
NAME
ls - list directory contents
SYNOPSIS
ls [OPTION]... [FILE]...
DESCRIPTION
List information about the FILEs (the current
directory by default). Sort entries alphabetically if
none of
-cftuvSUX nor --sort is specified.
Mandatory arguments to long options are mandatory
for short options too.
-a, --all
do not ignore entries starting with .
-A, --almost-all
do not list implied . and ..
(output truncated)
But how do you know if it’s still running, and how do you get a list of
every process running on your system? The ps command displays a list
of running processes in Linux. This command is often coupled with the
-ef flag to show every process in the long list format shown below. You’ll
see right at the top that “/sbin/init” is PID (process identifier) #1, and it’s
owned by root (the superuser—more on the root user later in this
chapter).
david@debian:~$ ps -ef
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 01:52 ? 00:00:01 /sbin/init
root 2 0 0 01:52 ? 00:00:00 [kthreadd]
root 3 2 0 01:52 ? 00:00:00 [ksoftirqd/0]
root 5 2 0 01:52 ? 00:00:00 [kworker/0:0H]
(Output truncated)
If you just enter ps by itself, you’ll see only your running processes, like
this:
david@debian:~$ cd /var/log
david@debian:/var/log$ ls -l
total 4924
-rw-r--r-- 1 root root 0 Jul 14 01:57 alternatives.log
-rw-r--r-- 1 root root 40586 May 15 12:12
alternatives.log.1
drwxr-xr-x 2 root root 4096 Jul 14 01:57 apt
-rw-r----- 1 root adm 1471 Jul 14 02:17 auth.log
-rw-r----- 1 root adm 24651 Jul 14 01:55 auth.log.1
-rw-rw---- 1 root utmp 0 Jul 14 01:57 btmp
-rw------- 1 root utmp 768 Jul 14 01:53 btmp.1
drwxr-xr-x 2 root root 4096 Jul 14 01:57 cups
(Output truncated)
The following are the most important system log files:
• tail. View the last lines (tail end) of a text file. A common use
case for tail is to watch the status of a log file in real time with
the “-f” flag like tail -f /var/log/syslog
Even if you ignore the rest of the commands in the previous list, learn
to use grep. I’ll be using it later in this book.
david@debian:/$ id
uid=1000(david) gid=1000(david)
groups=1000(david),24(cdrom),25(floppy),27(sudo),29(audi
o),30(dip),44(video),46(plugdev),108(netdev),110(lpadmin
),113(scanner),117(bluetooth)
david@debian:/$ whoami
david
david@debian:/$ sudo id
uid=0(root) gid=0(root) groups=0(root)
david@debian:/$
david@debian:/$ sudo whoami
root
Notice in the dialog above how the id command was used to see that
we were “uid” (user ID) 1000, and how the whoami command was used
to see that I am a user called “david.” From there, I used the sudo id
command to make sure I was the root user, and the sudo whoami
command verified that I had become root. You’ll note that the id
command proves that I have the uid of 0 (zero).
Here’s a real-world example. Suppose you’d like to view the latest system
logs from the Linux syslog file. Doing so isn’t possible with a regular
user account. To view the syslog file (using the tail command, in this
case), you must use the sudo command:
In the above command sequence, you can see that first there was a
permission denied error when trying to view the syslog file, but when
the sudo command was used (which typically prompts you for the root
password, since no other user was specified), the last 10 lines of the log
file were shown. Many systems prevent you from becoming the root user
with su and instead require you to use the sudo command.
The privileges for who can run what are determined by the /etc/sudoers
file, and that file should be edited using the visudo command to ensure
safe access to a critically important configuration file. For more
information on sudo, just use man sudo to view the manual page.
david@debian:~$ ls -l /var/log/syslog
-rw-r----- 1 root adm 9074 May 15 10:17 /var/log/syslog
d – directory
drwxr-xr-x
r – read
w – write
x - execute
Type User Group Other
In the file permissions graphic (Figure 2-2), a “d” on the left tells you
whether you are looking at a directory (or folder). Then the three sets of
permissions “rwx, r-x, r-x” say whether you can read, write, and execute
(or start the application) at the user level, the group level, and the
“everyone else” level (others). The type indicator shown in Figure 2-2
identifies the selected object as a directory, hence the “d” as the type. The
two most important types of objects in the Linux file system are
directories (“d”) and files (“-”). There are other possible types as well,
but for my purposes here, we’ll stick with directories and files.
Knowledge Check
Answer the following questions to check your knowledge
concerning the basics of Linux:
If you want to learn how to communicate with other hosts and devices
on your local network and around the world, read on!
david@debian:~$ ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue
state UNKNOWN mode DEFAULT group default
link/loopback 00:00:00:00:00:00 brd
00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500
qdisc mq state UP mode DEFAULT group default qlen 1000
link/ether 00:50:56:a3:71:f5 brd ff:ff:ff:ff:ff:ff
If you’re only doing this because you’re comfortable with the old
ways, however, we recommend that you start to phase out your use
of these old commands because there’s no guarantee that they’ll be
around forever, they aren’t kept up to date, and they may not
support all the features of the new commands.
MAC Addresses
A media access control (MAC) address is the unique identifier assigned to
a network interface at layer 2—the Data Link layer—of the OSI Model.
A network interface always has a MAC address—often referred to as the
hardware address—even if it does not have an IP address. MAC addresses
are assigned at the time that a network adapter is manufactured or, if it’s
a virtualized network adapter, the time that the adapter is created and
appears as six groups of two hexadecimal digits each. On the Ethernet
interface, eth0, shown above, the MAC address is also called the link or
ether address. In the ip link output above, you can see that the MAC
address in this case is 00:50:56:a3:71:f5.
IP Addressing
They are unique on the same network, every device has at least one, and
addresses typically fall somewhere between 1.1.1.1 and
255.255.255.255. What are they? IP addresses, of course! For this book,
I’m going to assume that you already know the basics around TCP/IP,
and we’ll focus on how to work with them in Linux. Later in this
chapter, we’ll talk about how to configure IP addresses on your Linux
machine.
david@debian:~$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue
state UNKNOWN group default
link/loopback 00:00:00:00:00:00 brd
00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500
qdisc mq state UP group default qlen 1000
link/ether 00:50:56:a3:71:f5 brd ff:ff:ff:ff:ff:ff
When it comes to Linux networking tools, there is one that just about
everyone has heard of, and that is ping. Ping, which began life as an
acronym but now enjoys its status as a full-fledged word, is the most
basic network test tool around for testing network reachability. It sends
out an Internet Control Message Protocol (ICMP) packet across the
network and notifies you whether there is a response. If a host is up and
able to communicate on the network, an ICMP response will be
returned. If, however, a host is not reachable, you will get a notice that
the host was unreachable or timed out (meaning that the ping test
failed). Here’s an example of a host that is unreachable:
(The “-c5” was used to send just five ping packets; otherwise, ping will
continue forever.)
In these results, five packets were transmitted, and all of them received
no response, so there was 100% packet loss. What that means is that this
host is unreachable, or down.
But why are some of those addresses listed on the left actually names
instead of IP addresses? That’s because domain name system (DNS) is
replacing the IP with a friendly name. You’ll learn about DNS in just a
couple of pages!
DHCP
What if you have dozens, hundreds, or thousands of computers on your
network? It would be incredibly time-consuming to manually assign IP
addresses and to actually track which machines have which IP address.
That’s where the dynamic host configuration protocol (DHCP) comes in.
To learn more about the exact packets that make up the process of
obtaining an IP address, see this diagram:
http://www.smartpctricks.com/wp-content/uploads/2014/04/DHCP-
Packets-Establishment.png.
Note that the prior text said “IP address configuration” and not just “IP
address.” The IP configuration that is returned to a requesting client
contains, at a minimum, the IP address, the IP subnet mask, the IP
default gateway, and DNS server details. Most end user devices are
configured to use DHCP.
The local configuration file for the DHCP client (called dhclient) is at
/etc/dhcp/dhclient.conf. This is a configuration file that dictates to
Linux how it will receive IP configuration information from a DHCP
server. To check the status on the DHCP client, you can cat the syslog
(system log file) and grep for dhcp, like this:
You can find more details on the DHCP client leases in the files
/var/lib/dhcp/*.leases
DNS
Computers that connect to each other using TCP/IP (the most prevalent
form of connection protocol) talk with each other using IP addresses;
however, it would be really painful to have to remember the IP address
of everything you want to connect to. Imagine having to recall the IP
address of Google each time you wanted to search the web. Domain
name system (DNS) is used to map IP addresses to names. Everyone is
familiar with using their web browser, entering a friendly name like
google.com or apple.com, and being taken to the company's website
without ever having to type an IP address. It’s DNS behind the scenes
• A local file called /etc/hosts is used for the first point of lookup
for any host name prior to going out to a DNS server on the
network. If the name is found there, no further searches are
performed. As the superuser, you have the option to edit the
hosts file and configure a static name to IP address mapping.
• The /etc/resolv.conf file shows the local domains to be searched
and what server names to use for DNS resolution.
DNS Resolution
By default, DNS name resolution works as described here, but
is very modular. The hosts portion of /etc/nsswitch.conf can include
directory services like NIS+ or LDAP as well.
david@debian:~$ netstat
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 debian:ssh iMac:52985 ESTABLISHED
tcp 0 0 debian:40980 192.168.1.128:37518 TIME_WAIT
tcp6 1 0 localhost:33904 localhost:ipp CLOSE_WAIT
Active UNIX domain sockets (w/o servers)
Proto RefCnt Flags Type I-Node Path
unix 20 [ ] DGRAM 8963 /run/systemd/journal/dev-log
unix 6 [ ] DGRAM 8972 /run/systemd/journal/socket
unix 2 [ ] DGRAM 15451 /run/user/1000/systemd/notify
(output truncated)
david@debian:~$ netstat -l
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 localhost:mysql *:* LISTEN
tcp 0 0 *:48875 *:* LISTEN
tcp 0 0 *:sunrpc *:* LISTEN
tcp 0 0 *:ssh *:* LISTEN
tcp 0 0 localhost:ipp *:* LISTEN
Active UNIX domain sockets (only servers)
Proto RefCnt Flags Type State I-Node Path
unix 2 [ ACC ] SEQPACKET LISTENING 8197 /run/udev/control
unix 2 [ ACC ] STREAM LISTENING 8200 /run/systemd/journal/stdout
(output truncated)
However, once the Linux machine is restarted, the default IP address will
be back on interface eth0.
To make this IP address change persistent on a Debian or Ubuntu
system, you need to edit the file /etc/network/interfaces and add the
configuration for eth0. To edit this file, use the nano command like this:
nano /etc/network/interfaces. If you are using CentOS or RHEL (Red
Hat Enterprise Linux), the same configuration is found in the
/etc/sysconfig/network-scripts directory.
To make the IP address change take effect, you can either reboot the host
or use the ifdown/ifup commands. At that point, the ip address
command output might look like this:
david@debian:~$ ip address show dev eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc
pfifo_fast state UNKNOWN group default qlen 1000
link/ether 00:0c:29:d0:e8:7e brd ff:ff:ff:ff:ff:ff
inet 192.168.1.72/24 brd 192.168.1.255 scope global
eth0
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fed0:e87e/64 scope link
valid_lft forever preferred_lft forever
You can see that the new IP address has been added, and making the
change this way ensures that it is persistent after the Linux OS restart.
To use network bonding, you need to install the bonding kernel module
via the modprobe command. Modprobe allows you to add additional
capability to the Linux kernel. It works like this:
At this point, you can create a bond using the iproute2 tools, which
allow you to establish the bond as well as set its mode (we’ll cover modes
more in the next chapter). You can get some hints with ip link help
and ip link help bond.
You can put interfaces eth0, eth1, and eth2 into a bond like this (Figure
3-1):
bond0
One of the most common parameters to set when creating a bond is the
“mode,” which is how the bond interacts with the connected network.
Knowledge Check
Answer the following questions to check your knowledge
concerning the basics of Linux networking administration:
Summary
You should now know the basics of Linux network administration. You
just learned about network interfaces, DHCP, DNS, IP address
configuration, interface bonding, and more.
DATA
NETWORK PROCESS
to “talk” to another application on TO APPLICATION
DATA REPRESENTATION
HOST LAYERS
LOGICAL ADDRESSING
and then sends it down the stack to the PATH DETERMINATION
session layer and so forth. This is one of
MEDIA LAYERS
DATA LINK
the reasons that applications don’t need
FRAMES
PHYSICAL ADDRESSING
to develop their own communications (MAC AND LLC)
stacks and can just rely on what is PHYSICAL
provided to them in the operating
BITS
Transparent bridges are layer 2 devices that send all frames received on
one port out the other bridge ports, based on knowledge of the frame’s
destination MAC address. Ethernet switches are multiport network
bridges. Multiport network bridges learn of the MAC addresses in the
network and intelligently forward frames based on the destination
MAC address in the frame.
The problem is that these approaches limit the ability for layer 2
networks alone to operate efficiently beyond relatively small-scale
locations and very simple topologies. Layer 2 networks suffer from two
major limitations. First, they allow for hosts to send traffic to unknown
destinations. This causes broadcasts, which impact every node in the
broadcast domain. Many networks have been taken offline due to
"broadcast storms," or when many hosts are broadcasting at once. In
contrast, layer 3 networks do not allow for unknown communication.
If a layer 3 router does not have a route to the destination IP address, it
will drop the packet instead of broadcasting like layer 2 does.
Second, layer 2 networks have globally unique MAC addresses that are
assigned by the manufacturer. There is no organization to these
addresses across manufacturers. If you have servers with Intel and
Mellanox network cards, the layer 2 MAC addresses will not have any
commonality. Again, when comparing layer 2 MAC addresses to layer
3 IP addresses, companies manually plan IP addressing schemes so that
there is a hierarchy to these IP addresses. An office may have all IP
addresses within it as part of a single IP subnet, like 10.0.0.0, allowing
the company to use a single subnet to represent the entire office. With
layer 2 addressing, there is no ability to summarize or aggregate MAC
addresses; every unique MAC address must be shared with every host in
the layer 2 domain.
When a node sends out an IP packet, it consults its routing and neighbor
(ARP) tables and sends the packet to the device most likely to get that
packet where it needs to go. If the destination is in the same layer 2
Bridging
What do you do when you have two different Ethernet networks that
need connecting? Build a bridge! Bridges have traditionally been
dedicated hardware devices, but you can easily create a bridge in Linux.
For example, when you have a Linux host that has two or more network
interfaces, you can create a bridge to pass traffic between these
interfaces. You can add two interfaces to a Linux bridge with ip link
set and ip link add using:
Once a bridge is created, you can view the MAC address table, which
shows which ports can reach a specific MAC address, with the bridge
command. The command shown in the example below uses fdb show
as its parameter. In this command, fdb stands for forwarding database
management, and show is a way for you to see the current contents of
this database:
Once the bridge has “bridged,” the different Ethernet networks, all the
devices on these networks can communicate, at least at layer 2 (see
Figure 4-2).
Spanning Tree
The downside to big networks is that you can accidentally create loops
that feed upon themselves and that can ultimately bring the network
down. For example, if you accidentally plug one switch port directly
into another port on the same switch, you may have created a loop. You
can mitigate these loops through the use of spanning trees. It’s also
important to note that layer 3 has a TTL (time to live) field that reduces
the impact of loops — packets eventually die and are dropped — while
layer 2 does not have a TTL and will loop a frame forever.
The Spanning Tree Protocol (STP) does not add a TTL field to the frame,
but it will prevent layer 2 loops from forming, preventing the broadcast
storm described earlier. Bridges that speak STP will exchange
information about the network using Bridge Protocol Data Units
(BPDUs). Through this BPDU exchange, the bridges will build a loop-
free "tree" of the network. In our two-switch example, STP would
disable one of the two links and never send traffic over it, until the active
link failed.
How, exactly, does your networking stack know that 192.168.10.2 is not
in the same network as 192.168.192.168 when using a 255.255.255.0
subnet mask? If you’ve ever wondered how the math works, the magic
lies in the use of the bitwise AND operator. In the figure below, you
can see that performing a bitwise AND operation between the
origination address and the local network’s subnet mask results in a
calculation that shows that the local network is 192.168.192.0. When a
node in this network wants to communicate with the IP address
192.168.10.2, a similar operation is performed on this destination
address with the result indicating that the destination address is
192.168.10.0. Because the destination address has been determined to
be non-local, this traffic is sent to the local layer 3 device, typically a
router, which then forwards the packet to the correct destination
network.
Neighbor Table
When an IP node wants to communicate with a system in the same layer
2 domain, it looks in its neighbor table, or ARP table, to determine how
to construct the Ethernet frame. If the desired destination IP address is
not in the neighbor table, the node issues an ARP request, which is
broadcast to everyone in the layer 2 domain, that asks, “Please tell me
the MAC address for the node with IP address X.X.X.X.” Assuming the
target device is available, the node with that IP address will respond. In
Linux, you view (and manipulate) the Neighbor table using the ip
neighbor show command (also known as ip neighbor show, ip
neigh show, or even just ip n s):
IP Routing
The routing table has knowledge of specific networks, or summaries of
networks, that a node can reach. Minimally, each routing table will have
a “default route” where the node can send any IP packet that is not in an
attached layer 2 network. You can view the routing table with the ip
route show command, like this:
Here you can see that the routing table knows that the 172.20.10.0/28
network is a locally attached layer 2 network. The routing table also
includes a route to the default gateway (172.20.10.1), which Linux calls
“default,” that will be used to reach any node that isn’t on the local
network. If you’re used to networking on non-Linux systems, you may
have seen a default route expressed as something like 0.0.0.0/0.
Routes can be added or deleted from the routing table in a few different
ways:
However, once the host is restarted, this route disappears because it’s not
persistent. To make this route persistent, you would edit the
/etc/network/interfaces file and, after the network device configuration,
add a post-up command with the same ip route command so that
this static route is added every time the Linux host is restarted or the
network interface is brought up. Here’s an example of what it might
look like in the /etc/network/interfaces file:
Suppose you want a Linux system to have eth1 in one bridge (VLAN11),
eth3 in a second bridge (VLAN12), and eth2 in both (i.e. a tagged
trunk). First, we make sure the 802.1Q trunking driver is installed. Then
we create a bridge, add the ports to the bridge, and make sure the ports
are part of the desired set of VLANs. Notice that both eth1 and eth3
used untagged VLANs. However, per the bridge’s configuration, traffic
from those ports will be placed onto their configured VLANs, which are
VLAN 11 and VLAN 12 in this case. Untagged traffic from the trunk
port will be placed into the native VLAN, which is VLAN 1 by default.
If you look at the Ethernet frames, you can’t tell that the interfaces are
part of a VLAN; however, eth2 is a member of both VLANs, and all
frames carry the 802.1Q VLAN tag (shown in Figure 4-3).
To help you better understand the configuration above, there are a few
things that you should know:
What is encapsulation?
Encapsulation is when one piece of data or packet on a
network is wrapped up in another type of data or
network packet. For example, a text file could be
encapsulated in an archive file. In networking,
encapsulation is used as a means to move traffic that might otherwise not
be able to traverse the communications mechanism. For example, you
may encapsulate an IP packet encapsulated in an Ethernet frame to move
traffic between local hosts, but encapsulation can even happen between
the same two protocols. IP could be encapsulated with IP. A common
modern-day example of encapsulation is the iSCSI storage protocol. In
an iSCSI system, iSCSI commands and a storage payload are
encapsulated inside a TCP packet, which is encapsulated inside an IP
packet, which is, in turn, encapsulated inside an Ethernet packet. This
multi-level encapsulation process enables what would have been local
SCSI storage commands to transparently traverse an Ethernet-based
TCP/IP network.
If you have two Linux systems and you want to bridge them with
VXLAN, you would install a bridge on both systems, add a local IP
address to that bridge, and add a VTEP to that bridge pointing the VTEP
to the other Linux host (shown in Figure 4-4).
BRIDGE BRIDGE
VLAN 10 VLAN 10
eth1 eth1
Linux System 1
sudo ip link add br0 type bridge vlan_filtering 1
sudo ip link add vlan10 type vlan id 10 link bridge
protocol none
sudo ip addr add 10.0.0.1/24 dev vlan10
sudo ip link add vtep10 type vxlan id 1010 local
10.1.0.1 remote 10.3.0.1 learning
sudo ip link set eth1 master br0
sudo bridge vlan add dev eth1 vid 10 pvid untagged
Linux System 2
sudo ip link add br0 type bridge vlan_filtering 1
sudo ip link add vlan10 type vlan id 10 link bridge
protocol none
sudo ip addr add 10.0.0.2/24 dev vlan10
sudo ip link add vtep10 type vxlan id 1010 local
10.3.0.1 remote 10.1.0.1 learning
sudo ip link set eth1 master br0
sudo bridge vlan add dev eth1 vid 10 pvid untagged
Now these two systems both exist on the 10.0.0.x/24 layer 2 network (via
the VXLAN overlay) even though they are connected by a layer 3 IP
fabric. It’s also worth noting that the hosts are completely isolated from
Knowledge Check
Answer the following questions to check your knowledge
concerning Linux internetworking:
Summary
You should now have a good understanding of the basics of Linux
internetworking. In this chapter, you learned about layer 2 versus layer
3 networking, bridging, routing, traffic filtering, and VXLAN. I hope
that you have enjoyed the chapter!
Hardware acceleration
While Linux networking can work on just about any
hardware, Cumulus Linux is best run on
commodity bare-metal switches that are hardware
accelerated. The “hardware acceleration” portion of
that means that the switches contain hardware called ASICs, specially
designed to switch frames and route packets, similar to how a graphics
card is specially designed for graphics. These ASICs are what make
routers and switches different from regular servers and allow them to
process hundreds of gigabits or even terabits of network traffic per
second.
Cumulus Linux 84
and manually manage what could be thousands of static routing rules,
you need to run a routing protocol, such as BGP, on the Linux system
so that you can automatically share IP routes with the rest of the
network. Cumulus Linux uses the following:
Cumulus Linux 85
As we explore internetworking use cases throughout this chapter, I will
lean on net and show you how to leverage it while using Cumulus
Linux. One of the most useful facilities in NCLU is the built-in help
and examples (as shown below); I’ll point this out throughout the
chapter.
$ net help
Usage:
# net <COMMAND> [<ARGS>] [help]
#
# net is a command line utility for networking on
Cumulus Linux switches.
#
# COMMANDS are listed below and have context
specific arguments which can
# be explored by typing "<TAB>" or "help" anytime
while using net.
#
# Use 'man net' for a more comprehensive overview.
net abort
net commit [verbose] [confirm] [description
<wildcard>]
net commit delete (<number>|<number-range>)
net commit permanent <wildcard>
net del all
net help [verbose]
net pending [json]
net rollback (<number>|last)
net rollback description <wildcard-snapshot>
net show commit (history|<number>|<number-
range>|last)
net show rollback (<number>|last)
net show rollback description <wildcard-snapshot>
net show configuration
Cumulus Linux 86
[commands|files|acl|bgp|multicast|ospf|ospf6|interface
<interface>]
Options:
# Help commands
help : context sensitive information; see
section below
example : detailed examples of common workflows
# Configuration commands
add : add/modify configuration
del : remove configuration
# Commit buffer commands
abort : abandon changes in the commit buffer
commit : apply the commit buffer to the system
pending : show changes staged in the commit buffer
rollback : revert to a previous configuration state
# Status commands
show : show command output
clear : clear counters, BGP neighbors, etc
Cumulus Linux 87
eth3
BRIDGE
eth1 eth2
SERVER SERVER
1 2
This simple example has a few noteworthy things going on. The first is
that we don’t need to use the sudo command for privileged access.
NCLU makes sure that the user has permission to invoke privileged
commands (or belongs to a group that has permission). The second is
that net puts commands into a “commit buffer” so that you can issue a
bunch of commands, review them in a pending state (with net
pending), correct them as needed, and then “commit” them to the
system with net commit.
Figure 5-3 shows such a deployment with swp1 and swp2 connected to
servers (each is part of an 802.1ad bond on the server side), swp3 and
swp4 connected back to the network core, and swp5 and swp6 acting as
“peer links” between the two switches that form the redundant pair. In
the example, 100 VLANs are trunked to each of the servers. Try net
example clag for a few MLAG use cases and net example clag
Cumulus Linux 88
l2-with-server-vlan-trunks for something close to what is
described here:
swp3
swp3
swp4
swp4
swp5 swp5
swp2
SERVER
SERVER
Figure 5-3. Two switches connected with MLAG
Cumulus Linux 89
IP Fabrics Are Easy
A recent trend in modern network architecture (especially in data
centers) is to reduce the size of the broadcast domains and use layer 3
(IP routed) internetworking to create fabrics. A fabric is a simple, high-
speed, layer 3 network. The motivation behind this trend is that IP
networks scale better than layer 2 networks and behave better in the
face of unfortunate misconfigurations and failures.
Traditionally, layer 3 fabrics have been complex to configure because
every interface on a switch/router needs to exist on an IP subnet with its
link peer — a painstaking undertaking. Recent implementations of
BGP and OSPF, such as FRRouting in Cumulus Linux, include the
ability to connect routers via point-to-point links using “unnumbered”
interfaces.
Cumulus Linux 90
Figure 5-4 shows the configuration of a leaf switch in a layer 3 leaf-spine
network built using BGP unnumbered. The leaf switch has a bridge
with swp1-4 that has the 10.0.0.0/24 IPv4 subnets. Swp5 through swp8
are connected to spines using BGP unnumbered, advertising
reachability of the bridge subnets to the rest of the network.
LEAF 1 ROUTING
LEAF 2
lo
10.0.0.0/24
10.1.0.1/24
VLAN 1
Cumulus Linux 91
BGP EVPN—L3 Network Virtualization for
Network Engineers
Many networks have the scale that requires layer 3 internetworking;
however, some applications still require layer 2 peering over the layer 3
fabric. One example of where this can be extremely useful is VMware’s
vMotion. The Ethernet Virtual Private Networks facilities built into
FRRouting’s BGP daemon allows us to use BGP to build both the IP
fabric as well as any distributed layer 2 overlays that are needed to
support your applications. BGP EVPN will take any MAC address
learned and advertise it to the remote EVPN peers. This allows each leaf
in the network to know where to send the Layer 2 VxLAN traffic
without flooding or the need for spanning tree.
Cumulus Linux 92
$ net add vxlan vtep100 vxlan id 100
$ net add vxlan vtep100 vxlan local-tunnelip 10.1.0.1
$ net add vxlan vtep100 bridge access 100
$ net add vxlan vtep100 bridge learning off
$ net add vxlan vtep100 mtu 9216
$ net add bgp neighbor swp5-8 interface remote-as
external
$ net add interface swp5-8 mtu 9216
$ net add bgp neighbor swp5-8 interface remote-as
external
$ net add bgp ipv4 unicast neighbor swp5-8 activate
$ net add bgp evpn neighbor swp5-8 activate
$ net add bgp evpn advertise-all-vni
$ net commit
LEAF 1 ROUTING
LEAF 2
lo
10.0.0.0/24
10.1.0.1/24
VTEP
swp2
Cumulus Linux 93
Note: The VXLAN header used to build the layer 2 network in EVPN
makes Ethernet frames larger than the default of 1518, so you need to
include the maximum transmission unit (MTU). In this case, set it to 9216
(large enough to support “jumbo” frames) so that you don’t have to
worry about it ever again.
These use cases are just four examples of how Linux networking can be
easy, efficient, and powerful. If you'd like to try out more use cases and
commands, we recommend downloading Cumulus VX, a free
prototyping environment where you can test out your new Linux
networking skills.
Knowledge Check
Answer the following questions to check your knowledge
concerning Linux internetworking:
Cumulus Linux 94
Next Steps
Your Cumulus
Linux Action Plan
In this book, you’ve learned the basics of Linux — from how to log in
to advanced Linux network configuration. With your newfound Linux
awareness, what’s your next step?
Tons of excellent resources are available in the Linux community,
including blogs, documentation, and videos. As a part of that
community, Cumulus Networks offers a plethora of learning resources
as well. Here’s your action plan for taking the next step with Cumulus
Linux:
Step 1: Gain Access to Cumulus Linux. You can do so in two different
ways:
Here you’ll find case studies, videos, validated designs, and white papers
that will show how Cumulus Linux is being used in real data centers
around the world.