### Example output JSON array Source: https://github.com/hknutzen/netspoc/blob/master/go/pkg/pass1/print-path.1.md Example of the JSON array output produced by print-path, listing network element names along the path. ```json ["network:n1", "network:n2", "router:r1"] ``` -------------------------------- ### Netspoc configuration input Source: https://github.com/hknutzen/netspoc/blob/master/go/pkg/exportsyntax/export-netspoc-syntax.1.md Example Netspoc configuration with a network and router definition, used as input to export-netspoc-syntax. ```netspoc #START network:n1 = { ip = 10.1.1.0/24; host:h1 = { ip = 10.1.1.11; owner = o1; } host:h2 = { range = 10.1.1.12-10.1.1.23; } } router:r1 = { managed; model = ASA; interface:n1 = {ip = 10.1.1.1; virtual = {ip = 10.1.1.9;} hardware = n1;} } #END ``` -------------------------------- ### JSON output from export-netspoc-syntax Source: https://github.com/hknutzen/netspoc/blob/master/go/pkg/exportsyntax/export-netspoc-syntax.1.md JSON output generated by running export-netspoc-syntax netspoc/ on the example configuration. ```json {"network":[ {"name":"network:n1", "ip": [ "10.1.1.0/24" ], "hosts": { "host:h1": { "ip": [ "10.1.1.11" ], "owner": [ "o1" ] }, "host:h2": { "range": [ "10.1.1.12 - 10.1.1.23" ] } } }], "router":[ {"name":"router:r1", "managed": null, "model":["ASA"], "interfaces":{ "interface:n1":{ "ip": [ "10.1.1.1" ], "hardware": [ "n1" ], "virtual": { "ip": [ "10.1.1.9" ] } } } }] } ``` -------------------------------- ### transpose-service command examples Source: https://github.com/hknutzen/netspoc/blob/master/go/pkg/transposeservice/transpose-service.1.md Command-line invocations of transpose-service. The first transposes a single service, the second multiple services, and the third reads service names from a file using the -f option. ```shell transpose-service netspoc/ service:s1 ``` ```shell transpose-service netspoc/ service:s1 service:s2 ``` ```shell echo 'service:s1 service:s2' > services.txt; transpose-service -f services.txt netspoc/ ``` -------------------------------- ### check-acl example with Netspoc config, packet file, command, and output Source: https://github.com/hknutzen/netspoc/blob/master/go/pkg/pass2/check-acl.1.md Example showing a Netspoc configuration, a packet description file, the check-acl command invocation, and the resulting output. The configuration defines two networks, a managed ASA router, and a service permitting TCP ports 80-90 and ICMP type 3 code 3 from n1 to n2. The packet file contains four descriptions; the command reads them with -f and checks them against ACL n1_in of router r1. Output prefixes each packet with permit or deny. ```netspoc ## START network:n1 = { ip = 10.1.1.0/24; } network:n2 = { ip = 10.1.2.0/24; } router:r1 = { managed; model = ASA; interface:n1 = { ip = 10.1.1.1; hardware = n1; } interface:n2 = { ip = 10.1.2.1; hardware = n2; } } service:s1 = { user = network:n1; permit src = user; dst = network:n2; prt = tcp 80-90, icmp 3/3; } ## END ``` ```text 10.1.1.11 10.1.2.12 tcp 85 10.1.1.11 10.0.0.0 udp 123 10.1.1.11 10.1.2.12 icmp 3/3 10.1.1.11 10.1.2.12 icmp 3/13 ``` ```bash check-acl -f file code/r1 n1_in ``` ```text permit 10.1.1.11 10.1.2.12 tcp 85 deny 10.1.1.11 10.0.0.0 udp 123 permit 10.1.1.11 10.1.2.12 icmp 3/3 deny 10.1.1.11 10.1.2.12 icmp 3/13 ``` -------------------------------- ### Remove services from a file Source: https://github.com/hknutzen/netspoc/blob/master/go/pkg/removeservice/remove-service.1.md Reads service names from services.txt and removes them. The example shows creating the file and running remove-service with the -f option. ```bash echo 'service:s1 service:s2' > services.txt; remove-service -f services.txt netspoc/ ``` -------------------------------- ### remove-from-netspoc command examples Source: https://github.com/hknutzen/netspoc/blob/master/go/pkg/removefrom/remove-from-netspoc.1.md Shows three command-line invocations of remove-from-netspoc. The first removes network:x from the netspoc/ directory. The second removes host:a, host:b, and interface:r.x. The third reads the same objects from a file using the -f option. ```shell remove-from-netspoc netspoc/ network:x ``` ```shell remove-from-netspoc netspoc/ host:a host:b interface:r.x ``` ```shell echo 'host:a host:b interface:r.x > file; remove-from-netspoc -f file netspoc/ ``` -------------------------------- ### Find path between two hosts Source: https://github.com/hknutzen/netspoc/blob/master/go/pkg/pass1/print-path.1.md Run print-path with a Netspoc configuration directory and two host names as source and destination. ```bash print-path netspoc/ host:h1 host:h2 ``` -------------------------------- ### Find path between two networks Source: https://github.com/hknutzen/netspoc/blob/master/go/pkg/pass1/print-path.1.md Run print-path with a Netspoc configuration directory and two network names as source and destination. ```bash print-path netspoc/ network:n1 network:n2 ``` -------------------------------- ### Find path quietly Source: https://github.com/hknutzen/netspoc/blob/master/go/pkg/pass1/print-path.1.md Run print-path with the -q option to suppress progress messages. ```bash print-path -q netspoc/ network:n1 network:n2 ``` -------------------------------- ### expand-group command with before and after configuration Source: https://github.com/hknutzen/netspoc/blob/master/go/pkg/expand/expand-group.1.md Shows the command-line invocation and the before/after Netspoc configuration when expanding group references. The command substitutes group:g1 and group:g2 in the configuration, leaving group:g3 with the expanded elements. ```bash expand-group netspoc/ group:g1 group:g2 ``` ```netspoc ## START group:g1 = host:a; group:g2 = group:g1, host:b; group:g3 = group:g2, host:c; ## END ``` ```netspoc ## START group:g3 = host:a, host:b, host:c, ; ## END ``` -------------------------------- ### Export topology from Netspoc configuration directory Source: https://github.com/hknutzen/netspoc/blob/master/go/pkg/pass1/export-netvis.1.md Runs export-netvis on the netspoc/ directory, outputting the network topology as JSON to standard output. ```shell export-netvis netspoc/ ``` -------------------------------- ### Read pairs from file with -f option Source: https://github.com/hknutzen/netspoc/blob/master/go/pkg/addto/add-to-netspoc.1.md Writes the pairs to a file and then runs add-to-netspoc with the -f option to read pairs from that file. ```shell echo 'group:g host:y network:x host:y' > file; add-to-netspoc -f file netspoc/ ``` -------------------------------- ### Service definition before and after transposition Source: https://github.com/hknutzen/netspoc/blob/master/go/pkg/transposeservice/transpose-service.1.md Shows the before and after of a service definition when transposed. The user keyword moves from src to dst, and the permit rule is updated accordingly. ```netspoc service:s1 = { user = network:n1; permit src = user; dst = network:n2; prt = tcp 80; } ``` ```netspoc service:s1 = { user = network:n2; permit src = network:n1; dst = user; prt = tcp 80; } ``` -------------------------------- ### Show IP address and name of IPv6 networks inside area:x Source: https://github.com/hknutzen/netspoc/blob/master/go/pkg/pass1/print-group.1.md Without --name or --ip, print-group shows both IP address and name. The expression 'network:[any:[ip6=::/0 & area:x]]' selects IPv6 networks within the area. ```shell print-group netspoc/ 'network:[any:[ip6=::/0 & area:x]]' ``` -------------------------------- ### Show IP addresses of all hosts inside area:x Source: https://github.com/hknutzen/netspoc/blob/master/go/pkg/pass1/print-group.1.md Use the --ip option to display only IP addresses. The expression 'host:[area:x]' selects all hosts within the area. ```shell print-group --ip netspoc/ 'host:[area:x]' ``` -------------------------------- ### Export topology quietly without progress messages Source: https://github.com/hknutzen/netspoc/blob/master/go/pkg/pass1/export-netvis.1.md Uses the -q option to suppress progress messages while exporting the topology from the netspoc/ directory. ```shell export-netvis -q netspoc/ ``` -------------------------------- ### Add host:y at every occurrence of group:g and network:x Source: https://github.com/hknutzen/netspoc/blob/master/go/pkg/addto/add-to-netspoc.1.md Runs add-to-netspoc with two pairs: group:g host:y and network:x host:y, augmenting both group:g and network:x with host:y. ```shell add-to-netspoc netspoc/ group:g host:y network:x host:y ``` -------------------------------- ### Remove service quietly Source: https://github.com/hknutzen/netspoc/blob/master/go/pkg/removeservice/remove-service.1.md Removes service:s1 without showing changed files using the -q option. ```bash remove-service -q netspoc/ service:s1 ``` -------------------------------- ### Show names of elements of group:g Source: https://github.com/hknutzen/netspoc/blob/master/go/pkg/pass1/print-group.1.md Use the --name option to display only the names of elements in a group. The Netspoc configuration is read from the directory netspoc/. ```shell print-group --name netspoc/ group:g ``` -------------------------------- ### Remove multiple services Source: https://github.com/hknutzen/netspoc/blob/master/go/pkg/removeservice/remove-service.1.md Removes service:s1, service:s2, and service:s3 in a single run. ```bash remove-service netspoc/ service:s1 service:s2 service:s3 ``` -------------------------------- ### Add network:y at every occurrence of network:x Source: https://github.com/hknutzen/netspoc/blob/master/go/pkg/addto/add-to-netspoc.1.md Invokes add-to-netspoc on the netspoc/ directory, replacing every occurrence of network:x with network:x, network:y in groups and rules. ```shell add-to-netspoc netspoc/ network:x network:y ``` -------------------------------- ### Show names and owners of elements of group:a without group:b Source: https://github.com/hknutzen/netspoc/blob/master/go/pkg/pass1/print-group.1.md Use --name and --owner together to display names and owners. The expression 'group:a &! group:b' computes the set difference, excluding elements of group:b. ```shell print-group --name --owner netspoc/ 'group:a &! group:b' ``` -------------------------------- ### Remove a single service Source: https://github.com/hknutzen/netspoc/blob/master/go/pkg/removeservice/remove-service.1.md Removes service:s1 from the Netspoc configuration in the netspoc/ directory. ```bash remove-service netspoc/ service:s1 ``` -------------------------------- ### Rename network:x to network:y in netspoc/ directory Source: https://github.com/hknutzen/netspoc/blob/master/go/pkg/rename/rename-netspoc.1.md Renames all occurrences of network:x to network:y in the Netspoc configuration under the netspoc/ directory. This also renames interface names referencing network:x, e.g., interface:r.x becomes interface:r.y. ```shell rename-netspoc netspoc/ network:x network:y ```