Installing dnscrypt-proxy on Linux

Get a root shell

sudo -s

check what else is possibly already listening to port 53

ss -lp 'sport = :domain'
systemctl stop systemd-resolved
systemctl disable systemd-resolved
ss -lp 'sport = :domain'

Download and run dnscrypt-proxy

Download dnscrypt-proxy here: dnscrypt-proxy binaries.

cp example-dnscrypt-proxy.toml dnscrypt-proxy.toml
./dnscrypt-proxy

Change the system DNS settings

apt-get remove resolvconf
cp /etc/resolv.conf /etc/resolv.conf.backup
rm -f /etc/resolv.conf

And create a new /etc/resolv.conf file with the following content:

nameserver 127.0.0.1
options edns0

Install the proxy as a system service

./dnscrypt-proxy -service install
./dnscrypt-proxy -service start
./dnscrypt-proxy -service stop
./dnscrypt-proxy -service restart
./dnscrypt-proxy -service uninstall

Want to check that DNS resolution works?

./dnscrypt-proxy -resolve example.com

Connect to 1.1.1.1 using DoH clients

Add cloudflare and cloudflare-ipv6 to the server list in dnscrypt-proxy.toml:

server_names = ['cloudflare', 'cloudflare-ipv6']

References
https://github.com/DNSCrypt/dnscrypt-proxy/wiki/Installation-linux
https://developers.cloudflare.com/1.1.1.1/encryption/dns-over-https/dns-over-https-client/

Linux Host File

The hosts file is a way to map hostnames to IP addresses. This is very important with certain setups and to make networking on Linux a bit easier. In a sense, the hosts file acts as a local DNS server.

sudo nano /etc/hosts

For example, to block Wikipedia, you’d type (remembering to use the Tab key rather than Space):

127.0.0.1        wikipedia.org

or static dns lookup for hostnames

198.20.14.51 example.com

References
https://www.makeuseof.com/tag/modify-manage-hosts-file-linux/

Configure Shadowsocks + V2ray + TLS + Apache + CDN on Ubuntu

Shadowsocks

nano /etc/shadowsocks/config.json
{
    "server":"127.0.0.1",
    "server_port":10001,
    "password":"password",
    "mode":"tcp_only",
    "timeout":300,
    "method":"chacha20-ietf-poly1305",
    "plugin":"v2ray-plugin_linux_amd64",
    "plugin_opts":"server;path=/ss;loglevel=none", # loglevel=debug
    "nameserver":"1.1.1.1"
}

Apache

nano /etc/apache2/apache2.conf
<VirtualHost *:80>
    Servername example.com
    RewriteEngine on
    RewriteCond %{SERVER_NAME} =example.com
    RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URL} [END,NE,R=permanent]
</VirtualHost>

<VirtualHost *:443>
    # change your domain
    ServerName example.com
    # you may have a different root
    DocumentRoot /var/www/

    # the SSL configuration enable https for your site and it’s also required by shadowsocks + v2ray
    SSLEngine on
    SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/example.com/privkey.pem

    SSLProtocol All -SSLv2 -SSLv3 -TLSv1 -TLSv1.1 +TLSv1.2 +TLSv1.3
    SSLCipherSuite HIGH:!aNULL

    <Location "/ss">
    ProxyPass ws://127.0.0.1:10001/ss
    ProxyAddHeaders Off
    ProxyPreserveHost On
    RequestHeader append X-Forwarded-For %{REMOTE_ADDR}s
    </Location>
</VirtualHost>

 

References
https://guide.v2fly.org/en_US/advanced/wss_and_web.html#server-side-configuration
https://big533.cc/wordpress/index.php/2020/01/03/v2ray-setup-with-websocket-tls-using-apache/
https://github.com/KonaisPC/v2ray-apache-ws/blob/master/v2ray-apache.sh

Install Shadowsocks + V2ray + TLS + CDN on Ubuntu

Install required Ubuntu packages

apt update
apt install -y --no-install-recommends gettext build-essential autoconf libtool libpcre3-dev asciidoc xmlto libev-dev libc-ares-dev automake libssl-dev gawk debhelper init-system-helpers pkg-config apg zlib1g-dev libudns-dev libsodium-dev libmbedtls-dev haveged

Install Certbot

sudo snap install core; sudo snap refresh core
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot

Get a certificate for your domain :

sudo certbot certonly --standalone

result

# Certificate is saved at: /etc/letsencrypt/live/example.com/fullchain.pem
# Key is saved at:         /etc/letsencrypt/live/example.com/privkey.pem

Download shadowsocks-rust

wget https://github.com/shadowsocks/shadowsocks-rust/releases/download/v1.17.1/shadowsocks-v1.17.1.x86_64-unknown-linux-gnu.tar.xz
tar -xf shadowsocks-v1.17.1.x86_64-unknown-linux-gnu.tar.xz

