6

I have a Mac Pro and the problem is that it is not connecting to systems in other VLANs. This can be temporarily archived by

sudo route -n add -net <IP>/mask  <Gateway>

However it vanishes in the next laptop restart. How can I add the route permanently?

slhck
  • 223,558
  • 70
  • 607
  • 592
Sri Ram
  • 61
  • 1
  • 1
  • 2
  • Possible duplicate of https://apple.stackexchange.com/questions/307221/add-a-permanent-static-route-in-high-sierra – Jesse P. Sep 04 '18 at 03:01

2 Answers2

1

I myself didn't manage to make it work with the solution that pabo provided. I ended up running it in the crontab:

env EDITOR=nano crontab -e

add the script line:

@reboot sh /path/to/your/script.sh

make sure that if you need sudo rights, you would need to disable password for sudo use for your script. More info here:

https://apple.stackexchange.com/questions/264663/shutdown-no-tty-present-and-no-askpass-program-specified

Additionally, if you are using some build in commands in mac, like for example route you need to specify full path of the binary file. Here is example of script.sh file:

sudo /sbin/route add 192.168.64.0/16 192.168.100.1

Maksim Luzik
  • 333
  • 5
  • 15
0

Found an article which suggests adding something like this

ifconfig en2 inet 11.22.33.5 netmask 255.255.255.252
route -n add 11.22.33.64/26 111.222.333.6

to /etc/rc.common. Apparently the preceding ifconfig line is necessary, though I don't know why.

pabo
  • 151
  • 6
  • Is Command-K still a thing in macOS, the way it was in OS X? If so, you can use that, since it's a front-end *of sorts* for what you do in Terminal. –  Apr 07 '20 at 13:41