Unblock Restricted Content with Dnsmasq and Sniproxy

Q:How to unblock Restricted Content?
A: Unblock Restricted Content with Setting up your own Dnsmasq server and Sniproxy Server.

This article will bring you over how to install dnsmasq and sniproxy for unblock restricted content such as BBC, Disney, FoxSport, ESPN.

In this tutorial we will need 2 server (Ubuntu 1604 LTS 64bit)

One will be the dnsmasq server and another one will be sniproxy

First of all we will start with a Dnsmasq Server.

192.168.1.30 dnsmasq server
192.168.1.31 computer to watch movie
192.168.1.32 sniproxy server (this server must be in the country that the content available country. )

Example: if you going to watch bbc outside of UK, your sniproxy server has to be in UK, you can get a VPS from DigitalOcean or anywhere else

Step1: Install dnsmasq on ubuntu 1604

apt-get install dnsmasq

Step2: Configure dnsmasq config file

vi /etc/dnsmasq.conf

add the following to the end of the dnsmasq.conf file

cache-size=0
no-resolv
log-queries
log-facility=/var/log/dnsmasq
server=8.8.8.8

Save and quit the file.

Step3: Restart dnsmasq

/etc/init.d/dnsmasq restart
systemctl restart dnsmasq
service dnsmasq restart

choose either one thats work for you, normally will be working for all these three

and verify your dnsmasq is startup successfully.

netstat -ntulp |grep dnsmasq

you will saw the output like this:

tcp 0 0 0.0.0.0:53 0.0.0.0:* LISTEN 21356/dnsmasq 
tcp6 0 0 :::53 :::* LISTEN 21356/dnsmasq 
udp 0 0 0.0.0.0:53 0.0.0.0:* 21356/dnsmasq 
udp6 0 0 :::53 :::* 21356/dnsmasq

and now set your computer dns address to become your dnsmasq server ip address. ie (192.168.1.30)

back to your dnsmasq server and try is it all the dns query passby your dnsmasq server by using below command

tail -f /var/log/dnsmasq |grep 1.31$

1.31 should be your computer ip address.

Step4: Redirect the domain you want to pass through sniproxy server.

cd /etc/dnsmasq.d/

vi redirect.conf

address=/www.bbc.co.uk/192.168.1.32
address=/www.abc.com/192.168.1.32

(In this example you are redirecting www.bbc.co.uk to sniproxy server and sniproxy server will pass your request to www.bbc.co.uk)

of course it will not be only one link to unblock the whole bbc content, you can find other link on /var/log/dnsmasq

if you lazy to find all those link to unblock, you can simply type

address=/#/192.168.1.32

it will redirect all the link that coming from your computer. # means anything.

save and exit the file.

You can use tail -f /var/log/sniproxy/*.log to see is it any dns record coming from your dnsmasq server or your computer.

if you have that, you had successful create the sniproxy server.

Enjoy the tutorial, Share this to your friends who need this.

NOTE: WE will not making any responsibility on this article , we are writing this article for education purpose. 

Now we will going through and setup our Sniproxy server.

Step1: Download sniproxy and install require package.

apt-get install libfile-chdir-perl git autotools-dev cdbs debhelper dh-autoreconf dpkg-dev gettext libev-dev libpcre3-dev libudns-dev pkg-config fakeroot devscripts libbz2-dev libpcre3-dev zlib1g-dev libboost-all-dev python-setuptools python-pip libmysqlclient-dev perltidy libfile-pid-perl libclass-dbi-mysql-perl libdbi-perl libdbd-mysql ipset autoconf dnsutils pandoc build-essential

using git to clone the sniproxy package from github.

cd /opt/
git clone https://github.com/dlundquist/sniproxy.git
cd sniproxy
./autogen.sh
dpkg-buildpackage

Step2: Install Sniproxy by using DPKG

cd /opt
dpkg -i sniproxy_*.deb

Step3: Enable Sniproxy

vim /etc/default/sniproxy

Changes ENABLED=0 to ENABLED=1

save and quit the file.

Step4: Edit sniproxy.conf

vi /etc/sniproxy.conf

delete all the stuff in the sniproxy.conf and replace will below content.

user daemon
pidfile /var/run/sniproxy.pid
resolver {
nameserver 8.8.8.8
mode ipv4_only
}
error_log {
filename /var/log/sniproxy/sniproxy.log
priority info
}
listen 192.168.1.32 8080 {
proto http
table httpout
access_log { filename /var/log/sniproxy/httpout_access.log }
bad_requests log
}
listen 192.168.1.32 443 {
proto tls
table httpsout
access_log { filename /var/log/sniproxy/httpsout_access.log }
bad_requests log
}
table httpout { .* *:80 }
table httpsout { .* *:443 }

192.168.1.32 in this tutorial are the ip address of sniproxy server, you have to changes the red text to your own sniproxy server ip address.

save and close the file

Step5: Start Sniproxy

systemctl restart sniproxy
service sniproxy restart

either one , see which one works for you.
and please check your sniproxy is it starting correctly by using command below:

netstat -ntulp |grep sniproxy

you will get something similar like below.

tcp 0 0 192.168.1.32:80 0.0.0.0:* LISTEN 20381/sniproxy
tcp 0 0 192.168.1.32:443 0.0.0.0:* LISTEN 20381/sniproxy
udp 0 0 0.0.0.0:59464 0.0.0.0:* 20381/sniproxy

NOTE: WE will not making any responsibility on this article , we are writing this article for education purpose.

Feel free to contact us if you found you has fail on this tutorial, we also providing a service only for you.

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

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