Last active
September 15, 2024 02:01
-
-
Save megamen32/a8cf234ee606e9b1960d7a25d971b17c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| #!/bin/bash | |
| # Проверка прав root | |
| if [ "$EUID" -ne 0 ]; then | |
| echo "Пожалуйста, запустите скрипт с правами root" | |
| exit 1 | |
| fi | |
| # Установка пакетов pptpd | |
| if ! command -v pptpd &> /dev/null; then | |
| echo "Устанавливаем PPTP-сервер..." | |
| apt update | |
| apt install -y pptpd | |
| else | |
| echo "PPTP уже установлен." | |
| fi | |
| # Настройка PPTP конфигурации, если не настроено | |
| PPTP_CONF="/etc/pptpd.conf" | |
| if [ ! -f "$PPTP_CONF" ]; then | |
| echo "Настраиваем PPTP..." | |
| cat > "$PPTP_CONF" <<EOF | |
| option /etc/ppp/pptpd-options | |
| logwtmp | |
| localip 192.168.0.1 | |
| remoteip 192.168.0.10-192.168.0.100 | |
| EOF | |
| else | |
| echo "Конфигурационный файл PPTP уже существует, пропускаем создание." | |
| fi | |
| # Настройка опций PPP | |
| PPP_OPTIONS="/etc/ppp/pptpd-options" | |
| if [ ! -f "$PPP_OPTIONS" ]; then | |
| echo "Настраиваем параметры PPP..." | |
| cat > "$PPP_OPTIONS" <<EOF | |
| name pptpd | |
| refuse-pap | |
| refuse-chap | |
| refuse-mschap | |
| require-mschap-v2 | |
| require-mppe-128 | |
| ms-dns 8.8.8.8 | |
| ms-dns 8.8.4.4 | |
| proxyarp | |
| nodefaultroute | |
| lock | |
| nobsdcomp | |
| EOF | |
| else | |
| echo "Файл параметров PPP уже существует, пропускаем создание." | |
| fi | |
| # Настройка пользователя PPTP | |
| echo "Добавляем пользователя us1r с паролем H1RDP4SSW..." | |
| cat > /etc/ppp/chap-secrets <<EOF | |
| # Secrets for authentication using CHAP | |
| # client server secret IP addresses | |
| us1r pptpd H1RDP4SSW * | |
| EOF | |
| # Включение пересылки пакетов | |
| echo "Включаем пересылку пакетов..." | |
| sysctl -w net.ipv4.ip_forward=1 | |
| if ! grep -q "net.ipv4.ip_forward=1" /etc/sysctl.conf; then | |
| echo "net.ipv4.ip_forward=1" >> /etc/sysctl.conf | |
| fi | |
| # Настройка iptables для NAT | |
| echo "Настраиваем iptables для NAT..." | |
| iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE | |
| iptables-save > /etc/iptables.rules | |
| # Настройка автозагрузки iptables | |
| if [ ! -f /etc/network/if-pre-up.d/iptablesload ]; then | |
| echo "Создаём скрипт для автозагрузки iptables..." | |
| cat > /etc/network/if-pre-up.d/iptablesload <<EOF | |
| #!/bin/sh | |
| iptables-restore < /etc/iptables.rules | |
| EOF | |
| chmod +x /etc/network/if-pre-up.d/iptablesload | |
| fi | |
| # Перезапуск службы pptpd | |
| echo "Перезапускаем PPTP-сервер..." | |
| systemctl restart pptpd | |
| systemctl enable pptpd | |
| echo "PPTP-сервер настроен с пользователем us1r и паролем H1RDP4SSW." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment