我有一个DD-WRT路由器,上面激活了OpenVPN服务。我创建了以下启动脚本,我希望该脚本能将Netflix从VPN隧道中排除。但是,我还没有成功。当我在 whatsmyip.org 查找ip时,我仍然得到VPN服务器的ip,而不是我自己的ip。你能看出哪里出了问题吗?
SCRIPT_DIR="/tmp/etc/config"
SCRIPT="$SCRIPT_DIR/add-routes.wanup"
mkdir -p $SCRIPT_DIR
cat << "EOF" > $SCRIPT
#!/bin/sh
# dd-wrt selective domain routing
WAN_GWAY="0.0.0.0"
while [ $WAN_GWAY == "0.0.0.0" ]; do
sleep 3
WAN_GWAY=`nvram get wan_gateway`
done
# list domains for selective routing
for domain in
"netflix.com"
"ichnaea.netflix.com"
"movies.netflix.com"
"www.netflix.com"
"nflxext.com"
"cdn1.nflxext.com"
"nflximg.com"
"nflxvideo.net"
"ipv4_1.cxl0.c145.sjc002.ix.nflxvideo.net"
"amazonaws.com"
"whatsmyip.org"
do
# extract ip addresses
for ip in $(nslookup $domain | awk '/^Name:/,0{if (/^Addr/)print $3}'); do
# add class c route for each ip address to wan gateway
ip route add `echo $ip | cut -d . -f 1,2`.0.0/16 via $WAN_GW
done
done
# flush cache
ip route flush cache
EOF
chmod +x $SCRIPT
sleep 60
$SCRIPT
尝试使用它。而不是使用该列表直接指定路由。
#!/bin/sh
# specify your own route(s), then place this script in the startup script
(
set -x # comment/uncomment to disable/enable debug mode
WANUP_DIR="/tmp/etc/config"
WANUP_SCRIPT="$WANUP_DIR/add-routes.wanup"
mkdir -p $WANUP_DIR
cat << "EOF" > $WANUP_SCRIPT
#!/bin/sh
ip route add 199.199.199.199 via $(nvram get wan_gateway)
ip route add 177.177.177.0/24 via $(nvram get wan_gateway) <-- Change ips to what you want
EOF
chmod +x $WANUP_SCRIPT
) 2>&1 | logger -t $(basename $0)[$$]
了解更多信息以及我在哪里找到这个 https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=313324&sid=c64a45234a73595b6e912a7e35f484ea