route is a traditional utility now replaced by ‘ip route’ on Linux which belongs to iproute2suite. /24 syntax is not implemented in all ifconfig versions, you may have to use netmask 255.255.255.0 ormask 255.255.255.0 syntax.

IP command cheat sheet 


Printing the route

netstat -nr
route add -host 10.12.76.5 netmask 255.255.255.0 dev eth0
route del -host 10.12.76.5 netmask 255.255.255.0 dev eth0
route add default gw 192.168.1.1 wlan2
ip route add default via 192.0.2.1

  • A netmask of 255.255.255.255 represents all bits are fixed and therefore will only route the give IP.
  • A netmask of 0.0.0.0 means all bits are variable, in other words it is default route matching every IP address.
  • In other words, there cannot be a bit set to 1 in the destination if the corresponding bit in the subnet mask is a 0.

Any packets come in from 10.x.x.x they will be masked out prior to hitting the default route.

route add -net 10.0.0.0 netmask 255.0.0.0 reject
You can also specify in the route command the interface it should use using the IF paramter:
route add 10.12.0.0 mask 255.255.0.0 10.12.0.1 IF 2
Examples -

Add or delete route on OSX

sudo route -n add -net 10.1.0.0/16  172.19.10.1
sudo route delete -net 10.1

MS-CWOPA Exchange

route add  206.0.0.0 mask 255.0.0.0 172.19.10.1 METRIC 15

Update metric for JNET Wifi

route change  0.0.0.0 mask 0.0.0.0 192.168.1.1 METRIC 18

Acess Cwopa LAN

route add  10.0.0.0 mask 255.0.0.0 172.19.10.1 METRIC 15

http://www.thegeekstuff.com/2012/04/route-examples/