( kisspepe | 2015. 08. 23., v – 18:55 )

FreeRadius szerver telepítése Ubuntu 14.04.3 LTS-re

Freeradius hitelesítés telepítése Ubuntura. A hitelesítés felhasználónév, jelszó és MAC-Address alapján történik.
A felhasználók egy részét időben korlátozzuk, hogy mikor használhatják a wifi hálózatot (Sajnos ez nem tökéletes, részletesebben lentebb).
A wifiket két részre osztom. A tanárok minden wifire kapcsolódhatnak, a diákok csak a nekik szánt wifikhez.

A konfigurált fájlok teljes tartalmát megosztom. Néhol magyarázattal.

Sajnos a tabulátorokat kiszedte a kódból is, így kicsit rossz a láthatósága.

Köszönöm mindenkinek aki segített!

#***********#
# Telepítés #
#***********#

- Ubuntu telepítése

- fix ip beállítása

- Freeradius 2.x ppa hozzáadása és freeradius 2.2.5 telepítése


sudo add-apt-repository ppa:freeradius/stable
sudo apt-get update
sudo apt-get install freeradius

#**************#
# Konfigurálás #
#**************#

- /etc/freeradius/modules/files
Felvesszük a files diakokat, melynek a usersfile-ja a diákok lesz.


files {
#key = "%{%{Stripped-User-Name}:-%{User-Name}}"

usersfile = ${confdir}/users
acctusersfile = ${confdir}/acct_users
preproxy_usersfile = ${confdir}/preproxy_users

compat = no
}

files diakok {
#key = "%{%{Stripped-User-Name}:-%{User-Name}}"

usersfile = ${confdir}/diakok
acctusersfile = ${confdir}/acct_users
preproxy_usersfile = ${confdir}/preproxy_users

compat = no
}

- /etc/freeradius/sites-available/default
A fájlban a suffix kommentelve lett, nincs rá szükség, más változtatás nincs.


authorize {
# filter_username
preprocess
# auth_log
chap
mschap
digest
# wimax
# IPASS
# suffix
# ntdomain

eap {
ok = return
}

# unix
files
# sql
# smbpasswd
# ldap
# daily
# checkval
expiration
logintime
pap

# Autz-Type Status-Server {
#
# }
}

authenticate {
Auth-Type PAP {
pap
}

Auth-Type CHAP {
chap
}

Auth-Type MS-CHAP {
mschap
}

digest
# pam
unix

# Auth-Type LDAP {
# ldap
# }

eap

# Auth-Type eap {
# eap {
# handled = 1
# }
# if (handled && (Response-Packet-Type == Access-Challenge)) {
# attr_filter.access_challenge.post-auth
# handled # override the "updated" code from attr_filter
# }
# }
}

preacct {
preprocess

# update request {
# FreeRADIUS-Acct-Session-Start-Time = "%{expr: %l - %{%{Acct-Session-Time}:-0} - %{%{Acct-Delay-Time}:-0}}"
# }

acct_unique
# IPASS
# suffix
# ntdomain
files
}

accounting {
detail
# daily
# unix
# radutmp
# sradutmp
# main_pool
# sql

# if (noop) {
# ok
# }

# sql_log
# pgsql-voip
exec
attr_filter.accounting_response

# Acct-Type Status-Server {
#
# }
}

session {
radutmp
# sql
}

post-auth {
# main_pool
# reply_log
# sql
# sql_log
# ldap
exec
# wimax

# update reply {
# Reply-Message += "%{TLS-Cert-Serial}"
# Reply-Message += "%{TLS-Cert-Expiration}"
# Reply-Message += "%{TLS-Cert-Subject}"
# Reply-Message += "%{TLS-Cert-Issuer}"
# Reply-Message += "%{TLS-Cert-Common-Name}"
# Reply-Message += "%{TLS-Cert-Subject-Alt-Name-Email}"
#
# Reply-Message += "%{TLS-Client-Cert-Serial}"
# Reply-Message += "%{TLS-Client-Cert-Expiration}"
# Reply-Message += "%{TLS-Client-Cert-Subject}"
# Reply-Message += "%{TLS-Client-Cert-Issuer}"
# Reply-Message += "%{TLS-Client-Cert-Common-Name}"
# Reply-Message += "%{TLS-Client-Cert-Subject-Alt-Name-Email}"
# }

# if (reply:EAP-Session-Id) {
# update reply {
# EAP-Key-Name := "%{reply:EAP-Session-Id}"
# }
# }

Post-Auth-Type REJECT {
# sql
attr_filter.access_reject
}
}

