ftp协议走另一条链路及断线转移


#!/bin/sh
if ping 192.168.1.251 -c 10 > /dev/null
then
ip route del table 1 via 192.168.1.251
ip route add table 1 via 192.168.1.251
ip rule del fwmark 1 table 1
ip rule add fwmark 1 table 1
if ! iptables -L -t mangle | grep !192.168.1.0/24 | grep ftp | grep MARK > /dev/null
then
iptables -A PREROUTING -t mangle -p tcp ! -d 192.168.1.0/24 --dport 21 -j MARK --set-mark 1
fi

if ping 114.114.114.114 -c 4 > /dev/null
then
iptables -D PREROUTING -t mangle -p all ! -d 192.168.1.0/24 -j MARK –set-mark 1
else
iptables -D PREROUTING -t mangle -p all ! -d 192.168.1.0/24 -j MARK –set-mark 1
iptables -A PREROUTING -t mangle -p all ! -d 192.168.1.0/24 -j MARK –set-mark 1
fi

fi


发表评论 0

Your email address will not be published. Required fields are marked *