Or download latest version here https://github.com/shadowsocks/shadowsocks-rust

Download v2ray-plugin

wget https://github.com/shadowsocks/v2ray-plugin/releases/download/v1.3.2/v2ray-plugin-linux-amd64-v1.3.2.tar.gz
tar -xzvf v2ray-plugin-linux-amd64-v1.3.2.tar.gz

Or download latest version here https://github.com/shadowsocks/v2ray-plugin

Move files

mv sslocal ssserver ssurl ssmanager ssservice v2ray-plugin_linux_amd64 /usr/local/bin/

Configuration

mkdir -p /etc/shadowsocks
touch /etc/shadowsocks/config.json
nano /etc/shadowsocks/config.json
{
    "server":"0.0.0.0",
    "server_port":443,
    "password":"password",
    "mode":"tcp_only",
    "timeout":300,
    "method":"chacha20-ietf-poly1305",
    "plugin":"v2ray-plugin_linux_amd64",
    "plugin_opts":"server;tls;cert=/etc/letsencrypt/live/example.com/fullchain.pem;key=/etc/letsencrypt/live/example.com/privkey.pem;host=example.com;path=/;loglevel=none",
    "nameserver":"1.1.1.1"
}

replace example.com with your domain in configuarion

Create Systemd service

touch /lib/systemd/system/shadowsocks.service
nano /lib/systemd/system/shadowsocks.service
[Unit]
Description=Shadowsocks Server Service
After=network.target
[Service]
ExecStart=/usr/local/bin/ssserver -c /etc/shadowsocks/config.json
ExecReload=/bin/kill -HUP \$MAINPID
Restart=on-failure
[Install]
WantedBy=multi-user.target
systemctl enable shadowsocks.service
systemctl start shadowsocks.service
journalctl -u shadowsocks.service -f

References
https://github.com/M3chD09/shadowsocks-with-v2ray-plugin-install

Configure Tor with Bridge in Ubuntu

sudo apt-get install tor

After runing tor you can see the log of the tor by

journalctl -exft Tor

If the service started without errors, look at the Tor log

sudo journalctl -b --no-pager /usr/bin/tor
sudo apt install obfs4proxy

then you should get the bridge line. for get the bridge line go to https://bridges.torproject.org/ and get your bridge line.

nano /etc/tor/torrc
UseBridges 1 
ClientTransportPlugin obfs4 exec /usr/bin/obfs4proxy 
Bridge obfs4 132.145.63.40:47347 5C72EEEE587AB1C7021A78707DAB80427F7A9B43 cert=HAZq1DmA4kR1/IFy1TBeSd67BNQI4SDur+U3zxun+G7HCWJ+x66eUyM6/sariPQYDJ9aIw iat-mode=0
Bridge obfs4 132.226.205.56:1991 6CA77FBE6752502259A3D0079F1C510663166404 cert=yrWZOUqsfQ9IyCj3LFwXSqFqbh+59S+1P9yPh/obHt4fbVYrE3ypGthX/+ZvM207I3xIBQ iat-mode=0
Bridge obfs4 45.33.1.189:9123 F9DFF618E7BA6C018245D417F39E970C2F019BAA cert=mDZuXuqSTjX1OjN7zLybTYzNi0A21A7G0DRNmW79029cSvLYSOk/KhGftcnmxruTmhRfZQ iat-mode=0
systemctl restart tor.service

References
https://askubuntu.com/questions/1183145/how-can-i-configure-tor-with-bridge-and-privoxy-to-proxy-entire-system
https://askubuntu.com/questions/607961/error-with-tor-in-ubuntu14-04

Install GitHub Desktop on Ubuntu

wget -qO - https://mirror.mwt.me/ghd/gpgkey | sudo tee /etc/apt/trusted.gpg.d/shiftkey-desktop.asc > /dev/null
# if you want to use packagecloud.io
sudo sh -c 'echo "deb [arch=amd64] https://packagecloud.io/shiftkey/desktop/any/ any main" > /etc/apt/sources.list.d/packagecloud-shiftkey-desktop.list'

# if you want to use the US mirror
sudo sh -c 'echo "deb [arch=amd64] https://mirror.mwt.me/ghd/deb/ any main" > /etc/apt/sources.list.d/packagecloud-shiftkey-desktop.list'
sudo apt update && sudo apt install github-desktop

References
https://github.com/shiftkey/desktop

Install GitHub CLI on Ubuntu

curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
&& sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& sudo apt update \
&& sudo apt install gh -y
sudo apt update
sudo apt install gh

References
https://github.com/cli/cli/blob/trunk/docs/install_linux.md
https://cli.github.com/manual/gh