DHCP Domain-Related Issues

I just spent the whole night trying the following(UTC+8):
The machine is set up with three network ports: eth0, eth1, and eth2. Eth0 is used as the WAN port, while the other two are designated as LAN1 and LAN2, respectively. The WAN port uses any protocol to automatically obtain an address from upstream. LAN1 is statically configured as 100.64.2.1/24 with a DHCP pool enabled on the interface (range: 100.64.2.1–100.64.2.254), and LAN2 is statically configured as 100.64.3.1/24 with a DHCP pool enabled (range: 100.64.3.1–100.64.3.254).

Then, on the DHCP&DNS page, I wanted to create two separate instances: one to listen for IP address assignments and DNS resolution requests on LAN1, providing the suffix (levein.one), and another to listen for those on LAN2, providing the suffix (levein.two). However, no matter how I adjust the Device&Port settings for these two, I cannot achieve the desired effect. Is this feature simply not implemented OR I`m fool😭?

Working on the timezone?

Why this range in your lan?
Using what subnet mask?

My math says those numbers do not work but I do not play with subnet masks anymore.

Please run the following commands (copy-paste the whole block) and paste the output here, using the "Preformatted text </> " button:
grafik
Remember to redact passwords, MAC addresses and any public IP addresses you may have

ubus call system board; \
uci export network; \
uci export dhcp; uci export firewall

Thanks for your comment,bro, I'm staying up all night again tonight😁
100.64.0.0/10 is also a private address, often used in ISP-level private network addresses, but in fact it is no different from 192.168.0.0/16, 172.16.0.0/12, 10.0.0.0/8. As long as the network architecture is suitable, you can use it at will.
My lan1: 100.64.2.0/255.255.255.0 lan2: 100.64.3.0/255.255.255.0. These two private networks do not interfere with each other.

1 Like

Thank you for your help. :two_hearts:
This is a simulation environment, so I won't code it :hushed:.
Now I have connected WinA/B to Lan_A/B respectively. A can get the IP address and domain name (100.64.2.201/Win.levein.two) normally, but B can't get anything (169.254..)

{
        "kernel": "6.6.73",
        "hostname": "OpenWrt",
        "system": "AMD Ryzen 7 8845H w/ Radeon 780M Graphics",
        "model": "VMware, Inc. VMware20,1",
        "board_name": "vmware-inc-vmware20-1",
        "rootfs_type": "squashfs",
        "release": {
                "distribution": "OpenWrt",
                "version": "24.10.0",
                "revision": "r28427-6df0e3d02a",
                "target": "x86/64",
                "description": "OpenWrt 24.10.0 r28427-6df0e3d02a",
                "builddate": "1738624177"
        }
}
package 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 'fdfd:93a2:8348::/48'
        option packet_steering '2'

config interface 'wan'
        option device 'eth0'
        option proto 'dhcp'
        option force_link '1'
        option peerdns '0'
        list dns '223.5.5.5'
        list dns '119.29.29.29'
        option delegate '0'

config device
        option name 'eth0'
        option promisc '0'
        option ipv6 '0'
        option multicast '0'

config device
        option name 'eth1'
        option promisc '0'
        option ipv6 '0'
        option multicast '0'

config interface 'Lan_B'
        option proto 'static'
        option device 'eth2'
        option ipaddr '100.64.3.2'
        option netmask '255.255.255.0'
        option defaultroute '0'
        option delegate '0'

config interface 'Lan_A'
        option proto 'static'
        option device 'eth1'
        option ipaddr '100.64.2.2'
        option netmask '255.255.255.0'
        option defaultroute '0'
        option delegate '0'

config device
        option name 'eth2'
        option promisc '0'
        option ipv6 '0'
        option multicast '0'

package dhcp

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'

config dhcp 'Lan_B'
        option interface 'Lan_B'
        option start '201'
        option limit '54'
        option leasetime '12h'
        list dhcp_option '6,100.64.3.2'

config dhcp 'Lan_A'
        option interface 'Lan_A'
        option start '201'
        option limit '54'
        option leasetime '12h'
        list dhcp_option '6,100.64.2.2'

config dnsmasq '100_64_2_0'
        option rebind_protection '0'
        option localservice '1'
        option authoritative '1'
        option local '/levein.two/'
        option domain 'levein.two'
        option expandhosts '1'
        list interface 'Lan_A'
        option sequential_ip '1'
        option boguspriv '0'
        option nonegcache '1'
        option localuse '1'
        option noresolv '1'

config dnsmasq '100_64_3_0'
        option authoritative '1'
        option local '/levein.thr/'
        option domain 'levein.thr'
        option expandhosts '1'
        option rebind_protection '0'
        option localservice '1'
        list interface 'Lan_B'
        option sequential_ip '1'
        option boguspriv '0'
        option nonegcache '1'
        option noresolv '1'

package firewall

config defaults
        option input 'REJECT'
        option output 'ACCEPT'
        option forward 'REJECT'

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

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

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

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 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 forwarding
        option src 'Lan_A'
        option dest 'wan'

config forwarding
        option src 'Lan_B'
        option dest 'wan'

config include 'openclash'
        option type 'script'
        option path '/var/etc/openclash.include'

Looks good to me. Have you tested the interface LANB by manually assigning a Ip-address to a client. ?

Yes, I’ve tried it, and communication works normally. This indicates that DHCP is failing on the Lan_B interface.

Also, I’ve noticed that no matter how I configure it, the DHCP server always listens on 0.0.0.0:67.
I think it would work better if each DHCP service could listen on a separate interface, for example, LanA’s DHCP only on 100.64.2.2:67 and LanB’s DHCP only on 100.64.3.2:67. :thinking:

I think that is illegal and probably prevents the DHCP service from starting. The highest usable IP in a /24 is .254. Don't push the edge condition move limit back to 50 or so.

The more that you move from defaults, the less likely it is to work. This use case does not require multiple instances of dnsmasq, turning off promisc mode, custom DHCP options, or any of much of what you've done. I would suggest you move back to defaults and confirm that the one LAN present by default does serve DHCP addresses to your external network. Then add a second LAN.

When running in a VM it is of course necessary to also properly configure networking in the host / hypervisor, which is outside the scope of this forum.

3 Likes

Please check the dhcp traffic with tcpdump, e.g tcpdump -i eth2 port 67 or port 68

You can also run logread|grep dnsmasq-dhcp

2 Likes