Change background image
LOVE quotion

Bắt đầu từ 4.53' thứ Hai ngày 17/10/2011


You are not connected. Please login or register

Xem chủ đề cũ hơn Xem chủ đề mới hơn Go down  Thông điệp [Trang 1 trong tổng số 1 trang]

DuyHung
DuyHung Xuất sắc

Cấp bậc: Xuất sắc

Giới tính : Nam

Bài viết : 1260

Danh vọng : 2272

Uy tín : 32

Nhu cầu truy cập từ xa vào mạng nội bộ để trao đổi dữ liệu hay sử dụng ứng dụng ngày càng phổ biến. Đây là nhu cầu thiết thực, tuy nhiên việc "mở" hệ thống mạng nội bộ của mình ra ngoài sẽ khiến hệ thống của bạn gặp nhiều vấn đề bảo mật và an toàn thông tin. Bài viết này trình bày giải pháp truy cập từ xa VPN (Virtual Private Network) thông qua router cài đặt FW OpenWRT sử dụng cơ chế mã hóa dựa trên giao thức IPSec nhằm đảm bảo an toàn thông tin.

Trong bài viết này, mình sẽ lần lượt đi qua các bước cài đặt cơ bản trên Router sử dụng FW mới nhất hiện nay của OpenWRT là 12.09 (Attitude Adjustment), cài đặt trên máy tính sử dụng HĐH MS Windows 7, Apple MAC OS 10.8 và cuối cùng là điện thoại / máy tính bảng chạy HĐH Android.

Việc sử dụng giao thức L2TP/IPSec không đòi hỏi bạn phải cài thêm một phần mềm hay ứng dụng nào trên ĐT, máy tính của mình.

1. Cài đặt trên router

Sau khi cài đặt thành công FW OpenWRT trên Router, bạn vào trang điều khiển của Router (địa chỉ mặc định là 192.168.1.1), đặt mật khẩu cho router để tránh sự truy cập trái phép. Việc đặt mật khẩu cũng cho phép bạn truy cập vào Router qua giao thức SSH, giao thức chúng ta sẽ làm việc chủ yếu vì giao diện Web thiếu đi các tính năng can thiệp chuyên sâu.

Sau khi SSH vào NAS thành công, bạn cài các gói sau:

- nano: Chương trình chỉnh sửa tập tin văn bản
- openswan: Thêm tính năng IPSec cho Linux
- ipsec-tools: Công cụ quản lý IPSec
- xl2tpd: Tạo giao thức L2TP
- iptables-mod-ipsec: Bổ sung các tính năng liên quan tới IPSec cho iptables
- kmod-ipsec4 kmod-ipt-ipsec kmod-crypto-aes: Các tính năng cốt lõi để IPSec hoạt động và mã hóa dữ liệu.

Code:
opkg update
opkg install nano openswan ipsec-tools xl2tpd iptables-mod-ipsec kmod-ipsec4 kmod-ipt-ipsec kmod-crypto-aes

nano /etc/modules.d/99-local-ipsec

Code:
ipcomp4
xfrm_mode_transport
xfrm_tunnel

nano /etc/ipsec.conf

Code:
version 2.0

config setup
    nat_traversal=yes
    virtual_private=%v4:0.0.0.0/0,%v4:!100.84.0.0/24
    oe=off
    protostack=netkey       

conn L2TP-PSK
    authby=secret
    pfs=no
    compress=no
    rekey=no
    keyingtries=3
    type=transport
    left=10.84.0.184
    leftnexthop=100.84.0.1
    leftprotoport=17/1701
    right=%any
    rightsubnet=vhost:%no,%priv
    rightprotoport=17/%any
    auto=add

nano /etc/ipsec.secrets

Code:
%any %any : PSK "admin-1234"

/etc/init.d/ipsec enable
nano /etc/xl2tpd/xl2tpd.conf

