Re: Specific route to facebook

#53738

RCWielewski
Member

Hello.

My data carrier (CLARO) does not charge for facebook, whatsapp and twiter data, so the logic is that access to these sites is done by the 4G connection.
I tried to create filters on the Net Balancer without success.
I decided to create the routes manually and as the access IPs change frequently the solution was to search for the IPs to create the correct routes.
I created a “script” to schedule it to run every 12 hours (time depends on each need).
Here’s the example for facebook, whatsapp and twitter, I hope they’re useful as an example (obviously they can be improved, but I’m a beginner in “linux script”:

# Bash script: Routes-Cron

cd /tmp

## Facebook
whois -h whois.radb.net — ‘-i origin AS32934’ | awk ‘/^route:/ {print $2;}’ | sort | uniq > facebook.routes
lines=`awk ‘END {print NR}’ facebook.routes`
i=1
while (( $i <= $lines ))
do
par=”sed -n “$i”p facebook.routes”
$par > facebook.txt
ra=`cat facebook.txt`
route_add=”ip route add “$ra” dev ppp0″
$route_add
i=$(( i+1 ))
done
## End for Facebook

## whatsapp
whois -h whois.radb.net — ‘-i origin AS36351’ | awk ‘/^route:/ {print $2;}’ | sort | uniq > whatsapp.routes
lines=`awk ‘END {print NR}’ whatsapp.routes`
i=1
while (( $i <= $lines ))
do
par=”sed -n “$i”p whatsapp.routes”
$par > whatsapp.txt
ra=`cat whatsapp.txt`
route_add=”ip route add “$ra” dev ppp0″
$route_add
i=$(( i+1 ))
done
## End for whatsapp

## Twitter
whois -h whois.radb.net — ‘-i origin AS13414’ | awk ‘/^route:/ {print $2;}’ | sort | uniq > twitter.routes
lines=`awk ‘END {print NR}’ twitter.routes`
i=1
while (( $i <= $lines ))
do
par=”sed -n “$i”p twitter.routes”
$par > twitter.txt
ra=`cat twitter.txt`
route_add=”ip route add “$ra” dev ppp0″
$route_add
i=$(( i+1 ))
done
## End for Twitrer