0% found this document useful (0 votes)
20 views9 pages

Network Routing and IP Forwarding Guide

The document outlines the configuration of a network with three hosts (H1, H2, H3) and two subnets (LAN1 and LAN2) using IP forwarding for communication. It details the setup of network interfaces, routing tables, and the process of enabling IP forwarding on hosts, particularly on H2 which acts as a router. Additionally, it provides commands for adding routing rules and making configurations permanent for effective packet forwarding between hosts across different subnets.

Translated by

ScribdTranslations
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views9 pages

Network Routing and IP Forwarding Guide

The document outlines the configuration of a network with three hosts (H1, H2, H3) and two subnets (LAN1 and LAN2) using IP forwarding for communication. It details the setup of network interfaces, routing tables, and the process of enabling IP forwarding on hosts, particularly on H2 which acts as a router. Additionally, it provides commands for adding routing rules and making configurations permanent for effective packet forwarding between hosts across different subnets.

Translated by

ScribdTranslations
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Routing

Consider the following network, let's have the nodes communicate with each other:

Host Network Interface Card LAN Subnet Mask


H1 eth0=[Link]
LAN1=[Link]
eth0=[Link]
H2 [Link]
eth1=[Link]
LAN2=[Link]
H3 eth0=[Link]
Using a bridge configuration, we could easily connect all the nodes, but not
We would receive the requested configuration in the schema. From the study of the two sisters>
it can be seen from the schema (LAN1eLAN2) that:

LAN (CIDR) Host-Min Host-Max


LAN1=[Link]/24 [Link] [Link]
LAN2=[Link]/24 [Link] [Link]
Each node of a network (H1, H2, or H3) can communicate at Level-2 only with the nodes belonging to
at the same time: (e.g. H1 with H2, and H2 with H3). For every other node, it is necessary to resort to
Routing of packets at the IP level.
So, given the following scheme, where the areas covered by the two LANs are graphically visible, at
Level-2 is possible:
§ Connect H1 with H2
§ Connecting H2 with H3
§ It is not possible to connect H1 and H3

1
Routing
In order to enable communication between two or more sisters, some hosts are identified that play the role of
router, which forward packets from one network to another. The forwarding of packets is
determined based on the destination IP address (Layer-3 of the TCP/IP stack)
The host that acts as a router when it receives a packet with a destination IP address
instead of discarding it (an action performed by a common host), it forwards it to another router
according to the predetermined rules of Roung.

In the event that the recipient of the package is not part of the host's network, the latter
will forward the package to a predetermined router identified by the term digateway.
The main problems to be solved within network configurations that include multiple
for example that in the previous scheme are:
§ Each router must know how to reach every network, both those it is connected to
directly or those that are indirectly connected (for example, in the previous scheme
the communication between H1 and H3).

§ Each host must know which router (gateway) of its own subnet it should send packets to.
based on the designation.

Course Note:
For the purposes of the course, the configuration (status) of the hosts and gateways must include:
§ The definition of Roungsu tables you hosts
§ The IP forwarding enablement on the hosts identifies as gateway

IP Forwarding
IP Forwarding, or IP routing, is the process that allows a network device, such as a router, to
accept incoming IP packets and forward them to the correct destination based on the information
contained in the package headers.
It is possible to check the status of IP Forwarding on a host using the command:
§ If the parameter is 0 (default value), IP Forwarding is disabled.
$ sysctl net.ipv4.ip_forward
[Link] forward = 0
To temporarily enable the IP Forwarding feature, execute the command:
$ sysctl -w net.ipv4.ip_forward=1
net.ipv4.ip_forward = 1
To enable IP Forwarding permanently on a host, within the file
/etc/[Link] modifies the ipc module ipv4.ip_forward setting it to 1:
§ At the end, the Network Manager is restarted to make the changes effective.
$ nano /etc/[Link]

net.ipv4.ip_forward=1

$ service networking restartRestart the network services
Or:
$ sysctl -p /etc/[Link]← Read and Apply the changes in the specified file

