Docsity

Configuring Linux as a Router: Enabling IP Forwarding and Connecting Networks, Study notes of Computed Tomography

Partial preview of the text

Download Configuring Linux as a Router: Enabling IP Forwarding and Connecting Networks and more Study notes Computed Tomography in PDF only on Docsity!

Configure Linux as a Router

Upon completion of this topic students will

able to:

o Configure and use Linux as a Router

o Explains how to enable IP forwarding in

Linux.

Introduction

o

Each computer, in the LAN network, uses a unique

software address that is known as the IP address.

o

For easier management and several technical

reasons, IP addresses are grouped into the IP

networks and the IP networks are further

categorized into the five IP classes.

o

By default, an IP address of an IP network can't

communicate with the IP address of another IP

network.

Why router?

o Router is a special device that not only provides the

IP forwarding as the main function but also supports

several other IP based features such as; packet

filtering, voice over IP, IP firewall, etc.

o Router is an expensive device.

o Configuring it is also a complex task.

o Not every network, especially the small and home

office network, can afford it.

Why configure Linux as router?

o Linux provides a zero-cost solution for the IP

forwarding.

o If you have a Linux system in your network, you can

use it for the IP forwarding.

The following image shows the IP configuration of

the PC-A (Windows 7).

The following image shows the IP configuration of

the PC-B (Ubuntu 18.04).

The following image shows my LAB with IP

configuration.

o Make a list of all gateway IPs which you assigned in your

network.

o For example, in my LAB I have two networks and the

default gateway IPs of both are; 192.168.1.1 and

o Now, configure all these gateway IP addresses in the

Linux system.

o You can use an individual network interface (LAN) for

each gateway IP or can use a single network interface for

all gateway IPs.

o Login from the root account and run the nmtui command.

o Select "Edit a connection" option and press

the Enter key.

o

Select available Ethernet (network interface)

from the left pane and the Edit option from the

right pane and hit the Enter key.

o

Select the Quit option and press Enter key.

o

Restart the network service.

o Confirm the IP configuration. To print the IP configuration of

all network interfaces, use the "ip addr" command.

o At this point, systems from different networks can access the

default gateway, but they can't access the system of another

network.

o To verify connectivity between systems and gateway, you can

use the ping command.

o

The following image shows connectivity

between PC-B and the default gateway.

o Enabling IP forwarding on Linux

o Run the following command to enable the IP forwarding.

o #echo "1" > /proc/sys/net/ip4/ip_forward

o This command enables IP forwarding in the current

session. It does not make a change in that configuration

file which Linux reads at the startup. By default, the state

of IP forwarding is disabled in the configuration file. It

means Linux will automatically disable the IP

forwarding again when you will restart the system.