Same ethernet, two mac, two subnets - how?

I want to use the same physical ethernet connection to the router, but have the host and network namespace have different ips - think of how a virtual machine gets a different IP other than the host.

I've managed to get to the point of requesting a lease to the router. However, I also wanted the network namespace to be in a different subnet - for this, I used macvlan and assigned a different macaddress to it.

I've tried setting up this macaddress in Network -> DHCP & DNS -> Static Leases and assign it an ip in the other /24, however the assigned ip is always in the same /24 as the host. Is there another way to "signal" the router that this device should be in another /24?

The straightforward solution is to use vlan-s to have multiple isolated networks.

Other solution to have 2 dhcp clients or dhcp client and static ip-s it to add bridge and configurable veth devices alongside physical interfeace, this way you can connect unlimited invented hosts in the same place, like having 2 subnets on the same wire etc.

Post output of

ubus call system board
cat /etc/config/network # edit away passwords, MAC addresses etc secrets

Say your br-lan or eth0 is 192.168.1/24
Add an alias interface and assign 192.168.2/24
Then dnsmasq is able to serve both subnets. The caveat being (as far as I know) for one of the subnets you'll have to do static lease and ignore unknown mac.


{
	"kernel": "5.15.167",
	"hostname": "OpenWrt",
	"system": "MediaTek MT7621 ver:1 eco:3",
	"model": "TP-Link Archer AX23 v1",
	"board_name": "tplink,archer-ax23-v1",
	"rootfs_type": "squashfs",
	"release": {
		"distribution": "OpenWrt",
		"version": "23.05.5",
		"revision": "r24106-10cc5fcd00",
		"target": "ramips/mt7621",
		"description": "OpenWrt 23.05.5 r24106-10cc5fcd00"
	}
}

cat /etc/config/network


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

config globals 'globals'
	option ula_prefix 'dde7:f626:f7d7::/48'
	option packet_steering '1'

config device
	option name 'br-lan'
	option type 'bridge'
	list ports 'lan1'
	list ports 'lan2'
	list ports 'lan3'
	list ports 'lan4'
	option mtu '1492'

config interface 'lan'
	option device 'br-lan'
	option proto 'static'
	option ipaddr '192.168.1.1'
	option netmask '255.255.255.0'
	option ip6assign '64'
	list dns '2a07:a8c0::9c:99bc'
	list dns '45.90.28.39'
	option dns_metric '0'
	list ip6class 'wan_6'

config interface 'wan'
	option device 'wan'
	option proto 'pppoe'
	option username '*'
	option password '*'
	option ipv6 'auto'
	option peerdns '0'
	list dns '45.90.28.39'
	option dns_metric '0'
	option ip6assign '64'

config interface 'wan6'
	option device 'wan'
	option proto 'dhcpv6'
	option reqaddress 'force'
	option reqprefix 'auto'
	option peerdns '0'
	list dns '2a07:a8c0::9c:99bc'
	option sourcefilter '0'
	option norelease '1'
	option ip6assign '64'

config device
	option type 'bridge'
	option name 'br-guest'
	option bridge_empty '1'
	option mtu '1492'

config interface 'iguest'
	option proto 'static'
	option device 'br-guest'
	list ipaddr '192.168.2.1/24'

config interface 'iproton'
	option proto 'static'
	option device 'br-wg'
	list ipaddr '192.168.3.1/24'

	
# currently unused
config device
	option type '8021q'
	option ifname 'lan2'
	option vid '20'
	option name 'lan2.20'
	option ipv6 '0'

config device
	option type 'bridge'
	option name 'br-wg'
	option bridge_empty '1'
	option mtu '1492'

config interface 'wg0'
	option proto 'wireguard'
	option private_key '*'
	list dns '10.2.0.1'
	list addresses '10.2.0.2/24'

config wireguard_wg0
	option description 'Imported peer configuration'
	option public_key '*'
	list allowed_ips '0.0.0.0/0'
	option endpoint_host '*'
	option endpoint_port '51820'

I kind of got this working with PBR and setting up the mac manually when creating the namespace in linux, but it's not ideally in the subnet I want. Since dhcp was giving an ip in the 192.168.1.0.24 subnet, I created a rule for it to be routed through wg

config policy
	option name 'teste macvlan'
	option src_addr '192.168.1.158'
	option interface 'wg0'

Your MTU-s make no sense. Clean them and reboot.

shouldn't they be 1492 considering the limitig exit through PPoE, subtracting PPPoE headers size from 1500?