2
Routing
UnaTabella di Rou ngè una stru ura da> u>lizzata da router, gateway e computer per
determine the most suitable route for forwarding packets in a network.
This contains information about network routes, including the destination IP address, the subnet
destination, the IP address of the gateway (the 'next hop') and the network interface to be used for
send the packages to that destination.
When a packet arrives at a device, the routing table is consulted to decide
where to send the package later. If the final destination of the package is within the
On the same network as the device, the packet is sent directly to the destination host. If the
If the final destination is on another network, the packet is sent to the appropriate gateway to be
forwarded to the destination network.

Routing Table Consultation


In Linux systems, the routing table can be queried and modified using the commands:
$ route→ if you are not root/sbin/route
Or:
$ ip route show
The command route option allows you to view the IP address of the hosts/network at
instead of translating them into the domain name. This option makes the output faster and easier to read.
$ route -n
Kernel IP routing table
Destination Gateway Subnet mask Flags Iface
[Link]* [Link] U eth1
[Link]* 255.255.255.192U eth0
[Link] [Link] [Link] UGH eth1
[Link] 155.185.54.1900.[Link] UG eth0

§ Target destination
§ Selected Destination
Corresponding IP route:
$ ip route show
default via [Link] dev eth1 proto static metric 1024
[Link]/24 dev eth0 proto kernel scope link src [Link]
[Link]/26 deveth1 proto kernel scope link src [Link]
[Link] via [Link] dev eth0 proto static metric 1024

The destination target can be a subnet or a host; moreover, it is possible to set a
Default gateway for all destinations that do not meet any of the destinations
present in the Roung Table.
§ The destinations in the table are defined by NetID + Subnet Mask, and not just by 'Destination'.

3
Routing
Add Routing Rules
The routing rules, stored in the routing table, determine how the data packets...
they are directed among different sisters within a network, or between the local network and other networks,
even the Internet. These rules can be configured to optimize the flow of traffic.
net, improve security, balance the load, and meet other specific needs.

Set the Routing to a Host:


$ route add -host<target>gw<gw_addr>
§ -host<target>
Indicates that the<target>it is a single host or a specific IP address, not a network.
§ gw<gw_addr>
Specify the IP address<gw_addr>from the gateway, which is the network device to which the packets are
they should be sent if they are destined to<target>.
Example:
$ route add -host192.161.4.1gw192.161.1.254

Set the Routing to a Subnet:


$ route add -net <target> gw <gw_addr>
§ -net<target>
This option indicates that the des>tination<target>it is a network, not a single host.
<target>It is the IP address of the destination network.
Example:
$ route add -net [Link] netmask [Link] gw [Link]

Set the Routing via Default Gateway:


$ route add default gw<gw_addr>
§ default
Indicates that it is about the default gateway, if there are no specific rules on the
the packaging designation will send the data to the gateway<gw_addr>.
Example:
$ route add default gw [Link]

Permanent Configuration
To make the Rou>ng Tables permanent, actions are taken on the interface blocks within the file.
/etc/network/interfaces. The Default Gateway is set using the commandgateway,
while other Rou>ng Rules can be set via the directpost-up, that
executes a command following the activation of the interface.
Example:
$ nano /etc/network/interfaces
auto eth0
interface eth0 inet static
address [Link]
netmask [Link]
gateway [Link]
post-uproute add -net192.168.2.0 netmask [Link] gw [Link]

4
Routing
Network with IP Forwarding (3 Hosts - 2 Switches)
Configure the network present in the following scenario:

• In the schema in question, there are two Subnets:


§ LAN1:[Link]/24
§ LAN2:[Link]/24
• The HostH2fa is part of both Subnets, so it has no issues reaching the other two nodes.
H2 must perform routing functions to allow communication between the two subnets.
• Once the network interfaces of the respective hosts are configured:
§ Enable IP Forwarding on H2
§ Configure the Rounging table of H1(H3) to reach host H3(H1) via H2, with
one of the possible methodologies of Rou>ng:
Routing towards the Host
b. Routing towards the Subnet
Routing through Default Gateway

