> For the complete documentation index, see [llms.txt](https://ajuda.rnp.br/eduroam/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ajuda.rnp.br/eduroam/manual-do-administrador/instalacao-manual/ubuntu-22.04-com-freeradius-3.2.4.md).

# Ubuntu 22.04 com Freeradius 3.2.4

INSTALANDO O IDP NA INSTITUIÇÃO CLIENTE

## Freeradius <a href="#instalar-freeradius-1" id="instalar-freeradius-1"></a>

### **Instalando FreeRADIUS 3.2.4 no Ubuntu Jammy 22.04.4 LTS**

Adicione a [chave pública NetworkRADIUS PGP](https://packages.networkradius.com/pgp/packages%40networkradius.com) :\
&#x20;

```
install -d -o root -g root -m 0755 /etc/apt/keyrings
curl -s 'https://packages.networkradius.com/pgp/packages%40networkradius.com' | \
    sudo tee /etc/apt/keyrings/packages.networkradius.com.asc > /dev/null 
```

\
&#x20;

Adicione um arquivo de preferências APT para garantir que todos os pacotes freeradius sejam instalados do repositório Network RADIUS:

```
printf 'Package: /freeradius/\nPin: origin "packages.networkradius.com"\nPin-Priority: 999\n' | \
    sudo tee /etc/apt/preferences.d/networkradius > /dev/null
```

&#x20;

Adicione a lista de fontes do APT:

```
echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/packages.networkradius.com.asc] http://packages.networkradius.com/freeradius-3.2/ubuntu/jammy jammy main" | \
    sudo tee /etc/apt/sources.list.d/networkradius.list > /dev/null
```

&#x20;

Por fim, atualize o banco de dados APT e instale os pacotes:

```
sudo apt-get update
sudo apt-get install freeradius
```

Comandos úteis:\
systemctl status  freeradius.service\
systemctl start  freeradius.service\
systemctl stop freeradius.service\
\
Rodar o Freeradius em modo de debug no nível máximo:\
systemctl stop freeradius.service\
freeradius -fxxxxx  -lstdout\
systemctl start  freeradius.service\
\
Verificar se as configurações do Freeradius estão OK:\
freeradius -CX

### Configurando o Freeradius <a href="#configurando-o-freeradius-1" id="configurando-o-freeradius-1"></a>

#### clients.conf

vim /etc/freeradius/clients.conf

```
# Este bloco libera a consulta em localhost
client localhost {
       ipaddr = 127.0.0.1
       proto = *
       secret = radsec
       require_message_authenticator = no
       shortname = localhost
       nas_type         = other        # localhost isn't usually a NAS...
       limit {
               max_connections = 16
               lifetime = 0
               idle_timeout = 30
       }
}
# Este bloco libera a consulta em localhost usando IPv6
client localhost_ipv6 {
       ipv6addr        = ::1
       secret          = radsec
}
# IP da controladora da sua instituicao
client 200.130.66.29 {
       ipaddr = 200.130.66.29
       shortname = Campus_Campinas
       secret = radsec
       require_message_authenticator = no
       nastype     = other
       }

```

\#&#x20;

## proxy.conf

vim /etc/freeradius/proxy.conf<br>

```
proxy server {
       default_fallback = no
}
home_server localhost {
       type = auth
       ipaddr = 127.0.0.1
       port = 1812
       secret = radsec
       response_window = 20
       zombie_period = 40
       revive_interval = 120
       status_check = status-server
       check_interval = 30
       check_timeout = 4
       num_answers_to_alive = 3
       max_outstanding = 65536
       coa {
               irt = 2
               mrt = 16
               mrc = 5
               mrd = 30
       }
       limit {
             max_connections = 16
             max_requests = 0
             lifetime = 0
             idle_timeout = 0
       }
}
 
home_server_pool my_localhost {
       type            = fail-over
       home_server     = localhost
}

realm DEFAULT {
}
realm LOCAL {
}

realm NULL {
       secret          = radsec
}

# Expressao para subdominios de sua instituicao
realm "~(.*\.)*sua_instituicao.br$" {
       auth_pool       = my_localhost
       secret          = radsec
}
```

\
&#x20;

### Configurando o arquivo default <a href="#configurando-o-arquivo-default" id="configurando-o-arquivo-default"></a>

vim /etc/freeradius/sites-enabled/default

```
server default {
listen {
       type = auth
       ipaddr = *
       port = 0
       limit {
             max_connections = 16
             lifetime = 0
             idle_timeout = 30
       }
}
listen {
       ipaddr = *
       port = 0
       type = acct
       limit {
       }
}
listen {
       type = auth
       ipv6addr = ::   # any.  ::1 == localhost
       port = 0
       limit {
             max_connections = 16
             lifetime = 0
             idle_timeout = 30
       }
}
listen {
       ipv6addr = ::
       port = 0
       type = acct
       limit {
       }
}
authorize {
       filter_username
       preprocess
       chap
       mschap
       digest
       suffix
               
       # Expressao para subdominios
       if ( Realm =~ /sua_instituicao.br/i ) {
                    update control {
                   &Proxy-To-Realm := LOCAL
                }
       }
       
       eap {
               ok = return
       }
       files
       -sql
       -ldap
       expiration
       logintime
       pap
}
authenticate {
       Auth-Type PAP {
               pap
       }
       Auth-Type CHAP {
               chap
       }
       Auth-Type MS-CHAP {
               mschap
       }
       mschap
       digest
       eap
}
preacct {
       preprocess
       acct_unique
       files
}
accounting {
       linelog
       detail
       unix
       #radutmp
       -sql
       exec
       attr_filter.accounting_response
       log_accounting
}
post-auth {
       update {
         &reply: += &session-state:
       }
       -sql
       -ldap
       exec
       remove_reply_message_if_eap
       Post-Auth-Type REJECT {
               -sql
               attr_filter.access_reject
               eap
               remove_reply_message_if_eap
       }
}
pre-proxy {
       update proxy-request {
           Operator-Name = "1sua_instituicao.br"
           Eduroam-SP-Country = "BR"
       }
}
post-proxy {
       eap
}
}
```

### Configurando o arquivo inner-tunnel <a href="#configurando-o-arquivo-default-1" id="configurando-o-arquivo-default-1"></a>

```
vim /etc/freeradius/sites-enabled/inner-tunnel
```

```
server inner-tunnel {
listen {
       type = auth
       ipaddr = *
       port = 18120
       limit {
             max_connections = 16
             lifetime = 0
             idle_timeout = 30
       }
}
authorize {
       filter_username
       preprocess
       chap
       mschap
       digest
       suffix
       # Expressao para subdominios
       if ( Realm =~ /sua_instituicao/i ) {
                
                update control {
                   &Proxy-To-Realm := LOCAL
                }
       }
       
       eap {
               ok = return
       }
       files
       -sql
       -ldap
       expiration
       logintime
       pap
}
authenticate {
       Auth-Type PAP {
               pap
       }
       Auth-Type CHAP {
               chap
       }
       Auth-Type MS-CHAP {
               mschap
       }
       mschap
       digest
       eap
}
preacct {
       preprocess
       acct_unique
       files
}
accounting {
       detail
       unix
       -sql
       exec
       attr_filter.accounting_response
}
session {
}
post-auth {
       update {
               &reply: += &session-state:
       }
       -sql
       -ldap
       exec
       remove_reply_message_if_eap
       Post-Auth-Type REJECT {
               -sql
               attr_filter.access_reject
               eap
               remove_reply_message_if_eap
       }
}
pre-proxy {
       update proxy-request {
           Operator-Name = "1sua_instituicao.br"
           Eduroam-SP-Country = "BR"
       }

}
post-proxy {
       eap
}
}
```

\
&#x20;

### Configurando o arquivo radsec <a href="#configurando-o-arquivo-radsec" id="configurando-o-arquivo-radsec"></a>

vim  /etc/freeradius/sites-enabled/radsec

```
listen {
   ipaddr = *
   port = 2083
   type = auth
   proto = tcp
   virtual_server = default
   clients = radsec
       limit {
             max_connections = 0
             lifetime = 0
             idle_timeout = 3600
             }
   tls {
       certdir = ${confdir}/certs       
       cadir = ${confdir}/certs
       private_key_password = whatever
       private_key_file = ${certdir}/server.pem
       certificate_file = ${certdir}/server.pem
       ca_file = ${cadir}/ca.pem
       dh_file = ${certdir}/dh
       random_file = /dev/urandom
       fragment_size = 8192
        ca_path = ${cadir}
         include_length = yes
        cipher_list = "DEFAULT"
         cipher_server_preference = no
         tls_min_version = "1.2"
         tls_max_version = "1.3"
         ecdh_curve = ""
       cache {
             enable = yes
             lifetime = 24 # hours           
       }
       require_client_cert = yes
       verify {
       }
   }
}
 
listen {
   ipv6addr = ::
   port = 2083
   type = auth
   proto = tcp
   clients = radsec
   limit {
             max_connections = 0
             lifetime = 0
             idle_timeout = 600
       }
   tls {
       certdir = ${confdir}/certs
       cadir = ${confdir}/certs
       private_key_password = whatever
       private_key_file = ${certdir}/server.pem
       certificate_file = ${certdir}/server.pem
       ca_file = ${cadir}/ca.pem
       dh_file = ${certdir}/dh
       random_file = /dev/urandom
       
      fragment_size = 8192
        ca_path = ${cadir}
         include_length = yes
        cipher_list = "DEFAULT"
         cipher_server_preference = no
         tls_min_version = "1.2"
         tls_max_version = "1.3"
         ecdh_curve = ""
       cache {
             enable = yes
             max_entries = 255
       }
       require_client_cert = yes
       verify {
       }
   }
}
 
clients radsec {
   limit {
             max_connections = 0
             lifetime = 0
             idle_timeout = 3600
       }
   client 127.0.0.1 {
       ipaddr = 127.0.0.1
       proto = tls
       secret = radsec
   }
      client rps01 {
       ipaddr = rps01.eduroam.org.br
       proto = tls
       secret = radsec
       limit {
             max_connections = 0
             lifetime = 0
             idle_timeout = 3600
       }
   }
   client rps02 {
       ipaddr = rps02.eduroam.org.br
       proto = tls
       secret = radsec
       limit {
             max_connections = 0
             lifetime = 0
             idle_timeout = 3600
       }
   }
       
}
 
# local test listener for debug (present by default)
listen {
      ipaddr = 127.0.0.1
      port = 4000
      type = auth
}
home_server rps01 {
   ipaddr = rps01.eduroam.org.br
   port = 2083
   type = auth
   secret = radsec
   proto = tcp
   status_check = none
   tls {
       certdir = ${confdir}/certs
       cadir = ${confdir}/certs
       private_key_password = whatever
       private_key_file = ${certdir}/server.pem
       certificate_file = ${certdir}/server.pem
       ca_file = ${cadir}/ca.pem
       dh_file = ${certdir}/dh
       random_file = /dev/urandom
       
      fragment_size = 8192
        ca_path = ${cadir}
         include_length = yes
        cipher_list = "DEFAULT"
         cipher_server_preference = no
         tls_min_version = "1.2"
         tls_max_version = "1.3"
         ecdh_curve = ""
   }
}
 
home_server rps02 {
   ipaddr = rps02.eduroam.org.br
   port = 2083
   type = auth
   secret = radsec
   proto = tcp
   status_check = none
   tls {
       certdir = ${confdir}/certs
       cadir = ${confdir}/certs
       private_key_password = whatever
       private_key_file = ${certdir}/server.pem
       certificate_file = ${certdir}/server.pem
       ca_file = ${cadir}/ca.pem
       dh_file = ${certdir}/dh
       random_file = /dev/urandom
       
      fragment_size = 8192
        ca_path = ${cadir}
         include_length = yes
        cipher_list = "DEFAULT"
         cipher_server_preference = no
         tls_min_version = "1.2"
         tls_max_version = "1.3"
         ecdh_curve = ""
   }
}
 
home_server_pool BR {
        type = fail-over
        home_server = rps01
        home_server = rps02
}

realm "~.+$" {
      auth_pool = BR
      nostrip
}
 
```

### configurando o arquivo eap <a href="#configurando-o-arquivo-eap" id="configurando-o-arquivo-eap"></a>

vim /etc/freeradius/mods-enabled/eap

```
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 {
               auth_type = PAP
       }
       tls-config tls-common {
               cipher_server_preference = yes
               require_client_cert = yes
               
               private_key_password = whatever
               private_key_file = ${certdir}/server.pem
               certificate_file = ${certdir}/server.pem
               ca_file = ${cadir}/ca.pem
               cipher_list = "DEFAULT"
                cipher_server_preference = no
                tls_min_version = "1.2"
                tls_max_version = “1.2”
               ecdh_curve = ""
               cache {
                       enable = no
                       lifetime = 24 # hours
               }
               verify {
               }
               ocsp {
                       enable = no
                       override_cert_url = yes
                       url = "http://127.0.0.1/ocsp/"
               }
       }
       tls {
               tls = tls-common
       }
       ttls {
               tls = tls-common
               default_eap_type = mschapv2
               copy_request_to_tunnel = yes
               use_tunneled_reply = yes
               virtual_server = "inner-tunnel"
       }
       peap {
               tls = tls-common
               default_eap_type = mschapv2
               copy_request_to_tunnel = yes
               use_tunneled_reply = yes
               virtual_server = "inner-tunnel"
       }
        mschapv2 {
       }
}


```

vim /etc/freeradius/mods-enabled/eap

cd /etc/freeradius/certs

openssl dhparam -out dh -2 2048

cp seu\_certificado\_recebito\_da\_rnp.crt    /etc/freeradius/certs/server.pem

cat seu\_certificado\_recebito\_da\_rnp.key    /etc/freeradius/certs/server.pem

&#x20;cat rnp-ca.crt  /etc/freeradius/certs/ca.pem

#### &#x20;Agora precisamos configurar se o servidor da instituição vai se conectar com a base LDAP ou com o AD.  Configurando o servidor para autenticar os usuários no LDAP <a href="#agora-precisamos-configurar-se-o-servidor-da-instituicao-vai-se-conectar-com-a-base-ldap-ou-com-o-a" id="agora-precisamos-configurar-se-o-servidor-da-instituicao-vai-se-conectar-com-a-base-ldap-ou-com-o-a"></a>

vim /etc/freeradius/mods-available/ldap

\# -\*- text -\*-\
\#\
\#  $Id: 015ae6907b8113771691ae3a3c1d53b05756d143 $

\#\
\#  Lightweight Directory Access Protocol (LDAP)\
\#\
ldap {\
&#x20;      \#  Note that this needs to match the name(s) in the LDAP server\
&#x20;      \#  certificate, if you're using ldaps.  See OpenLDAP documentation\
&#x20;      \#  for the behavioral semantics of specifying more than one host.\
&#x20;      \#\
&#x20;      \#  Depending on the libldap in use, server may be an LDAP URI.\
&#x20;      \#  In the case of OpenLDAP this allows additional the following\
&#x20;      \#  additional schemes:\
&#x20;      \#  - ldaps\:// (LDAP over SSL)\
&#x20;      \#  - ldapi:// (LDAP over Unix socket)\
&#x20;      \#  - ldapc:// (Connectionless LDAP)\
&#x20;      **server** = 'IP\_ou\_nome\_do\_seu\_servidor\_ldap'

&#x20;      \#  Port to connect on, defaults to 389, will be ignored for LDAP URIs.\
&#x20;      **port** = 389

&#x20;      \#  Administrator account for searching and possibly modifying.\
&#x20;      \#  If using SASL + KRB5 these should be commented out.\
&#x20;      **identity** = 'uid=app.idpeduroam.r,ou=APLICACOES,dc=dominio,dc=local'\
&#x20;      **password** = Xlhtuop0

&#x20;      \#  Unless overridden in another section, the dn from which all\
&#x20;      \#  searches will start from.\
&#x20;      **base\_dn** = 'dc=seu\_dominio,dc=local'

&#x20;      \#\
&#x20;      \#  You can run the 'ldapsearch' command line tool using the\
&#x20;      \#  parameters from this module's configuration.\
&#x20;      \#\
&#x20;      \#    ldapsearch -D ${identity} -w ${password} -h ${server}  -b 'CN=user,${base\_dn}'\
&#x20;      \#\
&#x20;      \#  That will give you the LDAP information for 'user'.\
&#x20;      \#\
&#x20;      \#  Group membership can be queried by using the above "ldapsearch" string,\
&#x20;      \#  and adding "memberof" qualifiers.  For ActiveDirectory, use:\
&#x20;      \#\
&#x20;      \#    ldapsearch ... '(&(objectClass=user)(sAMAccountName=user)(memberof=CN=group,${base\_dn}))'\
&#x20;      \#\
&#x20;      \#  Where 'user' is the user as above, and 'group' is the group you are querying for.\
&#x20;      \#

&#x20;      \#\
&#x20;      \#  SASL parameters to use for admin binds\
&#x20;      \#\
&#x20;      \#  When we're prompted by the SASL library, these control\
&#x20;      \#  the responses given, as well as the identity and password\
&#x20;      \#  directives above.\
&#x20;      \#\
&#x20;      \#  If any directive is commented out, a NULL response will be\
&#x20;      \#  provided to cyrus-sasl.\
&#x20;      \#\
&#x20;      \#  Unfortunately the only way to control Keberos here is through\
&#x20;      \#  environmental variables, as cyrus-sasl provides no API to\
&#x20;      \#  set the krb5 config directly.\
&#x20;      \#\
&#x20;      \#  Full documentation for MIT krb5 can be found here:\
&#x20;      \#\
&#x20;      \#       <http://web.mit.edu/kerberos/krb5-devel/doc/admin/env\\_variables.html\\>
&#x20;      \#\
&#x20;      \#  At a minimum you probably want to set KRB5\_CLIENT\_KTNAME.\
&#x20;      \#\
&#x20;      sasl {\
&#x20;              \# SASL mechanism\
\#               mech = 'PLAIN'

&#x20;              \# SASL authorisation identity to proxy.\
\#               proxy = 'autz\_id'

&#x20;              \# SASL realm. Used for kerberos.\
\#               realm = 'example.org'\
&#x20;      }

&#x20;      \#\
&#x20;      \#  Generic valuepair attribute\
&#x20;      \#

&#x20;      \#  If set, this will attribute will be retrieved in addition to any\
&#x20;      \#  mapped attributes.\
&#x20;      \#\
&#x20;      \#  Values should be in the format:\
&#x20;      \#       \<radius attr> \<op> \<value>\
&#x20;      \#\
&#x20;      \#  Where:\
&#x20;      \#       \<radius attr>:  Is the attribute you wish to create\
&#x20;      \#                       with any valid list and request qualifiers.\
&#x20;      \#       \<op>:           Is any assignment operator (=, :=, +=, -=).\
&#x20;      \#       \<value>:        Is the value to parse into the new valuepair.\
&#x20;      \#                       If the value is wrapped in double quotes it\
&#x20;      \#                       will be xlat expanded.\
\#       valuepair\_attribute = 'radiusAttribute'

&#x20;      \#\
&#x20;      \#  Mapping of LDAP directory attributes to RADIUS dictionary attributes.\
&#x20;      \#

&#x20;      \#  WARNING: Although this format is almost identical to the unlang\
&#x20;      \#  update section format, it does \*NOT\* mean that you can use other\
&#x20;      \#  unlang constructs in module configuration files.\
&#x20;      \#\
&#x20;      \#  Configuration items are in the format:\
&#x20;      \#       \<radius attr> \<op> \<ldap attr>\
&#x20;      \#\
&#x20;      \#  Where:\
&#x20;      \#       \<radius attr>:  Is the destination RADIUS attribute\
&#x20;      \#                       with any valid list and request qualifiers.\
&#x20;      \#       \<op>:           Is any assignment attribute (=, :=, +=, -=).\
&#x20;      \#       \<ldap attr>:    Is the attribute associated with user or\
&#x20;      \#                       profile objects in the LDAP directory.\
&#x20;      \#                       If the attribute name is wrapped in double\
&#x20;      \#                       quotes it will be xlat expanded.\
&#x20;      \#\
&#x20;      \#  Request and list qualifiers may also be placed after the 'update'\
&#x20;      \#  section name to set defaults destination requests/lists\
&#x20;      \#  for unqualified RADIUS attributes.\
&#x20;      \#\
&#x20;      \#  Note: LDAP attribute names should be single quoted unless you want\
&#x20;      \#  the name value to be derived from an xlat expansion, or an\
&#x20;      \#  attribute ref.\
&#x20;      update {\
&#x20;              control:Password-With-Header    += 'userPassword'\
\#               control:NT-Password             := 'ntPassword'\
&#x20;             control:NT-Password             := 'sambaNTPassword'\
&#x20;             reply:Reply-Message             := 'radiusReplyMessage'\
&#x20;             reply:Tunnel-Type               := 'radiusTunnelType'\
&#x20;             reply:Tunnel-Medium-Type        := 'radiusTunnelMediumType'\
&#x20;             reply:Tunnel-Private-Group-ID   := 'radiusTunnelPrivategroupId'

&#x20;              \#  Where only a list is specified as the RADIUS attribute,\
&#x20;              \#  the value of the LDAP attribute is parsed as a valuepair\
&#x20;              \#  in the same format as the 'valuepair\_attribute' (above).\
&#x20;              control:                        += 'radiusControlAttribute'\
&#x20;              request:                        += 'radiusRequestAttribute'\
&#x20;              reply:                          += 'radiusReplyAttribute'\
&#x20;      }

&#x20;      \#  Set to yes if you have eDirectory and want to use the universal\
&#x20;      \#  password mechanism.\
\#       edir = no

&#x20;      \#  Set to yes if you want to bind as the user after retrieving the\
&#x20;      \#  Cleartext-Password. This will consume the login grace, and\
&#x20;      \#  verify user authorization.\
\#       edir\_autz = no

&#x20;      \#  Note: set\_auth\_type was removed in v3.x.x\
&#x20;      \#\
&#x20;      \#  Equivalent functionality can be achieved by adding the\
&#x20;      \#  following "if" statement to the authorize {} section of\
&#x20;      \#  the virtual server, after the "ldap" module.  For example:\
&#x20;      \#\
&#x20;      \#    ...\
&#x20;      \#    ldap\
&#x20;      \#    if ((ok || updated) && User-Password && !control:Auth-Type) {\
&#x20;      \#        update {\
&#x20;      \#            control:Auth-Type := ldap\
&#x20;      \#        }\
&#x20;      \#    }\
&#x20;      \#    ...\
&#x20;      \#\
&#x20;      \#  You will also need to uncomment the "Auth-Type LDAP" block in the\
&#x20;      \#  "authenticate" section.\
&#x20;      \#

&#x20;      \#\
&#x20;      \#  Name of the attribute that contains the user DN.\
&#x20;      \#  The default name is LDAP-UserDn.\
&#x20;      \#\
&#x20;      \#  If you have multiple LDAP instances, you should\
&#x20;      \#\
&#x20;      \#       ${.:instance}-LDAP-UserDn\
&#x20;      \#\
&#x20;      \#  That change allows the modules to set their own\
&#x20;      \#  User DN, and to not conflict with each other.\
&#x20;      \#\
&#x20;      user\_dn = "LDAP-UserDn"

&#x20;      \#\
&#x20;      \#  User object identification.\
&#x20;      \#\
&#x20;      user {\
&#x20;              \#  Where to start searching in the tree for users\
&#x20;              base\_dn = "${..base\_dn}"

&#x20;              \#  Filter for user objects, should be specific enough\
&#x20;              \#  to identify a single user object.\
&#x20;              \#\
&#x20;              \#  For Active Directory, you should use\
&#x20;              \#  "samaccountname=" instead of "uid="\
&#x20;              \#\
&#x20;              \# filter = "(sAMAccountName=%{%{Stripped-User-Name}:-%{User-Name}})"\
&#x20;              \# filter = "(uid=%{%{Stripped-User-Name}:-%{User-Name}})"

&#x20;              \# Exemplo abaixo para instituicao utilizando OR para autenticar somente pelo uid ou pelo email\
&#x20;              \# filter = "(|(uid=%{%{Stripped-User-Name}:-%{User-Name}})(mail=%{User-Name}))"\
&#x20;              \#\
&#x20;              filter = "(mail=%{User-Name})"

&#x20;              \#  For Active Directory nested group, you should comment out the previous 'filter = ...'\
&#x20;              \#  and use the below. Where 'group' is the group you are querying for.\
&#x20;              \#\
&#x20;              \#  NOTE: The string '1.2.840.113556.1.4.1941' specifies LDAP\_MATCHING\_RULE\_IN\_CHAIN.\
&#x20;              \#  This applies only to DN attributes. This is an extended match operator that walks\
&#x20;              \#  the chain of ancestry in objects all the way to the root until it finds a match.\
&#x20;              \#  This reveals group nesting. It is available only on domain controllers with\
&#x20;              \#  Windows Server 2003 SP2 or Windows Server 2008 (or above).\
&#x20;              \#\
&#x20;              \#  See: <https://social.technet.microsoft.com/wiki/contents/articles/5392.active-directory-ldap-syntax-filters.aspx\\>
&#x20;              \#\
\#               filter = "(&(objectClass=user)(sAMAccountName=%{%{Stripped-User-Name}:-%{User-Name}})(memberOf:1.2.840.113556.1.4.1941:=cn=group,${..base\_dn}))"

&#x20;              \#  SASL parameters to use for user binds\
&#x20;              \#\
&#x20;              \#  When we're prompted by the SASL library, these control\
&#x20;              \#  the responses given.\
&#x20;              \#\
&#x20;              \#  Any of the config items below may be an attribute ref\
&#x20;              \#  or and expansion, so different SASL mechs, proxy IDs\
&#x20;              \#  and realms may be used for different users.\
&#x20;              sasl {\
&#x20;                      \# SASL mechanism\
\#                       mech = 'PLAIN'

&#x20;                      \# SASL authorisation identity to proxy.\
\#                       proxy = \&User-Name

&#x20;                      \# SASL realm. Used for kerberos.\
\#                       realm = 'example.org'\
&#x20;              }

&#x20;              \#  Search scope, may be 'base', 'one', sub' or 'children'\
\#               scope = 'sub'

&#x20;              \#  Server side result sorting\
&#x20;              \#\
&#x20;              \#  A list of space delimited attributes to order the result\
&#x20;              \#  set by, if the filter matches multiple objects.\
&#x20;              \#  Only the first result in the set will be processed.\
&#x20;              \#\
&#x20;              \#  If the attribute name is prefixed with a hyphen '-' the\
&#x20;              \#  sorting order will be reversed for that attribute.\
&#x20;              \#\
&#x20;              \#  If sort\_by is set, and the server does not support sorting\
&#x20;              \#  the search will fail.\
\#               sort\_by = '-uid'

&#x20;              \#  If this is undefined, anyone is authorised.\
&#x20;              \#  If it is defined, the contents of this attribute\
&#x20;              \#  determine whether or not the user is authorised\
\#               access\_attribute = 'dialupAccess'

&#x20;              \#  Control whether the presence of 'access\_attribute'\
&#x20;              \#  allows access, or denys access.\
&#x20;              \#\
&#x20;              \#  If 'yes', and the access\_attribute is present, or\
&#x20;              \#  'no' and the access\_attribute is absent then access\
&#x20;              \#  will be allowed.\
&#x20;              \#\
&#x20;              \#  If 'yes', and the access\_attribute is absent, or\
&#x20;              \#  'no' and the access\_attribute is present, then\
&#x20;              \#  access will not be allowed.\
&#x20;              \#\
&#x20;              \#  If the value of the access\_attribute is 'false', it\
&#x20;              \#  will negate the result.\
&#x20;              \#\
&#x20;              \#  e.g.\
&#x20;              \#    access\_positive = yes\
&#x20;              \#    access\_attribute = userAccessAllowed\
&#x20;              \#\
&#x20;              \#  With an LDAP object containing:\
&#x20;              \#    userAccessAllowed: false\
&#x20;              \#\
&#x20;              \#  Will result in the user being locked out.\
\#               access\_positive = yes\
&#x20;      }

&#x20;      \#\
&#x20;      \#  User membership checking.\
&#x20;      \#\
&#x20;      group {\
&#x20;              \#  Where to start searching in the tree for groups\
&#x20;              base\_dn = "${..base\_dn}"

&#x20;              \#  Filter for group objects, should match all available\
&#x20;              \#  group objects a user might be a member of.\
&#x20;              \#\
&#x20;              \#  If using Active Directory you are likely to need "group"\
&#x20;              \#  instead of "posixGroup".\
&#x20;              filter = '(objectClass=posixGroup)'

&#x20;              \# Search scope, may be 'base', 'one', sub' or 'children'\
\#               scope = 'sub'

&#x20;              \#  Attribute that uniquely identifies a group.\
&#x20;              \#  Is used when converting group DNs to group\
&#x20;              \#  names.\
\#               name\_attribute = cn

&#x20;              \#  Filter to find all group objects a user is a member of.\
&#x20;              \#  That is, group objects with attributes that\
&#x20;              \#  identify members (the inverse of membership\_attribute).\
&#x20;              \#\
&#x20;              \#  Note that this configuration references the "user\_dn"\
&#x20;              \#  configuration defined above.\
&#x20;              \#\
\#               membership\_filter = "(|(member=%{control:${..user\_dn}})(memberUid=%{%{Stripped-User-Name}:-%{User-Name}}))"

&#x20;              \#  The attribute, in user objects, which contain the names\
&#x20;              \#  or DNs of groups a user is a member of.\
&#x20;              \#\
&#x20;              \#  Unless a conversion between group name and group DN is\
&#x20;              \#  needed, there's no requirement for the group objects\
&#x20;              \#  referenced to actually exist.\
&#x20;              \#\
&#x20;              \#  If the LDAP server does not support the "memberOf"\
&#x20;              \#  attribute (or equivalent), then you will need to use the\
&#x20;              \#  membership\_filter option above instead. If you can't see\
&#x20;              \#  the memberOf attribute then it is also possible that the\
&#x20;              \#  LDAP bind user does not have the correct permissions to\
&#x20;              \#  view it.\
&#x20;              membership\_attribute = 'memberOf'

&#x20;              \#  If cacheable\_name or cacheable\_dn are enabled,\
&#x20;              \#  all group information for the user will be\
&#x20;              \#  retrieved from the directory and written to LDAP-Group\
&#x20;              \#  attributes appropriate for the instance of rlm\_ldap.\
&#x20;              \#\
&#x20;              \#  For group comparisons these attributes will be checked\
&#x20;              \#  instead of querying the LDAP directory directly.\
&#x20;              \#\
&#x20;              \#  This feature is intended to be used with rlm\_cache.\
&#x20;              \#\
&#x20;              \#  If you wish to use this feature, you should enable\
&#x20;              \#  the type that matches the format of your check items\
&#x20;              \#  i.e. if your groups are specified as DNs then enable\
&#x20;              \#  cacheable\_dn else enable cacheable\_name.\
\#               cacheable\_name = 'no'\
\#               cacheable\_dn = 'no'

&#x20;              \#  Override the normal cache attribute (\<inst>-LDAP-Group or\
&#x20;              \#  LDAP-Group if using the default instance) and create a\
&#x20;              \#  custom attribute.  This can help if multiple module instances\
&#x20;              \#  are used in fail-over.\
\#               cache\_attribute = 'LDAP-Cached-Membership'

&#x20;              \#  If the group being checked is specified as a name, but\
&#x20;              \#  the user's groups are referenced by DN, and one of those\
&#x20;              \#  group DNs is invalid, the whole group check is treated as\
&#x20;              \#  invalid, and a negative result will be returned.\
&#x20;              \#  When set to 'yes', this option ignores invalid DN\
&#x20;              \#  references.\
\#               allow\_dangling\_group\_ref = 'no'\
&#x20;      }

&#x20;      \#\
&#x20;      \#  User profiles. RADIUS profile objects contain sets of attributes\
&#x20;      \#  to insert into the request. These attributes are mapped using\
&#x20;      \#  the same mapping scheme applied to user objects (the update section above).\
&#x20;      \#\
&#x20;      profile {\
&#x20;              \#  Filter for RADIUS profile objects\
\#               filter = '(objectclass=radiusprofile)'

&#x20;              \#  The default profile.  This may be a DN or an attribute\
&#x20;              \#  reference.\
&#x20;              \#  To get old v2.2.x style behaviour, or to use the\
&#x20;              \#  \&User-Profile attribute to specify the default profile,\
&#x20;              \#  set this to \&control:User-Profile.\
\#               default = 'cn=radprofile,dc=example,dc=org'

&#x20;              \#  The LDAP attribute containing profile DNs to apply\
&#x20;              \#  in addition to the default profile above.  These are\
&#x20;              \#  retrieved from the user object, at the same time as the\
&#x20;              \#  attributes from the update section, are are applied\
&#x20;              \#  if authorization is successful.\
\#               attribute = 'radiusProfileDn'\
&#x20;      }

&#x20;      \#\
&#x20;      \#  Bulk load clients from the directory\
&#x20;      \#\
&#x20;      client {\
&#x20;              \#   Where to start searching in the tree for clients\
&#x20;              base\_dn = "${..base\_dn}"

&#x20;              \#\
&#x20;              \#  Filter to match client objects\
&#x20;              \#\
&#x20;              filter = '(objectClass=radiusClient)'

&#x20;              \# Search scope, may be 'base', 'one', 'sub' or 'children'\
\#               scope = 'sub'

&#x20;              \#\
&#x20;              \#  Sets default values (not obtained from LDAP) for new client entries\
&#x20;              \#\
&#x20;              template {\
\#                       login                           = 'test'\
\#                       password                        = 'test'\
\#                       proto                           = tcp\
\#                       require\_message\_authenticator   = yes

&#x20;                      \# Uncomment to add a home\_server with the same\
&#x20;                      \# attributes as the client.\
\#                       coa\_server {\
\#                               response\_window = 2.0\
\#                       }\
&#x20;              }

&#x20;              \#\
&#x20;              \#  Client attribute mappings are in the format:\
&#x20;              \#      \<client attribute> = \<ldap attribute>\
&#x20;              \#\
&#x20;              \#  The following attributes are required:\
&#x20;              \#    \* ipaddr | ipv4addr | ipv6addr - Client IP Address.\
&#x20;              \#    \* secret - RADIUS shared secret.\
&#x20;              \#\
&#x20;              \#  All other attributes usually supported in a client\
&#x20;              \#  definition are also supported here.\
&#x20;              \#\
&#x20;              \#  Schemas are available in doc/schemas/ldap for openldap and eDirectory\
&#x20;              \#\
&#x20;              attribute {\
&#x20;                      ipaddr                          = 'radiusClientIdentifier'\
&#x20;                      secret                          = 'radiusClientSecret'\
\#                       shortname                       = 'radiusClientShortname'\
\#                       nas\_type                        = 'radiusClientType'\
\#                       virtual\_server                  = 'radiusClientVirtualServer'\
\#                       require\_message\_authenticator   = 'radiusClientRequireMa'\
&#x20;              }\
&#x20;      }

&#x20;      \#  Load clients on startup\
\#       read\_clients = no

&#x20;      \#\
&#x20;      \#  Modify user object on receiving Accounting-Request\
&#x20;      \#

&#x20;      \#  Useful for recording things like the last time the user logged\
&#x20;      \#  in, or the Acct-Session-ID for CoA/DM.\
&#x20;      \#\
&#x20;      \#  LDAP modification items are in the format:\
&#x20;      \#       \<ldap attr> \<op> \<value>\
&#x20;      \#\
&#x20;      \#  Where:\
&#x20;      \#       \<ldap attr>:    The LDAP attribute to add modify or delete.\
&#x20;      \#       \<op>:           One of the assignment operators:\
&#x20;      \#                       (:=, +=, -=, ++).\
&#x20;      \#                       Note: '=' is \*not\* supported.\
&#x20;      \#       \<value>:        The value to add modify or delete.\
&#x20;      \#\
&#x20;      \#  WARNING: If using the ':=' operator with a multi-valued LDAP\
&#x20;      \#  attribute, all instances of the attribute will be removed and\
&#x20;      \#  replaced with a single attribute.\
&#x20;      \#  NAO PRECISA COMENTAR AS LINHAS ABAIXO PARA LDAP OU AD\
&#x20;      accounting {\
&#x20;              reference = "%{tolower:type.%{Acct-Status-Type}}"

&#x20;              type {\
&#x20;                      start {\
&#x20;                              update {\
&#x20;                                      description := "Online at %S"\
&#x20;                              }\
&#x20;                      }

&#x20;                      interim-update {\
&#x20;                              update {\
&#x20;                                      description := "Last seen at %S"\
&#x20;                              }\
&#x20;                      }

&#x20;                      stop {\
&#x20;                              update {\
&#x20;                                      description := "Offline at %S"\
&#x20;                              }\
&#x20;                      }\
&#x20;              }\
&#x20;      }

&#x20;      \#\
&#x20;      \#  Post-Auth can modify LDAP objects too\
&#x20;      \#

&#x20;

&#x20;      post-auth {\
&#x20;              \# COMENTAR O BLOCO ABAIXO POIS ELE TENTA GRAVAR NO AD/LDAP O HORARIO DE AUTENTICACAO\
&#x20;              \#update {\
&#x20;              \#         description := "Authenticated at %S"\
&#x20;              \# }\
&#x20;      }

&#x20;      \#\
&#x20;      \#  LDAP connection-specific options.\
&#x20;      \#\
&#x20;      \#  These options set timeouts, keep-alives, etc. for the connections.\
&#x20;      \#\
&#x20;      options {\
&#x20;              \#  Control under which situations aliases are followed.\
&#x20;              \#  May be one of 'never', 'searching', 'finding' or 'always'\
&#x20;              \#  default: libldap's default which is usually 'never'.\
&#x20;              \#\
&#x20;              \#  LDAP\_OPT\_DEREF is set to this value.\
\#               dereference = 'always'

&#x20;              \#\
&#x20;              \#  The following two configuration items control whether the\
&#x20;              \#  server follows references returned by LDAP directory.\
&#x20;              \#  They are  mostly for Active Directory compatibility.\
&#x20;              \#  If you set these to 'no', then searches will likely return\
&#x20;              \#  'operations error', instead of a useful result.\
&#x20;              \#\
&#x20;              chase\_referrals = yes\
&#x20;              rebind = yes

&#x20;              \# SASL Security Properties (see SASL\_SECPROPS in ldap.conf man page).\
&#x20;              \# Note - uncomment when using GSS-API sasl mechanism along with TLS\
&#x20;              \# encryption against Active-Directory LDAP servers (this disables\
&#x20;              \# sealing and signing at the GSS level as required by AD).\
&#x20;              \#sasl\_secprops = 'noanonymous,noplain,maxssf=0'

&#x20;              \#  Seconds to wait for LDAP query to finish. default: 20\
&#x20;              res\_timeout = 10

&#x20;              \#  Seconds LDAP server has to process the query (server-side\
&#x20;              \#  time limit). default: 20\
&#x20;              \#\
&#x20;              \#  LDAP\_OPT\_TIMELIMIT is set to this value.\
&#x20;              srv\_timelimit = 3

&#x20;              \#  Seconds to wait for response of the server. (network\
&#x20;              \#  failures) default: 10\
&#x20;              \#\
&#x20;              \#  LDAP\_OPT\_NETWORK\_TIMEOUT is set to this value.\
&#x20;              net\_timeout = 1

&#x20;              \#  LDAP\_OPT\_X\_KEEPALIVE\_IDLE\
&#x20;              idle = 60

&#x20;              \#  LDAP\_OPT\_X\_KEEPALIVE\_PROBES\
&#x20;              probes = 3

&#x20;              \#  LDAP\_OPT\_X\_KEEPALIVE\_INTERVAL\
&#x20;              interval = 3

&#x20;              \#  ldap\_debug: debug flag for LDAP SDK\
&#x20;              \#  (see OpenLDAP documentation).  Set this to enable\
&#x20;              \#  huge amounts of LDAP debugging on the screen.\
&#x20;              \#  You should only use this if you are an LDAP expert.\
&#x20;              \#\
&#x20;              \#       default: 0x0000 (no debugging messages)\
&#x20;              \#       Example:(LDAP\_DEBUG\_FILTER+LDAP\_DEBUG\_CONNS)\
&#x20;              ldap\_debug = 0x0028\
&#x20;      }

&#x20;      \#\
&#x20;      \#  This subsection configures the tls related items\
&#x20;      \#  that control how FreeRADIUS connects to an LDAP\
&#x20;      \#  server.  It contains all of the 'tls\_\*' configuration\
&#x20;      \#  entries used in older versions of FreeRADIUS.  Those\
&#x20;      \#  configuration entries can still be used, but we recommend\
&#x20;      \#  using these.\
&#x20;      \#\
&#x20;      tls {\
&#x20;              \# Set this to 'yes' to use TLS encrypted connections\
&#x20;              \# to the LDAP database by using the StartTLS extended\
&#x20;              \# operation.\
&#x20;              \#\
&#x20;              \# The StartTLS operation is supposed to be\
&#x20;              \# used with normal ldap connections instead of\
&#x20;              \# using ldaps (port 636) connections\
\#               start\_tls = yes

\#               ca\_file = ${certdir}/cacert.pem

\#               ca\_path = ${certdir}\
\#               certificate\_file = /path/to/radius.crt\
\#               private\_key\_file = /path/to/radius.key\
\#               random\_file = /dev/urandom

&#x20;              \#  Certificate Verification requirements.  Can be:\
&#x20;              \#    'never' (do not even bother trying)\
&#x20;              \#    'allow' (try, but don't fail if the certificate\
&#x20;              \#               cannot be verified)\
&#x20;              \#    'demand' (fail if the certificate does not verify)\
&#x20;              \#    'hard'  (similar to 'demand' but fails if TLS\
&#x20;              \#             cannot negotiate)\
&#x20;              \#\
&#x20;              \#  The default is libldap's default, which varies based\
&#x20;              \#  on the contents of ldap.conf.

\#               require\_cert    = 'demand'

&#x20;              \#\
&#x20;              \#  Minimum TLS version to accept. We STRONGLY recommend\
&#x20;              \#  setting this to "1.2"\
&#x20;              \#\
\#               tls\_min\_version = "1.2"\
&#x20;      }

&#x20;      \#  As of version 3.0, the 'pool' section has replaced the\
&#x20;      \#  following configuration items:\
&#x20;      \#\
&#x20;      \#  ldap\_connections\_number

&#x20;      \#  The connection pool is new for 3.0, and will be used in many\
&#x20;      \#  modules, for all kinds of connection-related activity.\
&#x20;      \#\
&#x20;      \#  When the server is not threaded, the connection pool\
&#x20;      \#  limits are ignored, and only one connection is used.\
&#x20;      pool {\
&#x20;              \#  Connections to create during module instantiation.\
&#x20;              \#  If the server cannot create specified number of\
&#x20;              \#  connections during instantiation it will exit.\
&#x20;              \#  Set to 0 to allow the server to start without the\
&#x20;              \#  directory being available.\
&#x20;              start = ${thread\[pool].start\_servers}

&#x20;              \#  Minimum number of connections to keep open\
&#x20;              min = ${thread\[pool].min\_spare\_servers}

&#x20;              \#  Maximum number of connections\
&#x20;              \#\
&#x20;              \#  If these connections are all in use and a new one\
&#x20;              \#  is requested, the request will NOT get a connection.\
&#x20;              \#\
&#x20;              \#  Setting 'max' to LESS than the number of threads means\
&#x20;              \#  that some threads may starve, and you will see errors\
&#x20;              \#  like 'No connections available and at max connection limit'\
&#x20;              \#\
&#x20;              \#  Setting 'max' to MORE than the number of threads means\
&#x20;              \#  that there are more connections than necessary.\
&#x20;              max = ${thread\[pool].max\_servers}

&#x20;              \#  Spare connections to be left idle\
&#x20;              \#\
&#x20;              \#  NOTE: Idle connections WILL be closed if "idle\_timeout"\
&#x20;              \#  is set.  This should be less than or equal to "max" above.\
&#x20;              spare = ${thread\[pool].max\_spare\_servers}

&#x20;              \#  Number of uses before the connection is closed\
&#x20;              \#\
&#x20;              \#  0 means "infinite"\
&#x20;              uses = 0

&#x20;              \#  The number of seconds to wait after the server tries\
&#x20;              \#  to open a connection, and fails.  During this time,\
&#x20;              \#  no new connections will be opened.\
&#x20;              retry\_delay = 30

&#x20;              \#  The lifetime (in seconds) of the connection\
&#x20;              lifetime = 0

&#x20;              \#  Idle timeout (in seconds).  A connection which is\
&#x20;              \#  unused for this length of time will be closed.\
&#x20;              idle\_timeout = 60

&#x20;              \#  NOTE: All configuration settings are enforced.  If a\
&#x20;              \#  connection is closed because of 'idle\_timeout',\
&#x20;              \#  'uses', or 'lifetime', then the total number of\
&#x20;              \#  connections MAY fall below 'min'.  When that\
&#x20;              \#  happens, it will open a new connection.  It will\
&#x20;              \#  also log a WARNING message.\
&#x20;              \#\
&#x20;              \#  The solution is to either lower the 'min' connections,\
&#x20;              \#  or increase lifetime/idle\_timeout.\
&#x20;      }\
}\
&#x20;

Agora precisamos criar o link para a ativação de autenticação via LDAP\
ln -s /etc/freeradius/mods-available/ldap /etc/freeradius/mods-enabled/ldap

Agora  você pode executar o comando freeradius -CX para verificar se a configuração está OK

&#x20;

**Utilizando o Freeradius para autenticar os usuários no AD**\
Será necessário instalar os pacotes do samba
--------------------------------------------

Se ao instalar os pacotes, se aparecer alguma tela perguntando por alguma informação, você pode pressionar Enter, não precisa responder.\
*apt install krb5-user libpam-krb5 krb5-config libkrb5-3 libkadm5clnt-mit12 winbind systemd-timesyncd ntpdate samba samba-common samba-common-bin samba-dsdb-modules samba-libs samba-vfs-modules cifs-utils smbclient*

### krb5.conf

Configuração do arquivo krb5.conf \
vim /etc/krb5.conf

\[libdefaults]\
&#x20;      default\_realm = SEU\_DOMINIO.LOCAL\
&#x20;      dns\_lookup\_realm = true\
&#x20;      dns\_lookup\_kdc = true\
&#x20;      ticket\_lifetime = 24h\
&#x20;      renew\_lifetime = 7d\
&#x20;      forwardable = true\
&#x20;      rdns = false

\[realms]\
&#x20;      SEU\_DOMINIO.LOCAL = {\
&#x20;              kdc = 200.130.35.164\
&#x20;              kdc = 200.143.193.71\
&#x20;              admin\_server = 200.130.35.164\
&#x20;              default\_domain = seu\_dominio.local\
&#x20;              master\_kdc =  200.130.35.164               \
&#x20;      }

\[domain\_realm]\
&#x20;      seu\_dominio.local = SEU\_DOMINIO.LOCAL\
&#x20;      .seu\_dominio.local = SEU\_DOMINIO.LOCAL

\[login]\
&#x20;      krb4\_convert = true\
&#x20;      krb4\_get\_tickets = false

\[logging]\
&#x20;      libkrb5 = 0-/SYSLOG:\
&#x20;      default = FILE:/var/log/krb5libs.log\
&#x20;      kdc = FILE:/var/log/krb5kdc.log\
&#x20;      admin\_server = FILE:/var/log/kadmind.log\
&#x20;

&#x20;

Para testar se a configuração acima está funcionando, voce pode utilizar o seguinte comando:\
kinit  <seulogin@SEU_DOMINIO.LOCAL>

Para ver se você se autenticou pode utilizar o comando:\
klist

&#x20;

#### Configurando o arquivo do Samba <a href="#configurando-o-arquivo-do-samba" id="configurando-o-arquivo-do-samba"></a>

vim /etc/samba/smb.conf

\[global]\
netbios name = idp1\
security = ads\
realm = SEU\_DOMINIO.LOCAL\
workgroup = SEU\_DOMINIO\
server role = standalone server\
server string = EDUROAM RADIUS server\
invalid users = root\
socket options = TCP\_NODELAY\
idmap config \* : rangesize = 1000000\
idmap config \* : range = 1000000-19999999\
idmap config \* : backend = autorid\
winbind enum users = yes\
winbind enum groups = yes\
template homedir = /home/%D/%U\
template shell = /bin/bash\
client use spnego = yes\
client ntlmv2 auth = yes\
encrypt passwords = yes\
winbind use default domain = yes\
restrict anonymous = 2\
domain master = no\
local master = no\
preferred master = no\
os level = 0\
logging                 =  syslog\@1 file\
log level               = 1 smb:4 acls:4 locking:4\
log file                = /var/log/samba/%m.log\
smbd profiling level    = on\
pam password change = yes\
password server = \*

\#log level = 10\
\#debug pid = true\
\#max log size = 0

\# adicionado em 14-06-2023\
kerberos method = secrets and keytab\
client signing = yes

winbind offline logon = yes\
winbind request timeout = 10\
&#x20;

&#x20;

#### Vamos remover o arquivo resolv.conf e criar um novo <a href="#vamos-remover-o-arquivo-resolv.conf-e-criar-um-novo" id="vamos-remover-o-arquivo-resolv.conf-e-criar-um-novo"></a>

cp /etc/resolv.conf /etc/resolv.conf.bak

rm /etc/resolv.conf&#x20;

vim /etc/resolv.conf&#x20;

nameserver 200.130.35.164\
nameserver 18.229.209.221\
search SEU\_DOMINIO.LOCAL\
domain SEU\_DOMINIO.LOCAL

\
Ingressando a máquina no dominio do local \
net ads join  -I ip\_ad -U user\_ad \
&#x20;

Para saber se a maquina ingressou com sucesso:\
net ads testjoin

Verificar o conteúdo do arquivo mschap\
vim /etc/freeradius/mods-enabled/mschap\
mschap {\
&#x20;      use\_mppe = yes\
&#x20;      require\_encryption = yes\
&#x20;      require\_strong = yes\
&#x20;      with\_ntdomain\_hack = yes\
&#x20;      ntlm\_auth =  "/usr/bin/ntlm\_auth --request-nt-key --username=%{%{Stripped-User-Name}:-%{%{User-Name}:-None}} --challenge=%{%{mschap:Challenge}:-00} --nt-response=%{%{mschap:NT-Response}:-00}"\
&#x20;      }

\
Configurando o arquivo ntlm\_auth\
vim /etc/freeradius/mods-enabled/ntlm\_auth\
exec ntlm\_auth {\
&#x20;              wait = yes\
&#x20;              program = "/usr/bin/ntlm\_auth --request-nt-key --domain=SEU\_COMINIO.LOCAL --username=%{mschap:User-Name} --password=%{User-Password}"\
&#x20;      }

#### Agora reiniciar todos os serviços com stop e start <a href="#agora-reiniciar-todos-os-servicos-com-stop-e-start" id="agora-reiniciar-todos-os-servicos-com-stop-e-start"></a>

/etc/init.d/freeradius stop ; /etc/init.d/smbd stop ; /etc/init.d/nmbd stop ; /etc/init.d/winbind stop\
/etc/init.d/smbd start ; /etc/init.d/nmbd start ; /etc/init.d/winbind start ; /etc/init.d/freeradius start\
&#x20;

#### Agora você ja pode testar a autenticação com o comando radtest <a href="#agora-voce-ja-pode-testar-a-autenticacao-com-o-comando-radtest" id="agora-voce-ja-pode-testar-a-autenticacao-com-o-comando-radtest"></a>

radtest [login\_do\_usuario\_do\_ad@](mailto:login_do_usuario_do_ad@unicamp.br)seu\_dominio.br   senha\_do\_usuario 127.0.0.1 0 radsec

&#x20;