pre-proxy {
# attr_rewrite
# files
# attr_filter.pre-proxy
# pre_proxy_log
}

post-proxy {
# post_proxy_log
# attr_rewrite
# attr_filter.post-proxy
eap

# Post-Proxy-Type Fail {
# detail
# }
}

- /etc/freeradius/sites-available/diakok
Létrehozzuk a diakok fájlt a default másolatával. Majd a fájl teljes tartalmát beletesszük a server diakok {...} alá.
A fájlban a files elé beírjuk a diakok-at. Így a users és a diakok fájlból is hitelesíteni fog.


server diakok {
authorize {
# filter_username
preprocess
# auth_log
chap
mschap
digest
# wimax
# IPASS
# suffix
# ntdomain

eap {
ok = return
}

# unix
diakok
files
# sql
# smbpasswd
# ldap
# daily
# checkval
expiration
logintime
pap

# Autz-Type Status-Server {
#
# }
}

authenticate {
Auth-Type PAP {
pap
}

Auth-Type CHAP {
chap
}

Auth-Type MS-CHAP {
mschap
}

digest
# pam
unix

# Auth-Type LDAP {
# ldap
# }

eap

# Auth-Type eap {
# eap {
# handled = 1
# }
# if (handled && (Response-Packet-Type == Access-Challenge)) {
# attr_filter.access_challenge.post-auth
# handled # override the "updated" code from attr_filter
# }
# }
}

preacct {
preprocess

# update request {
# FreeRADIUS-Acct-Session-Start-Time = "%{expr: %l - %{%{Acct-Session-Time}:-0} - %{%{Acct-Delay-Time}:-0}}"
# }

acct_unique
# IPASS
# suffix
# ntdomain
diakok
files
}

accounting {
detail
# daily
# unix
# radutmp
# sradutmp
# main_pool
# sql

# if (noop) {
# ok
# }

# sql_log
# pgsql-voip
exec
attr_filter.accounting_response

# Acct-Type Status-Server {
#
# }
}

session {
radutmp
# sql
}

post-auth {
# main_pool
# reply_log
# sql
# sql_log
# ldap
exec
# wimax

# update reply {
# Reply-Message += "%{TLS-Cert-Serial}"
# Reply-Message += "%{TLS-Cert-Expiration}"
# Reply-Message += "%{TLS-Cert-Subject}"
# Reply-Message += "%{TLS-Cert-Issuer}"
# Reply-Message += "%{TLS-Cert-Common-Name}"
# Reply-Message += "%{TLS-Cert-Subject-Alt-Name-Email}"
#
# Reply-Message += "%{TLS-Client-Cert-Serial}"
# Reply-Message += "%{TLS-Client-Cert-Expiration}"
# Reply-Message += "%{TLS-Client-Cert-Subject}"
# Reply-Message += "%{TLS-Client-Cert-Issuer}"
# Reply-Message += "%{TLS-Client-Cert-Common-Name}"
# Reply-Message += "%{TLS-Client-Cert-Subject-Alt-Name-Email}"
# }

# if (reply:EAP-Session-Id) {
# update reply {
# EAP-Key-Name := "%{reply:EAP-Session-Id}"
# }
# }

Post-Auth-Type REJECT {
# sql
attr_filter.access_reject
}
}

pre-proxy {
# attr_rewrite
# diakok
# files
# attr_filter.pre-proxy
# pre_proxy_log
}

post-proxy {
# post_proxy_log
# attr_rewrite
# attr_filter.post-proxy
eap

# Post-Proxy-Type Fail {
# detail
# }
}
}

