Score:1

Route traffic between two interfaces of a device

ng flag
LIH

I have ubuntu (Ubuntu Server 21.10) installed on a Raspberry Pi which is in the middle of the router(gateway) and the network switch. The reason for this design is, I want all the internet traffic to flow through the Raspberry Pi.

Raspberry Pi has two ethernet interfaces with following IP addresses eth1: 192.168.8.17/24 connected to the router, eth0: 192.168.8.18/24 connected to the switch

Router's ip address is 192.168.8.1

enter image description here

I want to make the traffic flow through eth0 and eth1 interfaces of the Raspberry Pi. Thanks in advance.

ng flag
LIH
@guiverc It's Ubuntu Server 21.10. If it helps, I'm open to install a different version too.
pe flag
with this design, rasp will not be a router but a forwarder. simply enable kernel ip forwarding. uncomment the line `net.ipv4.ip_forward=1` on the `/etc/sysctl.conf` configuration file.
ng flag
LIH
@cmak.fr Thanks for answering. I already tried that and it did not work. Don't I need to add any iptables rules? On the other hand what is the default gateway I should use for the devices in my network?
AlexOnLinux avatar
ng flag
i suggest you change your setup. Your pi and router need to be in a different subnet than your pc. also enable dhcp at eth0 so that your pi will give an ip to the pc. this way you have two distinct networks. next step is to create iptable rules to route the traffic from the subnet of eth0 to the subnet of eth1. This is what a router generaly does. you could search for raspberry pi as router guides on the web. there are plenty
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.