Skip to content

Commit

Permalink
Add section to use Google DNS and fix errors
Browse files Browse the repository at this point in the history
  • Loading branch information
kirill-zak committed Mar 12, 2018
1 parent b7db02c commit 1dce0bc
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 6 deletions.
43 changes: 42 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,43 @@
# UnblockDomains
Scripts for unblock domains
OpenWRT scripts for unblock domains

# How to use
Few steps

## 1. Install OpenVPN
Install OpenVPN into OpenWRT device

## 2. Install package bind-hos
```sh
opkg update
opkg install bind-host
```

## 3. Copy scripts into router
From host mashine
```sh
scp unblocker.sh /etc/openvpn/unblocker.sh
```

### Set executable flag
In router
```sh
chmod +x unblocker.sh
```


## 4. Add settings and domain configuration files
Run in folder with scripts
```sh
echo TUN=`ifconfig | grep tun | awk '{print $1}'` > settings.conf
touch domains.conf
```

## 5. Add domains
Add list of domains into `domains.conf`

## 6. Run script
```sh
./unblocker.sh
```

15 changes: 10 additions & 5 deletions unblocker.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
#!/bin/sh

## Intial settings
SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
SCRIPT_DIR=`pwd`
CONFIG_PATH="$SCRIPT_DIR/settings.conf"
DOMAINS_PATH="$SCRIPT_DIR/domains.conf"

Expand All @@ -25,17 +25,22 @@ if [ ! -f "$DOMAINS_PATH" ]; then
exit 1
fi

## Add Google DNS into route table
route add 8.8.8.8/32 dev $TUN;
route add 8.8.4.4/32 dev $TUN;
route add 77.88.8.8/32 dev $TUN;

## Process domains
while read -r DOMAIN
do
echo "Start to process domain [$DOMAIN]..." >&2

DOMAIN_IPS="$(host -t a "$DOMAIN" | awk '{print $4}' | egrep ^[1-9] | sort | uniq)"
DOMAIN_IPS="$(host -t a "$DOMAIN" | awk '{print $4}' | egrep ^[1-9] | awk -F. '{print $1"."$2"."$3".0/24"}' | sort | uniq)"

for IP in ${DOMAIN_IPS[*]}
for IP in ${DOMAIN_IPS}
do
echo " * Adding route for IP [$IP]"
#route add -net "$IP" dev "$TUN"
route add -net "$IP" dev "$TUN"
done

echo "End of process domain [$DOMAIN]" >&2
Expand Down

0 comments on commit 1dce0bc

Please sign in to comment.