- /etc/freeradius/sites-enabled/
A mappában a sites-available mappa default és diákok
fájljáról legyen szimbolikus link.

- /etc/freeradius/radiusd.conf
A listen részben beállítottuk a portokat
Valamint a log részben beállítottuk, hogy loggolja a
jó és rossz felhasználóhitelesítést.


prefix = /usr
exec_prefix = /usr
sysconfdir = /etc
localstatedir = /var
sbindir = ${exec_prefix}/sbin
logdir = /var/log/freeradius
raddbdir = /etc/freeradius
radacctdir = ${logdir}/radacct

name = freeradius

confdir = ${raddbdir}
run_dir = ${localstatedir}/run/${name}

db_dir = ${raddbdir}
libdir = /usr/lib/freeradius
pidfile = ${run_dir}/${name}.pid

user = freerad
group = freerad

max_request_time = 30
cleanup_delay = 5
max_requests = 1024

listen {
type = auth
ipaddr = *
port = 1812
# interface = eth0
}

listen {
ipaddr = *
port = 1813
type = acct
# interface = eth0
}

hostname_lookups = no
allow_core_dumps = no
regular_expressions = yes
extended_expressions = yes

log {
destination = files
file = ${logdir}/radius.log
syslog_facility = daemon
stripped_names = no
auth = yes
auth_badpass = yes
auth_goodpass = yes
# msg_goodpass = ""
# msg_badpass = ""
}

checkrad = ${sbindir}/checkrad

security {
max_attributes = 200
reject_delay = 1
status_server = yes
allow_vulnerable_openssl = yes
}

proxy_requests = yes

$INCLUDE proxy.conf
$INCLUDE clients.conf

thread pool {
start_servers = 5
max_servers = 32
min_spare_servers = 3
max_spare_servers = 10
# max_queue_size = 65536
max_requests_per_server = 0
}

modules {
$INCLUDE ${confdir}/mods-enabled/
$INCLUDE eap.conf
# $INCLUDE sql.conf
# $INCLUDE sql/mysql/counter.conf
# $INCLUDE sqlippool.conf
}

instantiate {
exec
expr
# daily
expiration
logintime
}

$INCLUDE policy.conf
$INCLUDE sites-enabled/

- /etc/freeradius/eap.conf
Itt pár dolgot változtatni kell. Az elején a default_eap_type = peap, a ttls szekcióban pedig mschapv2.
A copy_request_to_tunel és use_tunneled_reply mind a két helyen enabled, valamint a ttls és peap szekcióban kommentbe tesszük a virtual_server = "inner-tunnel"-t.


eap {
default_eap_type = peap
timer_expire = 60
ignore_unknown_eap_types = no
cisco_accounting_username_bug = no
max_sessions = ${max_requests}

md5 {
}

leap {
}

gtc {
#challenge = "Password: "
auth_type = PAP
}

tls {
certdir = ${confdir}/certs
cadir = ${confdir}/certs
private_key_password = whatever
private_key_file = ${certdir}/server.key
certificate_file = ${certdir}/server.pem
CA_file = ${cadir}/ca.pem
dh_file = ${certdir}/dh
random_file = /dev/urandom
# fragment_size = 1024
# include_length = yes
# check_crl = yes
CA_path = ${cadir}
# check_cert_issuer = "/C=GB/ST=Berkshire/L=Newbury/O=My Company Ltd"
# check_cert_cn = %{User-Name}
cipher_list = "DEFAULT"
# virtual_server = check-eap-tls
make_cert_command = "${certdir}/bootstrap"
ecdh_curve = "prime256v1"

cache {
enable = no
lifetime = 24 # hours
max_entries = 255
}

verify {
# tmpdir = /tmp/radiusd

# client = "/path/to/openssl verify -CApath ${..CA_path} %{TLS-Client-Cert-Filename}"
}

ocsp {
enable = no
override_cert_url = yes
url = "http://127.0.0.1/ocsp/"
# use_nonce = yes
# timeout = 0
# softfail = no
}
}

ttls {
default_eap_type = mschapv2
copy_request_to_tunnel = yes
use_tunneled_reply = yes
# virtual_server = "inner-tunnel"
# include_length = yes
}

peap {
default_eap_type = mschapv2
copy_request_to_tunnel = yes
use_tunneled_reply = yes
# proxy_tunneled_request_as_eap = yes
# virtual_server = "inner-tunnel"
# soh = yes
# soh_virtual_server = "soh-server"
}

mschapv2 {
# send_error = no
}
}

