brona / iproute2mac

CLI wrapper for basic network utilites on Mac OS X inspired with iproute2 on Linux systems - ip command.
MIT License
898 stars 73 forks source link

Support `ip route add blackhole CIDR` #36

Closed mhio closed 2 years ago

mhio commented 2 years ago

ip route add blackhole [CIDR] equates to route add [CIDR] 127.0.0.1 -blackhole

I couldn't figure out a way to run it without the destination gateway, so gave it localhost.

# route add -net 10.1.1.0/31 127.0.0.1 -blackhole
add net 10.1.1.0: gateway 127.0.0.1

# netstat -anr
Routing tables

Internet:
Destination        Gateway            Flags        Netif Expire
10.1.1.0/31         127.0.0.1          UGScB          lo0       
brona commented 2 years ago

I integrated your PR, fixed few issues incl. IPv6, see 4bd9c42dbf58bb5bc4edc46088cdc2901a086f86.

@mhio, can you test from head to check it works for you? https://raw.githubusercontent.com/brona/iproute2mac/master/src/ip.py