chore(snippets): dump notes about networking commands

This commit is contained in:
Michele Cereda
2025-07-19 23:36:04 +02:00
parent 3d0ef80ac8
commit 32cc239a81
2 changed files with 72 additions and 0 deletions

31
snippets/arp.fish Normal file
View File

@@ -0,0 +1,31 @@
#!/usr/bin/fish
###
# Linux
# ------------------
###
# Display the current entries
arp
arp --numeric
# Answer requests for 10.0.0.2 on eth0 with the MAC address for eth1
arp --device 'eth0' --use-device -s '10.0.0.2' 'eth1' 'pub'
arp -i eth0 -Ds 10.0.0.2 eth1 pub
# Delete the ARP table entry for 10.0.0.1 on interface eth1
# Will match published proxy ARP entries *and* permanent entries
arp -i 'eth1' -d '10.0.0.1'
###
# Mac OS X
# ------------------
###
# Display the current entries
arp -a
# Delete entries
arp -d -a
arp -d -i 'en0' 'nas.lan'

41
snippets/route.fish Normal file
View File

@@ -0,0 +1,41 @@
#!/usr/bin/fish
###
# Linux
# ------------------
###
# Display the contents of the current routing table
route
route -n
# Add routes
route add -net '192.56.76.0' netmask '255.255.255.0' metric '1024' dev 'eth0'
route add -net '192.57.66.0' netmask '255.255.255.0' gw 'astro'
route add -net '224.0.0.0' netmask '240.0.0.0' dev 'eth1'
route -6 add '2001:0002::/48' metric '1' dev 'eth2'
# Add default routes
# Default routes will be used when no other route matches
# The gateway *must* be be on a directly reachable route
route add 'default' gw 'dijkstra'
route add 'default' gw '192.168.100.1'
# Delete routes
# Since the Linux routing kernel uses classless addressing, one pretty much always has to specify the netmask as seen in
# 'route -n'
route del -net '192.56.76.0' netmask '255.255.255.0'
# Delete the current default route
# It is either labeled 'default' or has '0.0.0.0' in the destination field of the current routing table
route del 'default'
###
# Mac OS X
# ------------------
###
# Flush the routing tables of all or specified gateway entries
route flush
route -n flush -inet6