Solution:
Marionette Network
[Link]:H1,H2,H3
2. Machine > Modify > H2 > Ethernet cards = 2
[Link]:S1,S2
[Link] cable:d1[H1toS1],d2[H2toS1],d3[H2toS2],d4[H3toS2]
§ Then press the [Start all] button.

Continuity→

5
Routing
Network with IP Forwarding (3 Hosts - 2 Switches)

Network Interface Configuration


§ H1Terminal
$ nano /etc/network/interfaces
auto eth0
iface eth0 inet static
address [Link]
netmask [Link]
$ ifup eth0
§ H2Terminal
$ nano /etc/network/interfaces
auto eth0
interface eth0 inet static
address [Link]
netmask [Link]

auto eth1
interface eth1 inet static
address [Link]
netmask [Link]
$ ifup eth0 eth1
§ H3Terminal
$ nano /etc/network/interfaces
auto eth0
interface eth0 inet static
address [Link]
netmask [Link]
$ ifup eth0

IP Forwarding Enablement
§ H2Terminal
$ sysctl -w net.ipv4.ip_forward=1 ← Temporary enabling of IP Forwarding.
net.ipv4.ip_forward = 1

Routing Rules Configuration


a) Routing to a Host
H1$ route add [Link] gw [Link]
H3$ route add [Link] gw [Link]
b) Routing to a Subnet
H1$ route add -net [Link] netmask [Link] gw [Link]
H3$ route add -net [Link] netmask [Link] gw [Link]
c) Routing through Default Gateway
H1$ route add default gw [Link]
H3$ route add default gw [Link]

6
Routing
Network with IP Forwarding (4 Hosts - 3 Switches)
Extend the previous network configuration to allow communication between the nodes.
following network:

Solution:
Marionette Network
1. Machine > Modify >H3> Ethernet cards = 2
2. Machine: H4
3. Switch: S3
4. Straight cable: d4[H3(eth1) to S2], d5[H3(eth0) to S3], d6[H4 to S3]
§ Then press the [Start all] button.

Continuation→

7
Routing
Rete con IP Forwarding(4 Host – 3 Switch)

Configuration: Network Interfaces + Routing Rules


§ H1Terminal
$ nano /etc/network/interfaces
autoeth0
iface eth0 inet static
address192.168.1.1
netmask [Link]
post-uproute add -net [Link] netmask [Link] gw192.168.1.254
post-uproute add -net [Link] netmask [Link] gw192.168.1.254
$ ifup eth0
§ H2Terminal
$ nano /etc/network/interfaces
autoeth0
iface eth0 inet static
address192.168.1.254
netmask [Link]

autoeth1
ifaceeth1inet static
address192.168.2.254
netmask [Link]
post-uproute add -net [Link] netmask [Link] gw192.168.2.1
$ ifup eth0 eth1
§ H3Terminal
$ nano /etc/network/interfaces
autoeth0
iface eth0 inet static
address192.168.3.1
netmask [Link]

autoeth1
ifaceeth1inet static
address192.168.2.1
netmask [Link]
post-uproute add -net [Link] netmask [Link] gw192.168.2.254
$ ifup eth0 eth1
§ H4Terminal
$ nano /etc/network/interfaces
autoeth0
iface eth0 inet static
address192.168.3.2
netmask [Link]
post-uproute add -net [Link] netmask [Link] gw192.168.3.1
post-uproute add -net [Link] netmask [Link] gw192.168.3.1
$ ifup eth0
Continuation→

8
Routing
Network with IP Forwarding (4 Hosts - 3 Switches)

IP Forwarding Enablement
§ H2Terminal
$ sysctl -w net.ipv4.ip_forward=1
net.ipv4.ip_forward = 1
§ H3Terminal
$ sysctl -w net.ipv4.ip_forward=1
net.ipv4.ip_forward = 1

You might also like