nix: add subnet
This commit is contained in:
parent
b1fddd0ba7
commit
bf297cd5d7
|
@ -0,0 +1,20 @@
|
||||||
|
{ pkgs ? import <nixpkgs> {}
|
||||||
|
}:
|
||||||
|
|
||||||
|
{
|
||||||
|
# List of all IP addresses in a subnet
|
||||||
|
range = subnet:
|
||||||
|
import (
|
||||||
|
pkgs.runCommandLocal "subnet-${subnet}.nix" {
|
||||||
|
nativeBuildInputs = [ pkgs.nmap ];
|
||||||
|
} ''
|
||||||
|
(
|
||||||
|
echo "["
|
||||||
|
for i in $(nmap -sL ${pkgs.lib.optionalString (builtins.match ".*:.*" subnet != null) "-6"} ${subnet} -n -oG - | grep Status: | cut -d " " -f 2); do
|
||||||
|
echo \"$i\"
|
||||||
|
done
|
||||||
|
echo "]"
|
||||||
|
) > $out
|
||||||
|
''
|
||||||
|
);
|
||||||
|
}
|
Loading…
Reference in New Issue