Routing between two ethernet interfaces

Hi,

I'm new to OpenWRT so please forgive me if I ask the obvious.

Usually I get internet through a cable modem but their service is currently so horrible that I threw a cable over to my neighbours house to borrow some of his DSL connection until mine is fixed. So I need to temporarily connect two networks.

I have a RasPi 3B with an additional USB-to-Ethernet adapter 'eth1'. The built in port is 'br-lan'. OpenWRT is installed and running, both interfaces are working. Wifi on the Pi will not be used.

On my side is the cable router with a DHCP server. I cannot change its default gateway.
Network is 192.168.0.x. DHCP starts at .20. 'br-lan' has a fixed IP address of 192.168.0.19.
I plan to give the router a static route for 0.0.0.0 to 192.168.0.19 to divert all outbound traffic to one of the raspi ports.

My neighbour has basically the same setup but with DSL and uses 192.168.2.x. I cannot change anything on his side.

So - my side:
'br-lan'
Protocol: static address
IPv4: 192.168.0.19/24

neighbour:
'eth1'
Protocol: DHCP
IPv4: 192.168.2.120/24

What do I need to configure to route all outbound traffic from 'br-lan' to 'eth1'? The assumption is that the cable modem will send everything to 'br-lan'.
I plan to add traffic shaping later but first I need to make that work.

Thanks!

The DHCP client should automatically add a default route, which can be disabled in the advance settings.

2 Likes

Yes, it does that. That is the routing table:

Active IPv4-Routes Network Target IPv4-Gateway Metric Table
Ralf 0.0.0.0/0 192.168.2.1 0 main
lan 192.168.0.0/24 - 0 main
Ralf 192.168.2.0/24 - 0 main

(Ralf is the name of my neighbour)
So Ralf has a default route on that side to the gateway (192.168.2.1) which is correct.
But how do I enable routing between the two sides?

Btw I noticed I made a mistake: 'br-lan' is a bridge between eth0 and the radio. Since the radio is off its just eth0. So you can replace any mention off 'br-lan' above with 'eth0'. Sorry!

Hi ;

You may redirect traffic , using iptables

It should work as you describe. The default firewall will forward from the lan zone to the wan zone and NAT. So place the Ralf network in the wan firewall zone. A single port device sets up only the lan network to begin with, but the default firewall config file is the same for all devices. It assumes there will be a network named 'wan' leading to the Internet.

You can keep a bridge like br-lan even if it only has one hardware device in the bridge. This makes it simple to add more later.

3 Likes

Thanks - that was the hint I needed.

For the record: in the web interface under network -> interfaces you edit the interface and then switch to the tab 'Firewall Settings'. There you can assign the interface to the wan firewall zone. Then the routing starts.

This topic was automatically closed 0 minutes after the last reply. New replies are no longer allowed.