Last active
March 5, 2024 08:29
-
-
Save diyism/855b601b13c61d923f17fcac968796de to your computer and use it in GitHub Desktop.
tailscale exit node settings and global dns settings on pc, android termux or android shell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0.In my 0th vps (for example Oracle Cloud free tier VPS, ubuntu 20.04, it allow me to create 2 free vps servers): | |
#sudo apt install tailscale(ref: https://tailscale.com/kb/1039/install-ubuntu-2004/) | |
wget https://pkgs.tailscale.com/stable/tailscale_1.38.4_amd64.tgz | |
tar zxvf tailscale_1.38.4_amd64.tgz | |
sudo cp tailscale_1.38.4_amd64/tailscale* /usr/bin/ | |
rm -rf tailscale_1.38.4_amd64* | |
sudo tailscale up //copy the showed url and authorize google sign-in in the web browser | |
ip addr show tailscale0 //for example: 100.71.153.9 | |
1. In my 1st vps(in china, for example my linux PC in my home): | |
sudo apt install tailscale | |
sudo sysctl net.ipv4.conf.all.forwarding=1 | |
sudo tailscale up --advertise-exit-node --accept-dns=false //copy the showed url and authorize google sign-in in the web browser | |
//"--advertise-exit-node" to advertise this vps as exit node, "--accept-dns=false" to avoid global dns settings overwriting /etc/resolv.conf in exit node | |
ip addr show tailscale0 //it shows for example: 100.71.153.10 | |
curl https://www.google.com/search?q=my%20ip //it shows for example: 132.226.172.5 | |
tailscale version //it shows 1.8.6 | |
//open socks5 proxy 8086 that go through the 0th vps | |
while true; do nohup /usr/bin/ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o ServerAliveInterval=10 -o ServerAliveCountMax=6 -CND 100.71.153.10:8086 [email protected] -p 22 > /dev/null 2>&1; sleep 1; done & | |
//create socks86 interface for 8086 socks5 proxy | |
while true; do nohup ip tuntap add dev socks86 mode tun user nobody >/dev/null 2>&1; ifconfig socks6 up 10.6.0.1 >/dev/null 2>&1; badvpn-tun2socks --tundev socks86 --netif-ipaddr 10.6.0.2 --netif-netmask 255.255.255.0 --socks-server-addr 100.71.153.10:8086 >/dev/null 2>&1; sleep 1; done & | |
./mydns --listen 0.0.0.0:53 //my udp dns server, output every query logs, china/foreign IP split, for foreign IPs: ip route add <foregin ip>/32 dev socks86 scope link | |
2.In the web page of https://login.tailscale.com/admin/machines | |
Click the "..." menu button of 100.71.153.10 | |
Click "Review route settings" | |
Enable the "Use as exit node" | |
3.In the web page of https://login.tailscale.com/admin/dns | |
Click "Add nameserver", input "100.71.153.10" and click "Save" | |
Click the "Override local DNS" switch and enable it | |
4.In my android phone: | |
Install latest tailscale app from google play(version >=1.8.6) | |
Authenticate it with google sign-in | |
Click the "..." menu button on the top-right of the app | |
Click "Use "Use exit node" and select the name of "100.71.153.10" | |
Click "Active" switch | |
Open the browser, | |
visit https://www.google.com/search?q=my%20ip | |
It shows my 1st oracle vps's IP 132.226.172.5 | |
5.In my 2nd vps(in china, just for test, not must): | |
curl https://www.google.com/search?q=my%20ip //it shows my 2nd vps's IP: 152.70.90.2 | |
sudo apt install tailscale | |
sudo tailscale up --exit-node=100.71.153.10 //to restore: sudo tailscale down ; sudo tailscale up --reset | |
curl https://www.google.com/search?q=my%20ip --resolve www.google.com:443:216.58.200.36 //it shows my 1st vps's IP: 132.226.172.5 | |
Now I can see "/etc/resov.conf" has been changed to "nameserver 100.71.153.10" | |
I can see dns query log in my 1st vps | |
================ | |
socks5 proxy is more convinient than exit node: | |
in vps: | |
./tailscaled --tun=userspace-networking --state=./tailscaled.state --socket=./tailscaled.sock --port 41641 --socks5-server 0.0.0.0:8080 | |
./tailscale --socket=tailscaled.sock up | |
in home pc: | |
time curl --socks5 <vps tailscale ip>:8080 https://1.1.1.1 | head -n 20 | |
========tailscale in android termux======== | |
in my linux PC: | |
$ wget https://github.com/termux/termux-app/releases/download/v0.118.0/termux-app_v0.118.0+github-debug_arm64-v8a.apk | |
$ adb install termux-app_v0.118.0+github-debug_arm64-v8a.apk | |
in termux in my android phone: | |
$ wget https://pkgs.tailscale.com/stable/tailscale_1.30.0_arm64.tgz | |
$ tar xzvf tailscale_1.30.0_arm64.tgz | |
$ ./tailscaled --tun=userspace-networking --state=./tailscaled.state --socket=./tailscaled.sock --port 41641 --socks5-server 0.0.0.0:8081 | |
$ ./tailscale --socket=./tailscaled.sock up | |
$ pkg install openssh openssh-tool | |
$ sshd | |
$ passwd root | |
in my VPS (there's tailscaled in it already): | |
$ ssh root@<my android phone's tailscale IP> -p 8022 | |
==============go webview in android termux=========== | |
go get github.com/webview/webview #installed webkit2gtk | |
env DISPLAY=:0 go run test.go | |
#view the ui with android-xserver(https://github.com/nwrkbiz/android-xserver), the apk size is only 0.25MB | |
==============tailscale in android without termux======== | |
# in fact, tailscale doesn't need termux, to use "unix:abstract", for example "@tailscaled.sock": | |
./tailscaled --tun=userspace-networking --state=./tailscaled.state [email protected] --port 41641 --socks5-server 0.0.0.0:8081 | |
./tailscale [email protected] up | |
================tailscale in github codespace=========== | |
# add this line into the "start)" paragraph in /etc/init.d/ssh: | |
/usr/sbin/tailscaled --state=/var/lib/tailscale/tailscaled.state --socket=/run/tailscale/tailscaled.sock --port 41641 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment