Xác thực khách hàng OPENVPN qua máy chủ FREERADIUS

1. Cài đặt RADIUSPLUGIN

Truy cập máy chủ openvpn của bạn (trong trường hợp này tôi đang sử dụng CentOS 7 64bit) và đăng nhập với tư cách là người chủ. Sau đó, cài đặt các phụ thuộc bắt buộc để biên dịch thành công radiusplugi.

Ubuntu / Debian:

apt-get install libgcrypt11 libgcrypt11-dev build-essential

CentOS / Fedora:

yum install libgcrypt libgcrypt-devel gcc-c++

Sau khi cài đặt các phụ thuộc, bây giờ chúng ta có thể tải xuống nguồn radiusplugin. Chúng tôi sẽ tạo một thư mục và tải xuống các tệp nguồn từ đó.

Ubuntu / Debian / CentOS / Fedora:

mkdir /etc/radiusplugin

Sau đó, chúng tôi sẽ vào bên trong thư mục và tải xuống nguồn.

Ubuntu / Debian / CentOS / Fedora:

cd /etc/radiusplugin/

Ubuntu / Debian / CentOS / Fedora:

wget http://www.nongnu.org/radiusplugin/radiusplugin_v2.1a_beta1.tar.gz

Sau khi chúng tôi tải xuống, chúng tôi cần giải nén các tệp nguồn.

Ubuntu / Debian / CentOS / Fedora:

tar xvf radiusplugin_v2.1a_beta1.tar.gz

Sau đó, chúng ta sẽ vào bên trong thư mục radiusplugin và thực hiện lệnh make .
Ubuntu / Debian / CentOS / Fedora:

cd radiusplugin_v2.1a_beta1
make

Chúng ta sẽ nhận được tệp radiusplugin.so sau khi biên dịch từ nguồn và chúng ta sẽ cần chuyển tệp này đến một vị trí tốt hơn, có thể là trong thư mục openvpn. Nhưng trước tiên, chúng ta sẽ cần tạo một thư mục bán kính bên trong openvpn.
Ubuntu / Debian / CentOS / Fedora:

mkdir /etc/openvpn/radius

Ubuntu / Debian / CentOS / Fedora:

cp -r radiusplugin.so /etc/openvpn/radius

2. Tạo tệp cấu hình RADIUSPLUGIN?

Tiếp theo, chúng ta sẽ tạo một tệp mà chúng ta sẽ gọi là radius.cnf bên trong thư mục ‘/ etc / openvpn / radius /’. Đây sẽ là tệp cấu hình radiusplugin bao gồm các chi tiết của máy chủ bán kính của chúng tôi bao gồm địa chỉ ip.
Ubuntu / Debian / CentOS / Fedora:

nano /etc/openvpn/radius/radius.cnf

Và sau đó sao chép các chi tiết dưới đây và dán nó vào tệp.

NAS-Identifier=000.000.000.000_TCP_443

# The service type which is sent to the RADIUS server
Service-Type=5

# The framed protocol which is sent to the RADIUS server
Framed-Protocol=1

# The NAS port type which is sent to the RADIUS server
NAS-Port-Type=5

# The NAS IP address which is sent to the RADIUS server
NAS-IP-Address=000.000.000.000

# Path to the OpenVPN configfile. The plugin searches there for
# client-config-dir PATH   (searches for the path)
# status FILE              (searches for the file, version must be 1)
# client-cert-not-required (if the option is used or not)
# username-as-common-name  (if the option is used or not)

OpenVPNConfig=/etc/openvpn/443_tcp.conf


# Support for topology option in OpenVPN 2.1
# If you don't specify anything, option "net30" (default in OpenVPN) is used. 
# You can only use one of the options at the same time.
# If you use topology option "subnet", fill in the right netmask, e.g. from OpenVPN option "--server NETWORK NETMASK"  
subnet=255.255.255.0
# If you use topology option "p2p", fill in the right network, e.g. from OpenVPN option "--server NETWORK NETMASK"
# p2p=10.8.0.1


# Allows the plugin to overwrite the client config in client config file directory,
# default is true
overwriteccfiles=true

