Setting up a Linux router in layer 3

Red Hat Enterprise Linux 9.2 LPAR mode z/VM guest

By default, your Linux instance is not a router. Depending on your IP version, IPv4 or IPv6 you can use the route4 or route6 attribute of your qeth device to define it as a router.

Before you begin

  • A suitable hardware setup must be in place that enables your Linux instance to act as a router.
  • The Linux instance is set up as a router. To configure Linux running in a z/VM® guest virtual machine or in an LPAR as a router, IP forwarding must be enabled in addition to setting the route4 or route6 attribute.
    For IPv4, enable IP forwarding by issuing:
    # sysctl -w net.ipv4.conf.all.forwarding=1
    For IPv6, enable IP forwarding by issuing:
    # sysctl -w net.ipv6.conf.all.forwarding=1

About this task

You can set the route4 or route6 attribute dynamically, while the qeth device is online.

The same values are possible for route4 and route6 but depend on the type of CHPID:
Table 1. Summary of router setup values
Router specification OSA-Express CHPID in QDIO mode HiperSockets CHPID
primary_router Yes No
secondary_router Yes No
primary_connector No Yes
secondary_connector No Yes
multicast_router Yes Yes
no_router Yes Yes
Both types of CHPIDs accept:
multicast_router
causes the qeth driver to receive all multicast packets of the CHPID. For a unicast function for HiperSockets see HiperSockets Network Concentrator.
no_router
is the default. You can use this value to reset a router setting to the default.
An OSA-Express CHPID in QDIO mode accepts the following values:
primary_router
to make your Linux instance the principal connection between two networks.
secondary_router
to make your Linux instance a backup connection between two networks.
A HiperSockets CHPID accepts the following values, if the microcode level supports the feature:
primary_connector
to make your Linux instance the principal connection between a HiperSockets network and an external network .
secondary_connector
to make your Linux instance a backup connection between a HiperSockets network and an external network .

Example

In this example, two Linux instances, Linux P and Linux S, running on an IBM® mainframe use OSA-Express to act as primary and secondary routers between two networks. IP forwarding must be enabled for Linux in an LPAR or as a z/VM guest to act as a router. In Red Hat® Enterprise Linux 9.2 you can set IP forwarding permanently in /etc/sysctl.conf or dynamically with the sysctl command.

Mainframe configuration:
Figure 1. Mainframe configuration
This graphic is described in the surrounding text.

It is assumed that both Linux instances are configured as routers in their LPARs or in z/VM.

Linux P configuration:
To create the qeth group devices:
# chzdev --active --enable qeth 0.0.0400,0.0.0401,0.0.0402
# chzdev --active --enable qeth 0.0.0200,0.0.0201,0.0.0202
Alternatively, use the sysfs attribute group:
# echo 0.0.0400,0.0.0401,0.0.0402 > /sys/bus/ccwgroup/drivers/qeth/group
# echo 0.0.0200,0.0.0201,0.0.0202 > /sys/bus/ccwgroup/drivers/qeth/group
To make Linux P a primary router for IPv4:
# chzdev -a qeth 0.0.0400 route4=primary_router
# chzdev -a qeth 0.0.0200 route4=primary_router
or, using sysfs:
# echo primary_router > /sys/bus/ccwgroup/drivers/qeth/0.0.0400/route4
# echo primary_router > /sys/bus/ccwgroup/drivers/qeth/0.0.0200/route4
Linux S configuration:
To create the qeth group devices:
# chzdev --active --enable qeth 0.0.0404,0.0.0405,0.0.0406
# chzdev --active --enable qeth 0.0.0204,0.0.0205,0.0.0206
or, using sysfs:
# echo 0.0.0404,0.0.0405,0.0.0406 > /sys/bus/ccwgroup/drivers/qeth/group
# echo 0.0.0204,0.0.0205,0.0.0206 > /sys/bus/ccwgroup/drivers/qeth/group
To make Linux S a secondary router for IPv4:
# chzdev -a qeth 0.0.0400 route4=secondary_router
# chzdev -a qeth 0.0.0200 route4=secondary_router
or, using sysfs:
# echo secondary_router > /sys/bus/ccwgroup/drivers/qeth/0.0.0404/route4
# echo secondary_router > /sys/bus/ccwgroup/drivers/qeth/0.0.0204/route4
In this example, qeth device 0.01510 is defined as a primary router for IPv6:
# chzdev --enable qeth 0.0.1510,0.0.1511,0.0.1512
# chzdev qeth 0.0.1510 route6=primary_router
# lszdev 1510 -i | grep route6
primary router
Alternatively, using sysfs attributes:
# cd /sys/bus/ccwgroup/drivers/qeth/0.0.1510
# echo 1 > online
# echo primary_router > route6
# cat route6
primary router