

FORWARD - All packets neither destined for nor originating from the Pi, but passing through (routed by) the Pi.OUTPUT - All packets originating from the Pi.

INPUT - All packets destined for the Pi.# Uncomment the next line to enable packet forwarding for IPv4 The line we want is already there, we just want to uncomment it out. Routing can be enabled by editing the nf file. The first thing we need to do is turn on routing on the Pi which is disabled by default. Iptables places rules into predefined chains (INPUT, OUTPUT and FORWARD) that are checked against any network traffic relevant to those chains and a decision is made about what to do with each packet based upon the outcome of those rules. Most Linux distros come with a powerful firewall built-in, commonly referred to as iptables. This is achieved by Network Address Translation (NAT) On Linux, NAT can be configured using iptables. What we want it to happen is to change the source IP from 10.10.10.10 to the IP address of the wlan0 interface which is 192.168.0.10. Let's say the traffic that arrives on the eth0 interface has the source IP of 10.10.0.10 and the destination IP of 8.8.8.8. When the traffic from my lab devices arrives at the Pi's eth0 interface, we want the traffic to be routed to the wlan0 interface and then to the Internet. There are two important things you need to be familiar with, IP routing and NAT.

My ultimate goal is to provide Internet connectivity to the devices in the home lab. Home lab devices get an IP address in the 10.10.0.0/24 subnet and use 10.10.0.1 as the gateway (Pi is the gateway for the lab devices).I connected my home lab directly to Pi's ethernet port (eth0) and assigned an IP of 10.10.0.1/24.Pi is connected to the ISP provided router via Wi-Fi (wlan0, and gets internet).Diagram $ ip adġ: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000

There are many ways to accomplish this task but for me using the Pi as a router seemed to be the most straightforward way. I recently came across a situation where I needed to create a separate network for my home lab which also requires Internet connectivity. I have a Raspberry pi 4 which I solely use to block ads using Pi-hole.