# Allows the plugin to use auth control files if OpenVPN (>= 2.1 rc8) provides them.
# default is false
# useauthcontrolfile=false

# Only the accouting functionality is used, if no user name to forwarded to the plugin, the common name of certificate is used
# as user name for radius accounting.
# default is false
# accountingonly=false


# If the accounting is non essential, nonfatalaccounting can be set to true. 
# If set to true all errors during the accounting procedure are ignored, which can be
# - radius accounting can fail
# - FramedRouted (if configured) maybe not configured correctly
# - errors during vendor specific attributes script execution are ignored
# But if set to true the performance is increased because OpenVPN does not block during the accounting procedure.
# default is false
nonfatalaccounting=false

# Path to a script for vendor specific attributes.
# Leave it out if you don't use an own script.
# vsascript=/root/workspace/radiusplugin_v2.0.5_beta/vsascript.pl

# Path to the pipe for communication with the vsascript.
# Leave it out if you don't use an own script.
# vsanamedpipe=/tmp/vsapipe

# A radius server definition, there could be more than one.
# The priority of the server depends on the order in this file. The first one has the highest priority.
server
{
    # The UDP port for radius accounting.
    acctport=1813
    # The UDP port for radius authentication.
    authport=1812
    # The name or ip address of the radius server.
    name=192.168.0.153
    # How many times should the plugin send the if there is no response?
    retry=1
    # How long should the plugin wait for a response?
    wait=1
    # The shared secret.
    sharedsecret=mysecret
}

Trong đó:
mysecret là bí mật của máy chủ freeradius mà chúng tôi đã định cấu hình trên freeradius. Bạn có thể thay đổi điều này tùy thuộc vào thiết lập freeradius của bạn.
192.168.0.153 là địa chỉ ip của máy chủ bán kính của chúng tôi. Điều này chắc chắn sẽ cần phải được thay đổi.
000.000.000.000 là địa chỉ ip của máy chủ OpenVPN của chúng tôi. Điều này cũng sẽ cần được thay đổi.
/etc/openvpn/443_tcp.conf là đường dẫn đến tệp cấu hình OpenVPN của chúng tôi. Mỗi tệp cấu hình OpenVPN cũng cần tệp cấu hình radiusplugin riêng. Một lần nữa, điều này sẽ được thay đổi tùy thuộc vào thiết lập của bạn.

nếu tất cả những gì khác được thực hiện, hãy lưu tệp và thoát.


3. Cấu hình OPENVPN

port 443
proto tcp
dev tun
server 10.11.0.0 255.255.255.0
ca /etc/openvpn/easy-rsa/keys/ca.crt
cert /etc/openvpn/easy-rsa/keys/server.crt
key / etc / openvpn / easy -rsa / keys / server.key
dh
/etc/openvpn/easy-rsa/keys/dh2048.pem plugin /etc/openvpn/radius/radiusplugin.so /etc/openvpn/radius/radius.cnf ifconfig-pool-Kiên trì ipp .txt Kiên trì-key Kiên
trì-tun
keepalive 10 60 Reneg
-sec 0
comp-lzo
tun-mtu 1468
tun-mtu-extra 32
mssfix 1400
push “Perse-key”
push “Pers-tun”
push “redirect-gateway def1”
push “dhcp-option DNS 8.8.8.8”
push “dhcp-option DNS 8.8.4.4”
status /etc/openvpn/443.log
verb 3

Những gì chúng tôi đã thêm:

plugin /etc/openvpn/radius/radiusplugin.so /etc/openvpn/radius/radius.cnf 

Là đường dẫn đến tệp cấu hình radiusclient và chương trình.

ifconfig-pool-persist ipp.txt  

Là tập tin được đọc bởi radiusplugin để biết thông tin kế toán.

Sau khi tất cả hoàn tất, bạn có thể lưu tệp và thoát. Sau đó, chúng tôi sẽ khởi động lại openvpn để thực hiện các thay đổi.
Ubuntu / Debian / CentOS / Fedora:

service openvpn restart

CentOS 7:

systemctl start openvpn@443_tcp.service

Kết nối từ ứng dụng OpenVPN và đăng nhập bằng thông tin đăng nhập tên người dùng và mật khẩu bán kính của bạn.

Leave a Reply