This is the commands I got from chatgpt and used it to set up the router. RFKILL is disabled
#!/bin/bash
# Update & Install Required Packages
sudo apt update && sudo apt upgrade -y
sudo apt install tor hostapd dnsmasq iptables-persistent -y
# Set Static IP for wlan0
echo "interface wlan0
static ip_address=192.168.50.1/24
nohook wpa_supplicant" | sudo tee -a /etc/dhcpcd.conf
sudo systemctl restart dhcpcd
# Configure DHCP Server (dnsmasq)
sudo bash -c 'cat > /etc/dnsmasq.conf <<EOF
interface=wlan0
dhcp-range=192.168.50.100,192.168.50.200,255.255.255.0,24h
EOF'
sudo systemctl restart dnsmasq
# Configure Wi-Fi Hotspot (hostapd)
sudo bash -c 'cat > /etc/hostapd/hostapd.conf <<EOF
interface=wlan0
driver=nl80211
ssid=TorRouter
hw_mode=g
channel=7
wmm_enabled=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=12345678
EOF'
sudo sed -i 's|#DAEMON_CONF=""|DAEMON_CONF="/etc/hostapd/hostapd.conf"|' /etc/default/hostapd
sudo systemctl unmask hostapd
sudo systemctl enable hostapd
sudo systemctl start hostapd
# Enable IPv4 Forwarding (Required for Internet Sharing)
echo "net.ipv4.ip_forward=1" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p
# Configure Tor
sudo bash -c 'cat > /etc/tor/torrc <<EOF
VirtualAddrNetwork 10.192.0.0/10
AutomapHostsOnResolve 1
TransPort 9040
DNSPort 5353
SocksPort 9050
Log notice file /var/log/tor/notices.log
ExitRelay 0
EOF'
sudo systemctl enable tor
sudo systemctl restart tor
# Configure Firewall (iptables) - Force all traffic through Tor
sudo iptables -F
sudo iptables -t nat -F
# Route all TCP traffic through Tor
sudo iptables -t nat -A PREROUTING -i wlan0 -p tcp --syn -j REDIRECT --to-ports 9040
# Route all UDP traffic through Tor
sudo iptables -t nat -A PREROUTING -i wlan0 -p udp --dport 53 -j REDIRECT --to-ports 5353
# Allow traffic forwarding from wlan0 to eth0
sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
# Allow NAT from wlan0 to eth0 (Ensures internet sharing works)
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
# Save iptables rules to make them persistent after reboot
sudo netfilter-persistent save
sudo netfilter-persistent reload
# Reboot System
echo "Setup complete! Rebooting now..."
sudo reboot
#!/bin/bash
# Update & Install Required Packages
sudo apt update && sudo apt upgrade -y
sudo apt install tor hostapd dnsmasq iptables-persistent -y
# Set Static IP for wlan0
echo "interface wlan0
static ip_address=192.168.50.1/24
nohook wpa_supplicant" | sudo tee -a /etc/dhcpcd.conf
sudo systemctl restart dhcpcd
# Configure DHCP Server (dnsmasq)
sudo bash -c 'cat > /etc/dnsmasq.conf <<EOF
interface=wlan0
dhcp-range=192.168.50.100,192.168.50.200,255.255.255.0,24h
EOF'
sudo systemctl restart dnsmasq
# Configure Wi-Fi Hotspot (hostapd)
sudo bash -c 'cat > /etc/hostapd/hostapd.conf <<EOF
interface=wlan0
driver=nl80211
ssid=TorRouter
hw_mode=g
channel=7
wmm_enabled=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=12345678
EOF'
sudo sed -i 's|#DAEMON_CONF=""|DAEMON_CONF="/etc/hostapd/hostapd.conf"|' /etc/default/hostapd
sudo systemctl unmask hostapd
sudo systemctl enable hostapd
sudo systemctl start hostapd
# Enable IPv4 Forwarding (Required for Internet Sharing)
echo "net.ipv4.ip_forward=1" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p
# Configure Tor
sudo bash -c 'cat > /etc/tor/torrc <<EOF
VirtualAddrNetwork 10.192.0.0/10
AutomapHostsOnResolve 1
TransPort 9040
DNSPort 5353
SocksPort 9050
Log notice file /var/log/tor/notices.log
ExitRelay 0
EOF'
sudo systemctl enable tor
sudo systemctl restart tor
# Configure Firewall (iptables) - Force all traffic through Tor
sudo iptables -F
sudo iptables -t nat -F
# Route all TCP traffic through Tor
sudo iptables -t nat -A PREROUTING -i wlan0 -p tcp --syn -j REDIRECT --to-ports 9040
# Route all UDP traffic through Tor
sudo iptables -t nat -A PREROUTING -i wlan0 -p udp --dport 53 -j REDIRECT --to-ports 5353
# Allow traffic forwarding from wlan0 to eth0
sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
# Allow NAT from wlan0 to eth0 (Ensures internet sharing works)
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
# Save iptables rules to make them persistent after reboot
sudo netfilter-persistent save
sudo netfilter-persistent reload
# Reboot System
echo "Setup complete! Rebooting now..."
sudo reboot
Statistics: Posted by AASFDA — Sat Mar 01, 2025 12:23 pm