WatchYourLAN icon indicating copy to clipboard operation
WatchYourLAN copied to clipboard

Feature Request: Scan VLAN subnets

Open thehijacker opened this issue 2 years ago • 6 comments
trafficstars

Looking for alternative to PiAlert. This looks like much simpler version of it with simillar features. But one is missing that I need so I can capture all my subnets. Arp-scan can also scan VLAN subnets with syntax:

arp-scan --ignoredups --retry=6 10.0.107.0/24 -vlan=107 --interface=eth0

Can this vlan parameter be added as well as option to scan multiple subnets?

Thank you.

thehijacker avatar Feb 09 '23 19:02 thehijacker

I made some changes to the internal/scan/arpscan.go:

-func scanIface(iface string) string {
+func scanIface(iface []string) string {
-        cmd, err := exec.Command("arp-scan", "-glNx", "-I", iface).Output()
+       cmd, err := exec.Command("arp-scan", iface...).Output()
        if err != nil {
                return string("")
        }
        return string(cmd)
}
// Scan all interfaces
func arpScan(allIfaces string) []models.Host {
        var text string
        var foundHosts = []models.Host{}

        perString := strings.Split(allIfaces, ",")

        for _, iface := range perString {
                log.Println("INFO: scanning interface", iface)
-                 text = scanIface(iface)
+                text = scanIface(strings.Split("-gNx " + strings.TrimSpace(iface), " "))
                log.Println("INFO: found IPs:", text)
                foundHosts = append(foundHosts, parseOutput(text)...)
        }

        return foundHosts
}

Basically the parameters can be anything and it will pass them as array of parameters. For example:

IFACE=-l -I vmbr0, 10.0.208.0/24 -Q 208 -I vmbr0, 10.0.107.0/24 -Q 107 -I vmbr0

or long syntax

IFACE=-l --interface=vmbr0, 10.0.208.0/24 --vlan=208 --interface=vmbr0, 10.0.107.0/24 --vlan=107 --interface=vmbr0

Using this changes and IFACE parameters, all three of my home networks are scanned. Could this be included in next version? Or possible improved. First time I looked at a go code :)

Next I need to figure out how to put this new binary inside my docker container.

thehijacker avatar Feb 13 '23 20:02 thehijacker

+1 for the feature. Segmented my network into VLANs recently and realized that WatchYourLAN can only see within its subnet...

GentleHoneyLover avatar Mar 10 '23 18:03 GentleHoneyLover

Just set up an instance myself and noticed there wasnt an option for specifying what subnets to scan. I have a few subnets, based on wifi, homelab, hardwire, guest, iot devices, etc. I dont want to have to run an instance for each.

+1 for this

lima3w avatar Mar 20 '23 03:03 lima3w

Multiple subnets/vlans would be wonderful!

hobybrenner avatar Apr 10 '23 13:04 hobybrenner

Agreed. I just tried this (and the various forks of Pi Alert) trying to find one that would work for my multi-VLAN setup. This feature would be amazing.

dustingrady avatar Apr 22 '24 21:04 dustingrady

This feature would be awsome! sadly im not a dev and cant help :(

I will try to get my head into how to fix that like @thehijacker advertised, maybe you could provide a little guide for non devs?

thx in advance

Jffrey avatar May 12 '24 22:05 Jffrey

Done in v2.0.1 - see docs/VLAN_ARP_SCAN.md for a howto.

aceberg avatar Sep 02 '24 14:09 aceberg