examples: add example 7. Transparent Proxy with dnsmasq

This commit is contained in:
nadoo 2017-08-31 01:19:49 +08:00
parent a839f8d195
commit 432dc9485b
9 changed files with 106 additions and 7 deletions

View File

@ -4,9 +4,5 @@ verbose=True
listen=:8443
# NOTE HERE:
# specify a rule file
rulefile=office.rule
# specify another rule file
rulefile=home.rule
# parse all *.rule files in rules.d folder
rules-dir=rules.d

View File

@ -0,0 +1,43 @@
## 7. Transparent Proxy with dnsmasq
#### Setup a redirect proxy and a dnstunnel with glider
glider.conf
```bash
verbose=True
listen=redir://:1081
listen=dnstun://5353=8.8.8.8:53
forward=http://forwarder1:8080,socks5://forwarder2:1080
forward=http://1.1.1.1:8080
strategy=rr
checkwebsite=www.apple.com
checkduration=30
```
#### Create a ipset manually
```bash
ipset create myset hash:ip
```
#### Config dnsmasq
```bash
server=/example1.com/127.0.0.1#5353
ipset=/example1.com/myset
server=/example2.com/127.0.0.1#5353
ipset=/example2.com/myset
server=/example3.com/127.0.0.1#5353
ipset=/example4.com/myset
```
#### Config iptables on your linux gateway
```bash
iptables -t nat -I PREROUTING -p tcp -m set --match-set myset dst -j REDIRECT --to-ports 1081
iptables -t nat -I OUTPUT -p tcp -m set --match-set myset dst -j REDIRECT --to-ports 1081
```
Now you can startup glider and dnsmasq, the whole process:
1. all dns requests for domain example1.com will be forward to glider(:5353) by dnsmasq
2. glider will forward dns requests to 8.8.8.8:53 in tcp via forwarders
3. the resolved ip address will be add to ipset "myset" by dnsmasq
4. all tcp requests to example1.com will be redirect to glider(:1081)
5. glider then forward requests to example1.com via forwarders

View File

@ -0,0 +1,16 @@
# Verbose mode, print logs
verbose=True
listen=redir://:1081
listen=dnstun://5353=8.8.8.8:53
forward=http://forwarder1:8080,socks5://forwarder2:1080
forward=http://1.1.1.1:8080
strategy=rr
checkwebsite=www.apple.com
checkduration=30
# parse all *.rule files in rules.d folder
#rules-dir=rules.d

View File

@ -0,0 +1,18 @@
forward=http://forwarder4:8080
# first connect forwarder1 then forwarder2 then internet
forward=http://forwarder5:8080,socks6://forwarder3:1080
# Round Robin mode: rr
# High Availability mode: ha
strategy=rr
checkwebsite=www.apple.com
checkduration=30
# matches 192.168.0.0/16
cidr=192.168.0.0/16

View File

@ -0,0 +1,18 @@
forward=http://forwarder1:8080
# first connect forwarder2 then forwarder3 then internet
forward=http://forwarder2:8080,socks5://forwarder3:1080
# Round Robin mode: rr
# High Availability mode: ha
strategy=rr
checkwebsite=www.apple.com
checkduration=30
# matches 172.16.0.0/24
cidr=172.16.0.0/24

View File

@ -0,0 +1,8 @@
# Verbose mode, print logs
verbose=True
listen=:8443
# parse all *.rule files in rules.d folder
rules-dir=rules.d

View File

@ -113,7 +113,7 @@ dnsserver=8.8.8.8:53
# ----------------
# Create and mange ipset on linux based on destinations in rule files
# - add ip/cidrs in rule files on startup
# - add resolved ips for domains in rule files by dns forwarder server
# - add resolved ips for domains in rule files by dns forwarding server
# Usually used in transparent proxy mode on linux
ipset=glider