Forward DHCP requests and subsequent traffic on one LAN port only

Hi, I am trying to figure out a specific setup.

I have an OpenWrt router connected on its WAN-port to a modem. The router gets DHCP from the modem and does DHCP for all connected devices on LAN and Wifi itself.

Additionally, all LAN and Wifi traffic is routed via an wireguard interface, so there is no LAN->WAN traffic directly atm.

However, I want to change the setup of the first LAN port. All its traffic should be directed to the modem and the modem should supply DHCP for devices connected to LAN 1.

How do I accomplish seperating LAN 1 from the other ports/wifi bridge and how to enable forwarding in both directions. I am using CLI, not LuCI.

The device is an Archer C7v5, using swconfig and 18.06, which will be upgraded but I need the aforementioned setup to work until the upgrade can be done.

Output of network config

config interface 'loopback'
	option ifname 'lo'
	option proto 'static'
	option ipaddr '127.0.0.1'
	option netmask '255.0.0.0'

config interface 'lan'
	option type 'bridge'
	option proto 'static'
	option netmask '255.255.255.0'
	option ipaddr '192.168.1.1'
	option _orig_ifname 'eth0.1 wlan0-1 wlan0-2'
	option _orig_bridge 'true'
	option ifname 'bat0 eth0.1'
	option ipv6 '0'

config interface 'wan'
	option ifname 'eth0.2'
	option proto 'dhcp'
	option ipv6 '0'

config switch
	option name 'switch0'
	option reset '1'
	option enable_vlan '1'

config switch_vlan
	option device 'switch0'
	option vlan '1'
	option ports '2 3 4 5 0t'

config switch_vlan
	option device 'switch0'
	option vlan '2'
	option ports '1 0t'

config interface 'wg_wan'
	option ifname 'wg0'
	option _orig_ifname 'wg0'
	option _orig_bridge 'false'
	option proto 'static'
	option netmask '255.255.0.0'
	option dns '8.8.8.8 8.8.4.4'
	option ipv6 '0'

config interface 'meshbat'
	option ifname '@wireless0.0'
	option proto 'batadv'
	option mesh 'bat0'
	option mtu '1528'

config interface 'wireless0'
	option mtu '1528'
	option proto 'none'

Output of DHCP file

config dnsmasq
	option domainneeded '1'
	option boguspriv '1'
	option filterwin2k '0'
	option localise_queries '1'
	option rebind_protection '1'
	option rebind_localhost '1'
	option local '/lan/'
	option domain 'lan'
	option expandhosts '1'
	option nonegcache '0'
	option authoritative '1'
	option readethers '1'
	option leasefile '/tmp/dhcp.leases'
	option nonwildcard '1'
	option localservice '1'
	option resolvfile '/etc/resolv.conf'

config dhcp 'lan'
	option interface 'lan'
	option dhcpv6 'disabled'
	option ra 'disabled'
	option start '50'
	option limit '200'
	option leasetime '1h'

config dhcp 'wan'
	option interface 'wan'
	option ignore '1'

config odhcpd 'odhcpd'
	option maindhcp '0'
	option leasefile '/tmp/hosts/odhcpd'
	option leasetrigger '/usr/sbin/odhcpd-update'
	option loglevel '4'

Output of firewall file

config defaults
	option syn_flood '1'
	option input 'ACCEPT'
	option output 'ACCEPT'
	option forward 'ACCEPT'

config zone
	option name 'lan'
	list network 'lan'
	option input 'ACCEPT'
	option output 'ACCEPT'
	option forward 'ACCEPT'

config zone
	option name 'therm'
	list network 'therm'
	option input 'ACCEPT'
	option output 'ACCEPT'
	option forward 'ACCEPT'

config zone
	option name 'wan'
	list network 'wan'
	list network 'wan6'
	option input 'REJECT'
	option output 'ACCEPT'
	option forward 'REJECT'
	option masq '1'
	option mtu_fix '1'

config rule
	option name 'Allow-DHCP-Renew'
	option src 'wan'
	option proto 'udp'
	option dest_port '68'
	option target 'ACCEPT'
	option family 'ipv4'

config rule
	option name 'Allow-Ping'
	option src 'wan'
	option proto 'icmp'
	option icmp_type 'echo-request'
	option family 'ipv4'
	option target 'ACCEPT'

config rule
	option name 'Allow-IGMP'
	option src 'wan'
	option proto 'igmp'
	option family 'ipv4'
	option target 'ACCEPT'

config rule
	option name 'Allow-DHCPv6'
	option src 'wan'
	option proto 'udp'
	option src_ip 'fc00::/6'
	option dest_ip 'fc00::/6'
	option dest_port '546'
	option family 'ipv6'
	option target 'ACCEPT'

config rule
	option name 'Allow-MLD'
	option src 'wan'
	option proto 'icmp'
	option src_ip 'fe80::/10'
	list icmp_type '130/0'
	list icmp_type '131/0'
	list icmp_type '132/0'
	list icmp_type '143/0'
	option family 'ipv6'
	option target 'ACCEPT'

config rule
	option name 'Allow-ICMPv6-Input'
	option src 'wan'
	option proto 'icmp'
	list icmp_type 'echo-request'
	list icmp_type 'echo-reply'
	list icmp_type 'destination-unreachable'
	list icmp_type 'packet-too-big'
	list icmp_type 'time-exceeded'
	list icmp_type 'bad-header'
	list icmp_type 'unknown-header-type'
	list icmp_type 'router-solicitation'
	list icmp_type 'neighbour-solicitation'
	list icmp_type 'router-advertisement'
	list icmp_type 'neighbour-advertisement'
	option limit '1000/sec'
	option family 'ipv6'
	option target 'ACCEPT'

config rule
	option name 'Allow-ICMPv6-Forward'
	option src 'wan'
	option dest '*'
	option proto 'icmp'
	list icmp_type 'echo-request'
	list icmp_type 'echo-reply'
	list icmp_type 'destination-unreachable'
	list icmp_type 'packet-too-big'
	list icmp_type 'time-exceeded'
	list icmp_type 'bad-header'
	list icmp_type 'unknown-header-type'
	option limit '1000/sec'
	option family 'ipv6'
	option target 'ACCEPT'

config rule
	option name 'Allow-IPSec-ESP'
	option src 'wan'
	option dest 'lan'
	option proto 'esp'
	option target 'ACCEPT'

config rule
	option name 'Allow-ISAKMP'
	option src 'wan'
	option dest 'lan'
	option dest_port '500'
	option proto 'udp'
	option target 'ACCEPT'

config include
	option path '/etc/firewall.user'

config forwarding 'wg_forward'
	option dest 'wg_wan'
	option src 'lan'

Thank you in advance!

Why not just move LAN1 to VLAN 2?

config switch_vlan
	option device 'switch0'
	option vlan '1'
	option ports '3 4 5 0t'

config switch_vlan
	option device 'switch0'
	option vlan '2'
	option ports '1 2 0t'
4 Likes

Well, that is insanely easy, wow. Thank you, I will receive feedback on whether it worked as intended later, but it seems to have done the trick. Would've never thought about that move.

2 Likes

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