I'm looking for a way to use specific CIDR blocks to match hosts in the SSH client configuration (usually ~/.ssh/config). For example, I have an entry to forward all traffic through a bastion host if the IP falls into a certain range, let's say 10.1.0.0/16:
host 10.1.*
proxycommand ssh -q bastion -W %h:%p
This works very well, but how about when I add some ranges that don't fit the dot notation exactly?
# doesn't work, unfortunately
host 10.2.0.0/18
proxycommand ssh -q bastion-foo -W %h:%p
host 10.2.64.0/18
proxycommand ssh -q bastion-bar -W %h:%p
Is there something in the manual that I've missed, or a clever scripting trick that would enable matching these host IP ranges?
hostentries. It also needed each one quoted separately (ssh/Mac). Shortest I could find:host "10.2.?.*", "10.2.??.*", "!10.2.64*", "!10.2.65*", "!10.2.66*", "!10.2.67*", "!10.2.68*", "!10.2.69*", "!10.2.7*", "!10.2.8*", "!10.2.9*"and
– fazy May 12 '17 at 17:16host "10.2.??.*", "10.2.10?.*", "10.2.11?.*", "10.2.12?.*", "!10.2.1?.*", "!10.2.2?.*", "!10.2.3?.*", "!10.2.4?.*", "!10.2.5?.*", "!10.2.60.*", "!10.2.61.*", "!10.2.62.*", "!10.2.63.*", "!10.2.128.*", "!10.2.129.*"