Code:
[global]
port = 1701
;auth file = /etc/xl2tpd/xl2tp-secrets
access control = no
ipsec saref = yes

[lns default]
exclusive = yes
ip range = 100.84.0.239-100.84.0.247
local ip = 100.84.0.238
length bit = yes
name = XTDV.local
ppp debug = yes
require authentication = yes
unix authentication = no
require chap = yes
require pap = yes
pppoptfile = /etc/ppp/options.xl2tpd

nano /etc/ppp/options.xl2tpd

Code:
require-mschap-v2
ms-dns 192.168.1.1
asyncmap 0
auth
crtscts
lock
hide-password
modem
debug
name l2tpd
proxyarp
lcp-echo-interval 30
lcp-echo-failure 4

nano /etc/ppp/chap-secrets

Code:
#USERNAME    PROVIDER     PASSWORD       IPADDRESS
MY-USERNAME  *            "MY-PASSWORD"  *
*            MY-USERNAME  "MY-PASSWORD"  *

/etc/init.d/xl2tpd enable
nano /etc/config/firewall

Code:
#Allow IPsec
config rule
        option src              wan
        option proto            udp
        option dest_port        500
        option target           ACCEPT      

config rule
        option src              wan
        option proto            udp
        option dest_port        4500
        option target           ACCEPT      

config rule
        option src              wan
        option proto            esp
        option target           ACCEPT

nano /etc/firewall.user

Code:
# This file is interpreted as shell script.
# Put your custom iptables rules here, they will
# be executed with each firewall (re-)start.

iptables -A input_wan -m policy --strict --dir in --pol ipsec --proto esp -j ACCEPT
iptables -A forwarding_rule -i ppp+ -j ACCEPT
iptables -A forwarding_rule -o ppp+ -j ACCEPT

nano /etc/rc.local

Code:
sleep 30
/etc/init.d/ipsec restart

sleep 5
/etc/init.d/xl2tpd restart

nano /etc/ppp/ip-down.d/99-l2tp-restart

Code:
#!/bin/sh
/etc/init.d/ipsec restart
/etc/init.d/xl2tpd restart

Open router port

- 500
- 4500
- 1701

2. Cài đặt trên máy tính

a. Đối với máy tính chạy Microsoft Windows

- Mặc định Windows không cho phép kết nối VPN vào thiết bị đã được NAT, do vậy bạn cần điều chỉnh một chút trước khi thực hiện bước tiếp theo. Tham khảo: http://support.microsoft.com/kb/926179
- Các bạn thực hiện điều chỉnh Registry theo chỉ dẫn của MS ở trên. Bạn nào không rành có thể xem tập tin đính kèm trong bài viết này để thực hiện thay đổi Registry.
- Bạn vào Start, Control Panel, Network and Internet, Network and Sharing Center; sau đó chọn Setup a new connection or network.

b. Đối với máy tính chạy Apple MAC OS X

3. Cài đặt trên máy tính bảng/điện thoại chạy HĐH Android

Tham khao: forum.xtdv.group

- https://www.youtube.com/watch?v=Y88YSzDWA_A
- https://oldwiki.archive.openwrt.org/doc/howto/vpn.overview
- http://themusgravewebsite.com/questions/2402/vpn-manh-me-tren-openwrt
- https://quantrimang.com/cach-tu-thiet-lap-may-chu-vpn-tai-nha-145357
      

Xem chủ đề cũ hơn Xem chủ đề mới hơn Về Đầu Trang  Thông điệp [Trang 1 trong tổng số 1 trang]

Quyền hạn của bạn

Bạn không có quyền trả lời bài viết
free counters



  • Đoàn Ngọc Khánh

    mobile phone 098 376 5575


    Đỗ Quang Thảo

    mobile phone 090 301 9666


    Nguyễn Văn Của

    mobile phone 090 372 1401


    IP address signature
    Create a forum on Forumotion | ©phpBB | Free forum support | Báo cáo lạm dụng | Thảo luận mới nhất