Computers and servers

Hosts send real traffic through the lab: ARP, DHCP, ping, traceroute, TCP connections to servers and SSH logins to devices. Each one speaks its own system's commands.

PC (VPCS)

PC (VPCS)
ip 10.0.10.11/24 10.0.10.1A static address and gateway (ip 10.0.10.11 255.255.255.0 10.0.10.1 works too).
ip dhcpAsks for an address (DORA), as dhcp does.
show ipThe PC's address, mask, gateway and MAC.
ping 10.0.10.1Five pings (-c 3 for three).
trace 8.8.8.8The hops to an address.
arpThe ARP table.
set pcname PC1Renames the PC.
saveSaves its settings.

Windows

An elevated Command Prompt (C:\Windows\system32>).

Windows laptop
ipconfig /allEvery setting of the adapter: address, gateway, DNS, DHCP lease and MAC.
netsh interface ipv4 set address name="Ethernet" static 10.0.10.12 255.255.255.0 10.0.10.1A static address and gateway.
netsh interface ipv4 set address name="Ethernet" source=dhcpBack to DHCP.
ipconfig /renewAsks the DHCP server again (/release gives the lease back).
ping 10.0.10.1Four pings.
tracert 8.8.8.8The hops.
arp -aThe ARP table.
route printThe routing table.
curl http://10.0.20.10Opens a web page through the network's ACLs and NAT.
ssh admin@10.0.99.1Logs in to a switch or router and gets its command line.

macOS

zsh. Changing settings needs sudo, as on a real Mac.

macOS laptop
ifconfig en0The interface's addresses and MAC.
sudo networksetup -setmanual Ethernet 10.0.10.13 255.255.255.0 10.0.10.1A static address and router.
networksetup -getinfo EthernetThe service's settings.
sudo networksetup -setdhcp EthernetBack to DHCP (sudo ipconfig set en0 DHCP works too).
ipconfig getifaddr en0Just the address.
netstat -rnThe routing table.
route -n get defaultThe default gateway and interface.
ping -c 3 10.0.10.1Three pings.
traceroute 8.8.8.8The hops.
arp -aThe ARP table.
nc -zv 10.0.20.10 443Tests a TCP port.

Linux

bash on Ubuntu. Changing settings needs sudo.

Linux laptop
ip addrThe interfaces and their addresses (ip -4 addr, ip -6 addr).
sudo ip addr add 10.0.10.14/24 dev eth0Adds an address.
sudo ip route add default via 10.0.10.1Adds the default route.
ip routeThe routing table.
ip neighThe ARP (and IPv6 neighbour) table.
sudo ip addr flush dev eth0Removes the addresses.
sudo hping3 -1 -a 10.1.1.50 -c 5 10.1.1.10Sends ICMP probes (-S -p 80: TCP SYN to a port) with a forged source address (-a). Replies go to the forged address, so none come back. Needs sudo.
sudo dhclient eth0Asks for an address with DHCP.
hostname -IJust the addresses.
ping -c 3 10.0.10.1Three pings (ping6 for IPv6).
traceroute 8.8.8.8The hops.
curl -k https://10.0.20.10A web page over HTTPS.
nc -zv 10.0.20.10 22Tests a TCP port.
curl http://[2001:db8:100::10]/A web page over IPv6 (the address goes in brackets in a URL).
nc -zv 2001:db8:100::10 22Tests a TCP port over IPv6 (ssh takes IPv6 addresses too).

The NMS is a Linux host that also has snmpget, snmpwalk, tail -f /var/log/syslog, cat /var/log/snmptrapd.log, tcpdump (live, or -w to a file and -r to read it back) and nfdump for the flows it collects.

Names (DNS)

Each computer asks its DNS server (from the lab or from DHCP). ping, tracert/traceroute, curl, ssh and nc take a name and print it as the system does. Ubuntu asks its local stub resolver, 127.0.0.53, which forwards to the server resolvectl shows.

