|
|
#!/bin/bash |
|
|
|
|
|
set -e |
|
|
|
|
|
echo "Starting SSH/SOCKS5 NAT Gateway setup..." |
|
|
|
|
|
|
|
|
echo 1 > /proc/sys/net/ipv4/ip_forward |
|
|
|
|
|
|
|
|
PUBLIC_IP=$(curl -s ifconfig.me) |
|
|
if [ -z "$PUBLIC_IP" ]; then |
|
|
echo "Error: Could not fetch public IP. Exiting." |
|
|
exit 1 |
|
|
fi |
|
|
echo "Detected public IP: $PUBLIC_IP" |
|
|
|
|
|
|
|
|
cp /app/ssh-config/sshd_config /etc/ssh/sshd_config |
|
|
chmod 600 /etc/ssh/sshd_config |
|
|
|
|
|
|
|
|
if [ ! -f /etc/ssh/ssh_host_rsa_key ]; then |
|
|
ssh-keygen -A |
|
|
fi |
|
|
|
|
|
|
|
|
/usr/sbin/sshd -D -e -f /etc/ssh/sshd_config > /var/log/sshd_debug.log 2>&1 & |
|
|
|
|
|
echo "SSH server started." |
|
|
|
|
|
|
|
|
cp /app/socks5-config/danted.conf /etc/danted.conf |
|
|
chmod 644 /etc/danted.conf |
|
|
|
|
|
|
|
|
/usr/sbin/danted -D & |
|
|
|
|
|
echo "Dante SOCKS5 server started." |
|
|
|
|
|
|
|
|
iptables-legacy -t nat -A POSTROUTING -o eth0 -j MASQUERADE |
|
|
iptables-legacy -A FORWARD -i eth0 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT |
|
|
iptables-legacy -A FORWARD -i eth0 -o eth0 -j ACCEPT |
|
|
|
|
|
echo "iptables NAT rules set." |
|
|
|
|
|
|
|
|
exec tail -f /dev/null |
|
|
|
|
|
|
|
|
|