SysTutorials

Configure Custom DHCP Gateway IP in OpenWrt

· updated April 12, 2026

When clients connect to your OpenWRT router via DHCP, they typically receive the router itself as the default gateway. Sometimes you need to advertise a different gateway — whether you’re running a proxy, load balancer, or multi-gateway setup on your network. This is done via DHCP option 3 (the router option in the DHCP specification).

Understanding DHCP Option 3

DHCP option 3 tells clients which IP address to use as their default gateway. By default, OpenWRT advertises its own LAN IP. You can override this to point clients to a different gateway on the network.

The format is simple: 3,<gateway-ip>. For example, to advertise 192.168.1.2 as the gateway, you’d use:

3,192.168.1.2

Method 1: Via UCI Command Line

SSH into your router and use uci to add the DHCP option:

uci add_list dhcp.lan.dhcp_option="3,192.168.1.2"
uci commit dhcp
/etc/init.d/dnsmasq restart

Verify the option was saved:

uci get dhcp.lan.dhcp_option

If you need to remove or replace the option:

uci del dhcp.lan.dhcp_option
uci commit dhcp
/etc/init.d/dnsmasq restart

Method 2: Via LuCI Web Interface

  1. Navigate to Network → Interfaces
  2. Click Edit on the LAN interface
  3. Go to the DHCP Server tab
  4. In the DHCP-Options field, enter: 3,192.168.1.2
  5. Click Save & Apply

The web interface will validate and apply the change immediately.

Adding Multiple DHCP Options

If you need to set additional options alongside the gateway, add them on separate lines in LuCI, or use multiple uci add_list commands:

uci add_list dhcp.lan.dhcp_option="3,192.168.1.2"
uci add_list dhcp.lan.dhcp_option="6,8.8.8.8,8.8.4.4"
uci commit dhcp
/etc/init.d/dnsmasq restart

This example sets gateway to 192.168.1.2 and DNS servers to Google’s public DNS.

Verifying the Configuration

Test that clients receive the correct gateway:

On a Linux client:

dhclient -v eth0

Check the offered options in the output, or inspect /var/lib/dhcp/dhclient.leases.

On Windows:

ipconfig /release
ipconfig /renew
ipconfig /all

Look for “Default Gateway” in the output.

Important Considerations

Reverting to Default

To restore the default behavior (router advertises itself as gateway), simply remove the custom option:

uci del dhcp.lan.dhcp_option
uci commit dhcp
/etc/init.d/dnsmasq restart

2026 Best Practices and Advanced Techniques

For Configure Custom DHCP Gateway IP in OpenWrt, understanding both the fundamentals and modern practices ensures you can work efficiently and avoid common pitfalls. This guide extends the core article with practical advice for 2026 workflows.

Troubleshooting and Debugging

When issues arise, a systematic approach saves time. Start by checking logs for error messages or warnings. Test individual components in isolation before integrating them. Use verbose modes and debug flags to gather more information when standard output is not enough to diagnose the problem.

Performance Optimization

Security Considerations

Security should be built into workflows from the start. Use strong authentication methods, encrypt sensitive data in transit, and follow the principle of least privilege for access controls. Regular security audits and penetration testing help maintain system integrity.

These complementary tools expand your capabilities:

Integration with Modern Workflows

Consider automation and containerization for consistency across environments. Infrastructure as code tools enable reproducible deployments. CI/CD pipelines automate testing and deployment, reducing human error and speeding up delivery cycles.

Quick Reference

This extended guide covers the topic beyond the original article scope. For specialized needs, refer to official documentation or community resources. Practice in test environments before production deployment.

← All posts