06 - Code example

December 2025

Configuring the Network Interface

First, we need to assign a static IP address to the ethernet port that will act as our gateway.

file: /etc/dhcpcd.conf

interface eth0
static ip_address=192.168.4.1/24
static noservice

Enabling IP Forwarding

By default, Linux prevents packets from moving between different network interfaces.

file: /etc/sysctl.conf

# Uncomment the following line to enable packet forwarding for IPv4
net.ipv4.ip_forward=1
No Pages Found