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!

How to persist vlan settings (script help)?

Discussion in 'Asuswrt-Merlin' started by g1dtf, Sep 15, 2019.

  1. g1dtf

    g1dtf Occasional Visitor

    Joined:
    Oct 28, 2012
    Messages:
    19
    Location:
    UK
    I have an N66u (Rmerlin 374.43_2) with the following vlan settings.

    robocfg vlan 20 ports "0t 8t"
    vconfig add eth0 20
    ifconfig vlan20 up
    brctl addif br0 vlan20

    I want them to survive a reboot and from what I have read this needs to be done with a script. I am looking for help in writing, installing and executing the script on my N66U . I have read various threads on this but finished up more confused than before.

    Thanks

    Andy.
     
  2. Martineau

    Martineau Part of the Furniture

    Joined:
    Jul 8, 2012
    Messages:
    2,320
    Location:
    UK
    There is a wealth of information here RMerlin Wiki and includes examples of implementing scripts on the router.

    Basics for creating/exploiting scripts.

    e.g. My_script.sh

    1. Enable SSH access to router via the GUI
    Administration->System TAB then Click 'Enable SSH=LAN only'
    2. If you are using a Windows device then install WinSCP to create/edit the script file on the router.
    I posted a mini-tutorial of getting a script onto the router via WinSCP:
    Using WinSCP to create scripts/files on Asus Router
    or SSH into the router then use the router's nano editor.

    3. As per the Wiki, ensure your script is executable
    SSH to the router using your preferred SSH Client (Xshell6,MobaXterm or PuTTY etc.) and issue​
    Code:
    dos2unix   /jffs/scripts/My_script.sh
    chmod a+rx /jffs/scripts/My_script.sh
    4. Ensure that execution of scripts is enabled - either via the GUI
    Adminstration->System TAB then Click 'Enable JFFS custom scripts and configs=YES'​
    or from the command line
    Code:
    nvram set jffs2_scripts="1"
    nvram commit
    5. If you are logged on to the Routers SSH console you can now test the script
    Code:
    sh /jffs/scripts/My_script.sh
    For your VLAN script, I suggest you use nat-start

    /jffs/scripts/nat-start


    Code:
    #!/bin/sh
    
    sleep 10     # Always for nat-start?
    
    # Only create the VLAN if it doesn't already exist.
    if [ -z "$(robocfg show | grep -oF "vlan20:")" ];then
       robocfg vlan 20 ports "0t 8t"
       vconfig add eth0 20
       ifconfig vlan20 up
       brctl addif br0 vlan20
    fi
     
    Last edited: Sep 15, 2019
  3. g1dtf

    g1dtf Occasional Visitor

    Joined:
    Oct 28, 2012
    Messages:
    19
    Location:
    UK
    Thanks for the info but just for clarification regards nat-start. Is that a folder in which I place my script or the name of the script once created?
     
  4. Martineau

    Martineau Part of the Furniture

    Joined:
    Jul 8, 2012
    Messages:
    2,320
    Location:
    UK
    Read the Wiki …. e.g. User scripts
     
  5. g1dtf

    g1dtf Occasional Visitor

    Joined:
    Oct 28, 2012
    Messages:
    19
    Location:
    UK
    I have read that a couple of times and gathered that the scripts should be placed in /jffs/scripts/ and the script should be named nat-start etc but not sure whether the file needs the .sh suffix. Unless I am not understanding things correctly which is more than likely lol.
     
    Last edited: Sep 15, 2019