venerdì 9 febbraio 2024

Adding a Static Route to macOS

Issue


A quick post just to remind myself how to add a static route to macOS when I need it.

Solution


sudo route -n add -net X.X.X.X/Z Y.Y.Y.Y
Symbol legend:
X.X.X.X is the network that we want reach out
Z is the subnet mask in CIDR notation
   255.0.0.0 = 8
   255.255.0.0 = 16
   255.255.255.0 = 24
Y.Y.Y.Y it is the IP address where we find the subnet we want to reach


Examples
If we want to reach the subnet 172.16.11.0/24 and we know that is behind the IP 192.168.1.45 (that is not your default gateway); we have to add the route as follows:

sudo route -n add -net 172.16.11.0/24 192.168.1.45

That's it.

Nessun commento:

Posta un commento