This is a simple program that allows you to create a connection to the Internet through Telegram servers, taking advantage of the unlimited data offerings from mobile carriers.
- Install prerequisites
Alpine Linux:
sudo apk install gcc g++ cmake ninja gperf python3 python3-dev openssl-dev
- Build and install td and tuntap libraries
./build.sh
- Install requirements
python3 -m pip install -r requirements.txt
- Create config files
Example of
/config.client.yaml
(changetdconfig.token
to your phone number):
tdconfig:
files_directory: ".td"
token: "+15555555555"
api_id: 94575
api_hash: "a3406de8d171bb422bb6ddf3bbd800e2"
database_encryption_key: "1234echobot$"
tun:
name: "telegram_tun0"
mtu: 1500
ip: "10.0.0.2"
cache_size: 1
cache_flush_rate: 10
#cache_size: 0
#cache_flush_rate: 0
wrap_in_proxy: false
receive_from_user_id: 829534074
send_to_chat_id: 829534074
Copy config to config.server.yaml
, but change TUN's device IP to ip: "10.0.0.1"
for your internal server TUN device IP. Then rsync config to the server.
rsync -avz -e ssh config.server.yaml user@company420:/p/ip_over_telegram
- You should have root permissions in order to run this program.
- On the server:
sudo sysctl -w net.ipv4.ip_forward=1
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo iptables --policy FORWARD ACCEPT
sudo modprobe tun
sudo python3 main.py config.server.yaml
- On the client:
sudo modprobe tun
sudo python3 main.py config.client.yaml
- Setup routes (on the client):
TELEGRAM_IP_ADDRESSES=(149.154.167.41 149.154.167.51 95.161.76.100)
DEFAULT_GATEWAY=$(ip route | grep default | awk '{print $3 " dev " $5}')
# Add Telegram IP addresses to the exception for your default gateway
for ip in $TELEGRAM_IP_ADDRESSES; do sudo ip route add $ip via $DEFAULT_GATEWAY; done
# Make IP over Telegram as default gateway
sudo ip route change default via 10.0.0.1 dev telegram_tun0
- Enjoy!
- Stop
sudo ip route change default via $DEFAULT_GATEWAY
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE-2.0 or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.