brew install iproute2mac

#! /bin/sh
set -x
GATEWAY_IP=$(ip route get 0.0.0.0 |  awk '{ print $3}')
GATEWAY_IP=$(route -n get default | grep 'gateway' | awk '{print $2}')
echo $GATEWAY_IP
rm -f china_ip_list.txt
wget -c https://raw.githubusercontent.com/17mon/china_ip_list/master/china_ip_list.txt
for i in $(cat ./china_ip_list.txt)
do
    ip route add "$i" via "$GATEWAY_IP"  dev en0
done

重置

 sudo route -n flush; sudo route -n flush; sudo route -n flush;
 ifconfig en0 down&&ifconfig en0 up

参考

china_ip_list flush-routing-table