ติดตั้ง VPN server L2TP/IPsec บน cenos 7

ติดตั้ง VPN server L2TP/IPsec บน cenos 7

ลิ้งอ้างอิง https://github.com/hwdsl2/setup-ipsec-vpn

จริงๆแล้วไม่ได้มีความเข้าใน ในการทำงานของ vpn มาก เพราะที่ทราบคือ เหมือนเราจะได้ ip ใหม่หลังจาก vpn ไปแล้ว โดย ip นั้นจะคือ ip ที่ได้รับแจกจาก

vpn server โดน ip นั้นจะสามารถเข้าจัดการ server ต่างๆที่อยู่ใน วงเดียวกับ vpn

ผมจะไม่ได้ อธิบาย ว่า vpn จริงๆทำงานอย่างไร อันนี้น่าจะมีข้อมูลเยอะ ใน google  และหลายวิธี แต่ในนี้ผมจะอธิบายจากสิ่งที่เค้าทำไว้แล้วมาอธิบายให้ฟัง

โดยจะเป็น vpn L2TP/IPsec  ที่มี username ,password และ pre-shared key (PSK)  ที่ติดตั้งบน centos

หากต้องการทราบละเอียด เข้าไปดูที่ลิ้งอ้างอิงได้ โดยวิธีการทดสอบของผมมีดังนี้

yum update

wget https://git.io/vpnsetup-centos -O vpnsetup.sh && sudo sh vpnsetup.s

จากนั้นมันจะทำการติดตั้ง ทั้งหมดที่ต้องใช้  โดยเราจะได้แบบนี้มา

server ip: จะเป็น ip internet ของเรา เราอาจจะต้องแก้ ให้เป็น ip wan ในที่นี้คือ 192.168.1.3

IPaec PSK, username,password เอาไปตั้ง vpn client

 

ส่วนที่แก้ wan ip และ ชุด ip ที่จะส่งให้ vpn  client แก้ที่ /etc/ipsec.conf

wan ip

conn shared
left=%defaultroute
leftid=192.168.1.33

ip  client

conn xauth-psk
auto=add
leftsubnet=0.0.0.0/0
rightaddresspool=192.168.43.10-192.168.43.250
modecfgdns=”8.8.8.8 8.8.4.4″

 

หลังจากนั้น systemctl restart ipsec

จากที่ทดสอบ

Windows 10 and 8.x

  1. Right-click on the wireless/network icon in your system tray.
  2. Select Open Network and Sharing Center. Or, if using Windows 10 version 1709 or newer, select Open Network & Internet settings, then on the page that opens, click Network and Sharing Center.
  3. Click Set up a new connection or network.
  4. Select Connect to a workplace and click Next.
  5. Click Use my Internet connection (VPN).
  6. Enter Your VPN Server IP in the Internet address field.
  7. Enter anything you like in the Destination name field, and then click Create.
  8. Return to Network and Sharing Center. On the left, click Change adapter settings.
  9. Right-click on the new VPN entry and choose Properties.
  10. Click the Security tab. Select “Layer 2 Tunneling Protocol with IPsec (L2TP/IPSec)” for the Type of VPN.
  11. Click Allow these protocols. Check the “Challenge Handshake Authentication Protocol (CHAP)” and “Microsoft CHAP Version 2 (MS-CHAP v2)” checkboxes.
  12. Click the Advanced settings button.
  13. Select Use preshared key for authentication and enter Your VPN IPsec PSK for the Key.
  14. Click OK to close the Advanced settings.
  15. Click OK to save the VPN connection details.

Note: windows จะมีปัญหาหลังจากทดสอบมันใช้ไม่ได้ต้องแก้ตามนี้ แต่ถึงแก้แล้วก็เจอว่า ใช้ได้ 1 ครั้ง หาก disconnect แล้วจะต่อใหม่ไม่ได้ ต้อง restart เครื่อง

  1. Login to the Windows machine as Admin.
  2. Go to ‘Start > Run’ and type regedit.
  3. Locate the entry “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\PolicyAgent“.
  4. Right-click and Create a new DWORD (32-bit) value.
  5. Add “AssumeUDPEncapsulationContextOnSendRule” and save.
  6. Modify the new entry and change Value Data from “0” to “2”.
  7. Reboot the computer and test the connection.

OS X

  1. Open System Preferences and go to the Network section.
  2. Click the + button in the lower-left corner of the window.
  3. Select VPN from the Interface drop-down menu.
  4. Select L2TP over IPSec from the VPN Type drop-down menu.
  5. Enter anything you like for the Service Name.
  6. Click Create.
  7. Enter Your VPN Server IP for the Server Address.
  8. Enter Your VPN Username for the Account Name.
  9. Click the Authentication Settings button.
  10. In the User Authentication section, select the Password radio button and enter Your VPN Password.
  11. In the Machine Authentication section, select the Shared Secret radio button and enter Your VPN IPsec PSK.
  12. Click OK.
  13. Check the Show VPN status in menu bar checkbox.
  14. (Important) Click the Advanced button and make sure the Send all traffic over VPN connection checkbox is checked.
  15. Click the TCP/IP tab, and make sure Link-local only is selected in the Configure IPv6 section.
  16. Click OK to close the Advanced settings, and then click Apply to save the VPN connection information.

Note: Mac ลองแล้วไม่ได้อะไรจ้า

 

ใส่ความเห็น

อีเมลของคุณจะไม่แสดงให้คนอื่นเห็น ช่องที่ต้องการถูกทำเครื่องหมาย *