NETGEAR is aware of a growing number of phone and online scams. To learn how to stay safe click here.

Forum Discussion

SLK-Purdue's avatar
SLK-Purdue
Luminary
Mar 22, 2020

Attached Devices Sorted by IP Number

I have a good number of devices on my home network.   I manage then with static DHCP reservations and I wanted to be able to get an Attached Device display in the web ui sorted by IP number.   The attached changes to /www/DEV_show_device.htm implement that change.   Changes are highlighted in yellow on pages 2 and 3.  This works for firmware version V2.5.1.8.

 

A couple thoughts

 

1. This change requires Telnet access to ORBI and an editor such as vi.   If you are not comfortable with your skills to do that, take the time to learn them.   Editing a live system always requires great care.

2. The coding techniques used here are not original to me.   They are from a collections of really great example by amazing coders available on the internet.   Thanks to the many people who contribute to that body of freely available information.

3. The "better" answer would be to offer a sort click for every column in the Attached Devices wed ui but I really only need the IP address so I decided to just hard code this sort for my needs.

33 Replies

  • CrimpOn's avatar
    CrimpOn
    Guru - Experienced User

    Considering users have been asking Netgear for this for at least two years, WOW.

    For those of us uncertain how Orbi's Linux is different from others we have used, would you mind sharing the procedure used to implement the change?  My guess is the process is to (a) make a backup copy of this file in case I screw it up and have to go back, (b) edit the file. AND?????

     

    This probably has to be done with each firmware release.

     

    Thanks

    • SLK-Purdue's avatar
      SLK-Purdue
      Luminary

      CrimpOn wrote:

      Considering users have been asking Netgear for this for at least two years, WOW.

      For those of us uncertain how Orbi's Linux is different from others we have used, would you mind sharing the procedure used to implement the change?  My guess is the process is to (a) make a backup copy of this file in case I screw it up and have to go back, (b) edit the file. AND?????

       

      This probably has to be done with each firmware release.

       

      Thanks


      I struggled with that idea when I thought about my original post.  My problem is there are too many variable for both tools and skills.   For Telnet, I use PuTTY but there are many other good tools.  Once you get Telnet working, log in as "admin" with your router password.   Then at the prompt type "cd /www" to change directories.  I would then "cp DEV_show_devices.htm  DEV_show_devices.orig" to create a backup of the original file.   Editing is the difficult part.  The editor vi isn't the easiest to use.  I am open to ideas.  Maybe other members have ideas.   The best idea, of course, would be to get NETGEAR to make this available in their firmware.  :-)

       

      Scott

      • CrimpOn's avatar
        CrimpOn
        Guru - Experienced User

        SLK-Purdue wrote:

        I struggled with that idea when I thought about my original post.  My problem is there are too many variable for both tools and skills.   For Telnet, I use PuTTY but there are many other good tools.  Once you get Telnet working, log in as "admin" with your router password.   Then at the prompt type "cd /www" to change directories.  I would then "cp DEV_show_devices.htm  DEV_show_devices.orig" to create a backup of the original file.   Editing is the difficult part.  The editor vi isn't the easiest to use.  I am open to ideas.  Maybe other members have ideas.   The best idea, of course, would be to get NETGEAR to make this available in their firmware.  :-)

        I use PuTTY as well (love it).  Will brush up on vi before attempting this.  (Have been using nano with my Raspberry Pi's and Linux Mint machines.)  It is really annoying that the Nighthawk line has had the "click on a column" for years.  Using different sort routines would not be a serious issue.  (If .. then, else or something similar)  It's recognizing the column click and setting the selection variable that is WAY beyond me.

         

        I cannot think of any "Downside" to sorting by IP address.

  • Got one report of problems that I think may be due to line wrap in the PDF.   The important code should look like:

     

    function ip2int(ip) {
    return ip.split('.').reduce(function(ipInt, octet) { return (ipInt<<8) + parseInt(octet, 10)}, 0) >>> 0;
    }

    Array.prototype.keySort = function(key, desc){
    this.sort(function(a, b) {
    var result = desc ? (ip2int(a[key]) < ip2int(b[key])) : (ip2int(a[key]) > ip2int(b[key]));
    return result ? 1 : -1;
    });
    return this;
    }

     

    • CrimpOn's avatar
      CrimpOn
      Guru - Experienced User

      SUCCESS!  This is SO COOL.

       

      Looking at the web page contents, I am tempted to think there might be a way to have two "Attached Devices" menu items on the main menu so the user could select one or the other.  (Not brave enough to try that.)

       

      There is a timer somewhere that defines how long Orbi waits between updating the display.  Wonder if that timer is in NVRAM somewhere?

      The reason I ask is browser dependent.  When I open Attached Devices in Chrome, Edge, and Opera the screen refresh is really obvious.  The entire column of device icons (the stupid new graphics that replaced our cool pictures) and Connection Status both flicker as they refresh every 7.5 seconds (on my Orbi).  Really annoying.  Strangely, Firefox does not.  Perhaps there is some technology buried in Firefox that compares page changes and decide they are not actually "changes".  So, for now I will stick with Firefox when looking at Attached Devices.

       

      Thank SO MUCH.

      • SLK-Purdue's avatar
        SLK-Purdue
        Luminary

        Glad you got it working.   I have a number of things on my list that I would like to change.  Since we have a "stay home" order, I may get some time to work down the list.  We'll see.

         

        Thanks,

        Scott

  • Thanks to the Stay-At-Home order, I have had some time to work on this a bit more.  Please stay safe, stay healthy, and stay home!

     

    A complete replacement for /www/DEV_show.device.htm available on Dropbox (dots removed to keep obey the forum rules about URLs)   

     

    www dropbox com/s/svqx6020yq0avgh/DEV_show_device.htm?dl=0

     

    You can diff if you want to see changed.

     

    1.You can now sort any column of the device connections by clicking the heading

    2. I removed the unnecessary repaints when nothing changes.  They were just annoying.

    3. If you click on a heading, not only will the column sort but new devices will be added if they have recently connected.

    4. The timing for the recheck for new devices was increased to 4 minutes to keep the load light.  If no new devices are found, the screen will not repaint.  If new devices are found, the screen will repaint with the current sort key applied for new and existing devices.

    5. Cleaned up a couple other minor bugs.

     

    As before, ALWAYS make a backup of the original version.  Reboot will reset to original.  Search for hack on how to reset this after a reboot.  Some very nice work at hackingthenetgearorbi wordpress com

     

    I have tested with current Orbi FW and current Chrome, IE, Edge, and Foxfire.  Your mileage may vary.

     

    No support expressed or implied but if you do see things please report them here and I will most likely have time to take a look.

     

    Scott

     

     

    • tomschmidt's avatar
      tomschmidt
      Virtuoso

      Sweet. I just tried this now, it looks great, now able to sort by connection type, MAC, etc. Awesome job!

    • SLK-Purdue's avatar
      SLK-Purdue
      Luminary

      Got questions about how I get the file into ORBI.  Good question.

       

      I use PuTTY so a copy-and-paste is pretty easy.  Most other Telnet package have some sort of copy-and-paste function

       

      Bacis idea is:

       

      1. Select and copy the entire file on the workstation

      2. Telnet to ORBI and login

      3. cd /www

      4. vi new.htm

      5. o command to get to "add mode"

      6. paste file (right mouse click in PuTTY)

      7 ESC

      9 clean up first and last line if necessary

      10 w

      11 q

       

      mv DEV_show_device.htm DEV_show_device.orig

      mv new.htm DEV_show_device.htm

       

      Scott

      • FURRYe38's avatar
        FURRYe38
        Guru - Experienced User

        Awesome, thank you for posting the details. 


        SLK-Purdue wrote:

        Got questions about how I get the file into ORBI.  Good question.

         

        I use PuTTY so a copy-and-paste is pretty easy.  Most other Telnet package have some sort of copy-and-paste function

         

        Bacis idea is:

         

        1. Select and copy the entire file on the workstation

        2. Telnet to ORBI and login

        3. cd /www

        4. vi new.htm

        5. o command to get to "add mode"

        6. paste file (right mouse click in PuTTY)

        7 ESC

        9 clean up first and last line if necessary

        10 w

        11 q

         

        mv DEV_show_device.htm DEV_show_device.orig

        mv new.htm DEV_show_device.htm

         

        Scott


         

  • Rather than running code to sort on the router, there's another way. Basically, find the entries you want to manipulate, copy/paste them into a text editor, manipulate them as desired (change device names, reserved IPs, reservation IDs, manufacturer details, display icons), convert the entries into commands, then paste back into the CLI, commit, and you're done. Save the text file for future use, either for backup/restore, or to add additional devices later. You're basically creating a batch file/shell script file, and then copy/pasting the contents instead of executing it. It may be possible to upload and execute the shell script file over telnet, but I don't know.

     

    Telnet in, have it show you the DHCP reservations. I believe it's something like:

    config show | grep reservation

    You're get a few extraneous lines, but then you'll see all your reservations, in the form:

    reservation[ID number]=[reserved IP] [MAC] [device name]

    sorted by ID. Copy/paste the whole list of reservations into a text editor, preferably one with a find/replace or multi-line editing function. You'll need to edit it by adding "config set" to the beginning of each line, and putting everything after the equals sign within double quotes, so it ends up like:

    config set reservation[ID number]="[reserved IP] [MAC] [device display name]"

    One per line, for all the reserved devices. They will display in reservation ID number order in the GUI. Organize your list however you like. I'm unsure if the text list needs to be ordered by reservation ID number in order to display properly in the GUI, but it's certainly easier for you if you do it thay way, to make sure they're in the order you want, and there aren't any skipped or duplicate reservation IDs. Rearrange manually, or, if you're clever, run it through a script and have it sort however you like. Once it's done, save for future use. Then, telnet back to the CLI prompt, and just copy/paste the entire file contents into the CLI, and hit enter. Commit the changes, and you're done.

     

    Relatedly, a similar process can be used for naming devices, including to use characters it rejects in the GUI, such as apostrophe for possessives (e.g., "Bob's laptop" instead of "Bob laptop" or "Bobs laptop"), and setting the device details (if you care to change from defaults) (all of which you'll see in the "attached devices" screen under the "device name" column).

     

    Device names display in the CLI in the form:

    orbi_dev_name[ID number]=[MAC] [device name]

    And device details (manufacturer & icon) in the form:

    orbi_dev_name_ntgr[ID number]=[MAC] [icon ID] [device manufacturer]

    config show, grep as appropriate, copy/paste into a text editor, change device ID numbers, names, manufacturers, IPs, icon IDs (I don't know which icon ID corresponds to which icon), convert configuration output lines into commands (add "config set" before each line, and put everything after the equals sign within double quotes), paste back into CLI, enter, commit, done. Optional (though recommended) backup of the finished text file for future use to restore after a factory reset, if the included backup/restore breaks after a firmware update,  or if you want to insert new devices into the middle of the list.

     

    And really, instead of saving a binary backup, which isn't human readable, and which may not work across firmware versions, any configuration setting you can figure out how to set from the CLI can be saved in a text file and copy/pasted into the CLI. You could do router name, DNS settings, password, network and subnet info, saved routes, etc. You can even just save the entire output from "config show" if you really want, though you'd have to edit it all into a series of valid commands, and some of the settings may not be ones you'd actually want to carry forward anyway. There's probably some way to actually save the commands as a shell script file, and to upload and run it over telnet from the CLI, but I don't know how to do that. There may also be a way to get the output in a form where you can paste it back in directly, without having to change each line into a command (adding "config set" and putting values within double quotes), but I don't know how to do that, either.

     

    NB: ID numbers for the DHCP reservations, device names, and device details don't necessarily match. They're each separate ordered lists, with consecutive IDs, so each list can be a different length, and the same device can have a different ID in each list it appears in, and devices can have entries in one list but not another. Entries for a given device are matched by MAC, not ID. I don't know what happens if you skip ID numbers to try to force them to match across lists, but since it doesn't matter, I wouldn't mess with it.

    • CrimpOn's avatar
      CrimpOn
      Guru - Experienced User

      This is an interesting procedure.  I have done that in the past, carefully assigning reservations in IP order, but my experience was that "Attached Devices" did not appear in "reservation order", but in some random sequence.  I think the whole point of this latest web page revision is that the user can choose on the spur of the moment, "Show me these in MAC order."  This is what Nighthawk routers have done forever.

      • randomousity's avatar
        randomousity
        Luminary

        Yeah, but it's a PITA to do manually from the GUI. You have to delete everything, and then re-add them all in the proper order. If you skip one, or get a new device later, you have to repeat the process. It's much simpler to just extract the data, order it how you want, and then upload it again, and now it's in your preferred order. This makes it super easy to fix on the backend, and to reapply if it ever gets assorted. Plus, you're not running any code on the router, so there's little risk of cauing any problems this way. Plus, it's useful for more than just sorting by IP address. And it works across firmware updates.