Linux laptop
nslookup www.example.comA and AAAA records, through the stub resolver (Non-authoritative answer). A CNAME prints as canonical name =.
nslookup -type=mx example.com 10.1.99.53One record type (a, aaaa, cname, mx, ns, ptr, soa), asking a server directly.
nslookup 10.1.99.80The reverse lookup: the PTR record.
dig www.example.comThe full answer: status (NOERROR, NXDOMAIN, SERVFAIL), flags, the answer and authority sections.
dig +short @10.1.99.53 www.example.com AAAAJust the values, from a chosen server. dig -x ADDRESS asks for the PTR.
resolvectl statusThe DNS server and search domain the stub resolver uses.
sudo resolvectl dns eth0 10.1.99.53Sets the DNS server (sudo resolvectl domain eth0 example.com the search domain).
cat /etc/resolv.confPoints at the stub resolver, 127.0.0.53.
Windows laptop
nslookup www.example.comFirst the server's own name (its PTR: UnKnown without one), then the addresses and Aliases for a CNAME.
nslookup -type=mx example.comOne record type. With no such record it prints the zone's SOA.
netsh interface ipv4 set dnsservers name="Ethernet" static 10.1.99.53 primarySets the DNS server (ipconfig /all shows it).
ipconfig /flushdnsEmpties the resolver cache.
macOS laptop
nslookup www.example.comThe same as on Linux, asking the DNS server directly.
dig +short www.example.comJust the values.
sudo networksetup -setdnsservers Ethernet 10.1.99.53Sets the DNS server (-getdnsservers Ethernet shows it, empty removes it).

A DNS server is a Linux host running BIND, authoritative for its zones: A, AAAA, CNAME, MX, NS, PTR and SOA records. It does not recurse to the internet. Change its records with nsupdate, one line at a time at its > prompt; send applies them.

DNS server (Linux)
cat /etc/bind/db.example.comThe zone file, as BIND reads it.
sudo nsupdate -lStarts a dynamic update: update add web.example.com 3600 A 10.1.99.80, update delete web.example.com A 10.1.99.81, show, send, quit. Names are absolute.

Files over SSH (SCP)

A server keeps files in its home folder and logs in its own accounts. A switch or router takes pushed files in flash when it runs ip scp server enable with AAA (privilege 15).

Linux laptop
scp motd.txt admin@10.1.99.1:flash:/motd.txtPushes a file (to a server: admin@10.1.99.20:). The host key is asked about once, then the password.
scp admin@10.1.99.20:R1-confg .Fetches a file.
ls -lThe files with their sizes.
md5sum R1-confgA file's MD5, to compare with verify /md5 on the device.

Ansible

A Linux control node runs Ansible against switches and routers over SSH (network_cli): nothing runs on the devices. The inventory is an INI file with group variables (ansible_connection, ansible_network_os=cisco.ios.ios, ansible_user, ansible_password, and ansible_become with the enable method); playbooks are YAML with the cisco.ios.ios_command, cisco.ios.ios_config (lines, parents, save_when) and ansible.builtin.debug modules, and register. Edit files with echo … >> FILE and sed -i 's/OLD/NEW/' FILE.

Linux laptop
ansible-inventory -i inventory.ini --graphThe groups and their hosts (--list with the variables).
ansible routers -i inventory.ini -m cisco.ios.ios_command -a "commands='show version'"An ad hoc command on a group: SUCCESS with the output, or FAILED with Ansible's message.
ansible-playbook -i inventory.ini save.ymlRuns a playbook: each task per host (ok, changed, fatal), then the PLAY RECAP.
ansible-playbook -i inventory.ini --syntax-check save.ymlOnly checks the playbook.
sed -i 's/10.1.99.12/10.1.99.2/' inventory.iniReplaces text in a file (/PATTERN/d deletes lines, $a TEXT appends one).

Servers, the AAA server and the NMS

The attacker laptop

A VPCS host with three extra tools, for the Layer 2 security labs. Each one does to the network what the real attack does, so port security, DHCP snooping and DAI can stop it.

Attacker laptop
macof -n 200Floods the switch with random source MAC addresses (MAC table overflow).
rogue-dhcp startAnswers DHCP requests with itself as the gateway (rogue-dhcp stop ends it).
rogue-dhcp stopStops the rogue server.
arpspoof 10.0.10.1Claims the gateway's address with its own MAC (ARP poisoning).

The IPv6 and storm labs use a Kali Linux laptop instead: a Linux host with the attacker role. It has every Linux command, plus THC-IPv6's fake_router6. Tools that run until stopped go in the background with &, and kill %N stops them.

Attacker laptop (Kali Linux)
sudo fake_router6 eth0 2001:db8:bad::/64 &Advertises the laptop as an IPv6 router for that prefix, with high preference: clients in the VLAN build an address in it and send their IPv6 traffic to the laptop, unless RA guard drops the advertisements.
sudo hping3 --flood --udp -p 9 10.0.10.255 &Floods UDP to the subnet's broadcast address at line rate (-1 ICMP, a multicast or unicast address for those storms). Storm control on the switch port sees it.
jobsThe background jobs.
kill %1Stops a background job by its number.