- /etc/freeradius/clients.conf
A Teszt a users fájlt használja hitelesítéshez.
A Teszt2 a diakok és users fájlt használja hitelesítéshez.


client "Teszt" {
ipaddr = 192.168.1.99
secret = jelszó
max_connections = 120
shortname = Teszt
nastype = other
}

client "Teszt2" {
ipaddr = 192.168.1.1
secret = jelszó
max_connections = 120
shortname = Teszt2
nastype = other
virtual_server = diakok
}

- /etc/freeradius/users
A felhasználó felvételének formája:
"felhasználónév" Cleartext-Password := "jelszó", Calling-Station-Id == "MAC-Address"
Amennyiben egy felhasználónak több eszköze van, vegyük fel ugyan azzal a felhasználónév jelszó párossal és különböző MAC-Address-el.
A MAC-Address-t nagy betűvel és kötőjellel kell felvenni.


"kisspepe" Cleartext-Password := "jelszó", Calling-Station-Id == "34-23-BA-B5-81-47"

"kisspepe" Cleartext-Password := "jelszó", Calling-Station-Id == "34-51-C9-45-7D-3C"

- /etc/freeradius/diakok
A felhasználó felvételének formája:
"felhasználónév" Cleartext-Password := "jelszó", Calling-Station-Id == "MAC-Address", Login-Time := "Időpont amikor bejelentkezhet"
A bejelentkezési idő megadása:
Wk - weekdays hétfőtől-péntekig
Napok: Mo,Tu,We,Th,Fr,Sa,Su
Időpont megadás:
"Wk0800-1200" - Hétfőtől - Péntekig 8-12-ig
"Sa,Su1300-1400" - Szombaton és Vasárnap 13-14-ig
"Mo0600-0700,Mo1300-1400" - Hétfőn 6-7-ig és 13-14-ig

Bejelentkezési idő hátránya: Az az eszköz ami csatlakozva van, csatlakozva is marad. Ha véletlenül lecsatlakozna a wifiről, utána már nem tud visszamenni, amíg nem engedélyezett. Így lényegében aki a wifi közelében van, és az eszköze állandóan csatlakozik, arra nincs hatással az időpont.


"kisspepe" Cleartext-Password := "jelszó", Calling-Station-Id == "34-23-BA-B5-81-47", Login-Time := "Wk0600-0700,Wk1400-2200,Sa,Su0000-2359"

#***************************#
# Windows 7 csatlakoztatása #
#***************************#

- Hálózati és megosztási központ megnyitása
- Vezeték nélküli hálózatok kezelése
- Hozzáadás -> Hálózati profil kézi hozzáadása
- Hálózat neve: A wifi neve melyre csatlakozni szeretnénk.
Biztonság típusa: WPA2-Enterprise
Titkosítás típusa: AES
Kapcsolat indítása automatikusan kipipálva.
Tovább
- Kapcsolat beállításainak módosítása
- Biztonság fül:
Válassza ki a hálózati hitelesítés módszerét: Microsoft: Védett EAP (PEAP)
-> Beállítások
Kiszolgáló tanúsítvány érvényesítése: kivenni a pipát
Hitelesítési mód: Biztonságos jelszó (EAP-MSCHAP v2)
-> Konfigurálás
A Windows bejelentkezési nevem és jelszavam automatikus használata: kivenni a pipát.
Ok
Ok
-> Speciális beállítások:
Hitelesítési mód megadása: kipipálni
Legördülő lista: Felhasználó- vagy számítógép-hitelesítéshez
Ok
Ok
Bezárás
-