1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
Dismiss Notice

Welcome To SNBForums

SNBForums is a community for anyone who wants to learn about or discuss the latest in wireless routers, network storage and the ins and outs of building and maintaining a small network.

If you'd like to post a question, simply register and have at it!

While you're at it, please check out SmallNetBuilder for product reviews and our famous Router Charts, Ranker and plenty more!

ASUSwrt: How to get VLAN specific IP address for the AP via DHCP

Discussion in 'Asuswrt-Merlin' started by A.D., Apr 21, 2019.

  1. A.D.

    A.D. Regular Contributor

    Joined:
    Feb 15, 2016
    Messages:
    82
    Running ASUSwrt-Merlin 380.70 (but in this regard, there should be no difference to ASUSwrt).

    The device is set up as an access point. Starting from there, a script introduces VLANs which map traffic to various SSIDs and LAN ports; the WAN port is the trunk.

    How can I have the ASUS box (access point) send out DHCP requests for itself (its config UI etc) via a given VLAN? It's easy to get none (that's the default) or have a static one (ifconfig for the related bridge does the job). But how can I tell the bridge to get an IP address via DHCP?
     
  2. eibgrad

    eibgrad Regular Contributor

    Joined:
    Feb 20, 2017
    Messages:
    153
    You need to use the DHCP client (/sbin/udhcpc) and specify the appropriate options. If you dump the process table (ps), you'll see the one running on the WAN.

    Code:
     1842 admin     1428 S    /sbin/udhcpc -i vlan2 -p /var/run/udhcpc0.pid -s /tmp/udhcpc -O33 -O249
    Use udhcpc --help to see all the options.
     
  3. A.D.

    A.D. Regular Contributor

    Joined:
    Feb 15, 2016
    Messages:
    82
    Thank you, that's a good starting point. I was wondering how its start is actually triggered, though. There are entries such as wan_proto=dhcp in the NVRAM so I was hoping to configure stuff there.

    When I enable DHCP on WAN in AP mode, I indeed can see one instance of udhcpc running. Unfortunately, it's called with a script that appears to be binary and I came across an (old) article saying that there are versions of such scripts which mess up "unexpected" config when they are triggered upon events (such as renewing the lease). In fact, it could be that I saw such an effect, so I may have to provide a config change tolerant script...

    But apart from that, I'll try to start it in my services-start script when I'm sure that it doesn't mess with the rest of my config modifications.
     
  4. eibgrad

    eibgrad Regular Contributor

    Joined:
    Feb 20, 2017
    Messages:
    153
    It's not as if you need to somehow trick the router into using your script in lieu of the WAN's use of udhcpc. If the WAN is disabled, udhcpc simply doesn't run. And at that point, you can (as you've already suggested) start udhcpc on the LAN's network interface, presumably in the services-start script.

    Frankly, I don't know for sure what the WAN's script does (as you said, it's binary), so I don't know how vital it is to replicate that script for your purposes. The WAN script could be completely unrelated to your needs. For example, it may trigger the DDNS client (because the WAN ip changed), and/or maybe is triggers the wan-start event. None of which are relevant to you.
     
  5. A.D.

    A.D. Regular Contributor

    Joined:
    Feb 15, 2016
    Messages:
    82
    Thanks! - Yes, it should. But it seems it was not user config tolerant once and I presume the binary version was done by ASUS. And to me, some things in ASUSwrt look "partially hardwired" so I wouldn't be surprised if assumptions are being mede there which could stand in my way.