2 MAC addresses for one device/interface assigned via DHCP

I'd like to assign two IP addresses to my OpenWrt router via DHCP. At some point I was able to give the router two unique MAC addresses and assign an IP to them, but that config has since been wiped out by a hardware failure. I can't for the life of me figure out how I ended up doing it. If I had to guess it's some combination of aliases and device configs, but nothing seems to work.

Has anyone tried to do this? Am I the only one? Thanks for any help at all.

This is as a client?

First thing is you need to assign multiple interfaces with multiple unique mac addresses?

Are you using luci, editing config files or using uci from the command line?

I'm usually using a bridge and then creating virtual ethernet devices. Or it's using multiple ports on the bridge via vlans and bridge vlan filtering. I think macvlan might be what you want? I haven't done it by macvlan before.

Probably best to do uci show or cat your config. Plus a ubus call system board (Redacting PII of course) .

A block diagram of your network as well as 'why' you are trying to do this would be good? i.e. why do you need multiple IP's being served over DHCP.

Sorry yes, as a client.

I'm trying to use luci, but I'm open to anything.

Here is my current config, which works just fine, but I'd like to use DHCP for the IP addresses.

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

config device
	option name 'br-lan'
	option type 'bridge'
	list ports 'lan'
	list ports 'wan'

config device
	option name 'lan'
	option macaddr '58:cb:52:dc:f3:24'

config interface 'lan'
	option device 'br-lan'
	option proto 'static'
	list ipaddr '192.168.4.6/24'
	list ipaddr '192.168.4.7/24'
	option gateway '192.168.4.1'
	list dns '192.168.4.1'
{
	"kernel": "5.15.150",
	"hostname": "OpenWrt",
	"system": "ARMv7 Processor rev 5 (v7l)",
	"model": "Google WiFi (Gale)",
	"board_name": "google,wifi",
	"rootfs_type": "squashfs",
	"release": {
		"distribution": "OpenWrt",
		"version": "23.05.3",
		"revision": "r23809-234f1a2efa",
		"target": "ipq40xx/chromium",
		"description": "OpenWrt 23.05.3 r23809-234f1a2efa"
	}
}

This can be done with an alias interface:

config interface 'lan2'
   option device '@lan'
   option proto 'dhcp'

This is common (and useful) for a dual stack setup where an interface holds both a v4 and a v6 IP address. The question remains what is the usefulness of having two IPv4s on one physical or bridge device, especially when they are in the same subnet.

2 Likes

In my case I'm running Nginx on the openwrt device. This just allows me to serve external sites and internal sites from the same device.

The router sends traffic to the .6 address and internal machines (via dns) go to the .7 address.

Obviously this is not perfect, and foolproof, but I'm also not serving anything super important on these sites.

I'd just like to avoid setting static IPs and setting dns servers.