Chapter #25: Static and Dynamic Routing
In this chapter, we cover static and dynamic routing in Linux, guiding you through IP setup, routing tables, NAT, and packet forwarding.

iproute2
and iptables
.As we have anticipated in previous tutorials of this series, in this chapter, we will discuss the routing of IP traffic statically and dynamically with specific applications.
First things first, letβs get some definitions straight:
- Packet: In simple words, a packet is the basic unit that is used to transmit information within a network. Networks that use TCP/IP as a network protocol follow the same rules for transmission of data: the actual information is split into packets that are made of both data and the address where it should be sent.
- Routing: Routing is the process of βguidingβ the data from source to destination inside a network.
- Static Routing: Static routing requires a manually-configured set of rules defined in a routing table. These rules are fixed and are used to define the way a packet must go through as it travels from one machine to another.
- Dynamic Routing: Dynamic routing, or smart routing (if you wish), means that the system can alter automatically, as needed, the route that a packet needs to follow.
However, in the context of the LFCS exam, the term dynamic routing refers to the ability to perform routing βon-the-flyβ with the ip
command.
IP and Network Device Configuration
The iproute2
package provides a set of tools to manage networking and traffic control. We will use it throughout this chapter as it represents the replacement of legacy tools such as ifconfig
and route
.
The central utility in the iproute2
suite is called simply ip
. Its basic syntax is as follows:
ip object command
Where object
can be only one of the following (only the most frequent objects are shown - you can refer to man ip
for a complete list):
link
: network device.addr
: protocol (IP or IPv6) address on a device.route
: routing table entry.rule
: rule in the routing policy database.
Whereas command
represents a specific action that can be performed on object
. You can run the following command to display the complete list of commands that can be applied to a particular object:
ip object help
For example,
ip link help

The above image shows, for example, that you can change the status of a network interface with the following command:
ip link set interface {up | down}
Example 1: Disabling and Enabling a Network Interface
In this example, we will disable and enable eth1
:
ip link show
ip link set eth1 down
ip link set eth1 up
Instead of displaying all the network interfaces, we can specify one of them:
ip link show eth1

Which will return all the information for eth1
.
Example 2: Displaying the Main Routing Table
You can view your current main routing table with either of the following 3 commands: