Network Routing and IP Forwarding Guide
Network Routing and IP Forwarding Guide
Consider the following network, let's have the nodes communicate with each other:
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.
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.
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:
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)
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
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)
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