Bước 1: Kiểm tra khả năng hỗ trợ PPTP
Chạy lệnh sau để xác minh kernel có hỗ trợ nén PPP cần thiết:
modprobe ppp_mppe && echo "Hỗ trợ sẵn sàng"
Bước 2: Cài đặt gói PPP
yum install -y ppp
Bước 3: Kích hoạt kho EPEL
sudo yum install -y epel-release sudo yum update -y
Bước 4: Cài đặt dịch vụ PPTPD
yum install -y pptpd
Bước 5: Định cấu hình dải IP cho kết nối VPN
Mở tệp /etc/pptpd.conf, bỏ chú thích hai dòng sau:
localip 10.10.10.1 remoteip 10.10.10.100-200
Bước 6: Thiết lập DNS cho client
Chỉnh sửa /etc/ppp/options.pptpd, thêm hoặc đảm bảo tồn tại các dòng:
ms-dns 1.1.1.1 ms-dns 8.8.8.8
Bước 7: Tạo tài khoản xác thực
Thêm vào /etc/ppp/chap-secrets theo định dạng tab-delimited:
vpnuser pptpd MySecurePass123 *
(Cột 1: tên người dùng, cột 2: tên dịch vụ, cột 3: mật khẩu, cột 4: địa chỉ IP được phép — * cho phép mọi nơi)
Bước 8: Bật chuyển tiếp IP
Sửa /etc/sysctl.conf:
net.ipv4.ip_forward = 1
Áp dụng ngay lập tức:
sysctl -p
Bước 9: Đăng ký dịch vụ PPTP trong firewalld
Tạo tệp dịch vụ tùy chỉnh:
sudo tee /usr/lib/firewalld/services/pptp.xml <<'EOF' <?xml version="1.0" encoding="utf-8"?> <service> <short>pptp</short> <description>Point-to-Point Tunneling Protocol</description> <port protocol="tcp" port="1723"/> </service> EOF
Bước 10: Cấu hình tường lửa
firewall-cmd --permanent --add-service=pptp firewall-cmd --permanent --add-port=47/tcp firewall-cmd --permanent --add-port=1723/tcp firewall-cmd --permanent --direct --add-rule ipv4 filter INPUT 0 -p gre -j ACCEPT firewall-cmd --permanent --direct --add-rule ipv4 filter FORWARD 0 -i ppp+ -o eth0 -j ACCEPT firewall-cmd --permanent --direct --add-rule ipv4 filter FORWARD 0 -i eth0 -o ppp+ -j ACCEPT firewall-cmd --permanent --direct --passthrough ipv4 -t nat -I POSTROUTING -s 10.10.10.0/24 -o eth0 -j MASQUERADE firewall-cmd --reload
Bước 11: Khởi động và kích hoạt dịch vụ
systemctl enable pptpd firewalld systemctl start pptpd firewalld
Bước 12: Kết nối từ Windows
Trong Network and Sharing Center → Set up a new connection or network → Connect to a workplace → chọn Use my Internet connection (VPN). Nhập địa chỉ IP máy chủ, tên người dùng và mật khẩu đã khai báo ở bước 7.
Ghi chú khắc phục sự cố phổ biến:
Nếu máy khách Windows không truy cập được Internet sau khi kết nối, hãy vô hiệu hóa tùy chọn "Use default gateway on remote network" trong thuộc tính IPv4 → Advanced của kết nối VPN. Điều này ngăn lưu lượng cục bộ bị định tuyến sai qua đường hầm.