В данной статье описывается только базовая настройка прокси сервера с авторизацией Kerberos в Active Directory Windows Server 2016 (на данный момент TP4) без настройки ограничений и прочего. Тестовый стенд: VM Windows Server 2016 TP4, VM с Debian 8.2 x64, VM Windows 10 x64. Изначально хотел обновить статью для настройки предыдущих Windows Server и Squid, но решил не городить огород даже из-за нескольких новых (или удалённых старых) строчек.
root@squid3:~# uname -a
Linux squid3 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt20-1+deb8u1 (2015-12-14) x86_64 GNU/Linux
root@squid3:~# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 8.2 (jessie)
Release: 8.2
Codename: Jessie
В Debian 8.2 желательно добавить репозитории предыдущих версии, т.к. не все программы присутствуют в новом:
cat /etc/apt/sources.list
...
deb http://ftp.de.debian.org/debian wheezy main
deb http://ftp.de.debian.org/debian squeeze main
Указываем адрес DNS сервера и домен.
cat /etc/resolv.conf
domain test.exonix.ru
search test.exonix.ru
nameserver 192.168.29.97
До сих пор, по непонятным причинам, Debian или Squid не хотят разрешать имя контроллера домена из DNS. Дописываем /etc/hosts:
root@squid3:~# cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 squid3.test.exonix.ru squid3
192.168.29.97 dc1.test.exonix.ru dc1
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
Установка и настройка сервера времени для синхронизации времени с контроллером домена. Для протокола Kerberos это важно.
aptitude install ntp
cat /etc/ntp.conf
server dc1.test.exonix.ru
restrict 127.0.0.1
service ntp restart
Установка и настройка Kerberos клиента:
aptitude install krb5-user
cat /etc/krb5.conf [libdefaults] default_realm = TEST.EXONIX.RU # for Windows 2008\2012\2016 with AES default_tgs_enctypes = aes256-cts-hmac-sha1-96 rc4-hmac des-cbc-crc des-cbc-md5 default_tkt_enctypes = aes256-cts-hmac-sha1-96 rc4-hmac des-cbc-crc des-cbc-md5 permitted_enctypes = aes256-cts-hmac-sha1-96 rc4-hmac des-cbc-crc des-cbc-md5 default_keytab_name = /etc/squid3/PROXY.keytab # The following krb5.conf variables are only for MIT Kerberos. krb4_config = /etc/krb.conf krb4_realms = /etc/krb.realms kdc_timesync = 1 ccache_type = 4 forwardable = true proxiable = true # The following encryption type specification will be used by MIT Kerberos # if uncommented. In general, the defaults in the MIT Kerberos code are # correct and overriding these specifications only serves to disable new # encryption types as they are added, creating interoperability problems. # # Thie only time when you might need to uncomment these lines and change # the enctypes is if you have local software that will break on ticket # caches containing ticket encryption types it doesn't know about (such as # old versions of Sun Java). # default_tgs_enctypes = des3-hmac-sha1 # default_tkt_enctypes = des3-hmac-sha1 # permitted_enctypes = des3-hmac-sha1 # The following libdefaults parameters are only for Heimdal Kerberos. v4_instance_resolve = false v4_name_convert = { host = { rcmd = host ftp = ftp } plain = { something = something-else } } fcc-mit-ticketflags = true [realms] TEST.EXONIX.RU = { kdc = DC1.TEST.EXONIX.RU admin_server = DC1.TEST.EXONIX.RU } [domain_realm] .test.exonix.ru = TEST.EXONIX.RU test.exonix.ru = TEST.EXONIX.RU [login] krb4_convert = true krb4_get_tickets = false default = FILE:/var/log/krb5libs.log kdc = FILE:/var/log/krb5kdc.log admin_server = FILE:/var/log/kadmind.log
Установка squid3 и инструментов ldap:
aptitude install squid3 ldap-utils
root@squid3:~# kinit administrator Password for administrator@TEST.EXONIX.RU: root@squid3:~#
Создаём файл PROXY.keytab. Учётная запись компьютера предварительно создана, а так же группа для доступа в интернет и пользователь, который может читать всю AD:
aptitude install msktutil
msktutil -c -b "CN=OU" -s HTTP -k /etc/squid3/PROXY.keytab --computer-name SQUID3 --upn HTTP/squid3.test.exonix.ru --server dc1.test.exonix.ru --verbose --enctypes 28
chgrp proxy /etc/squid3/PROXY.keytab
chmod g+r /etc/squid3/PROXY.keytab
msktutil --auto-update --verbose
Настройка прокси сервера squid3. Файл отличается от предыдущей версии, так были переименованы хелперы и ещё некоторые изменения:
cat /etc/squid3/squid.conf ####### /etc/squid3/squid.conf Configuration File ####### ####### cache manager cache_mgr aleks@test.exonix.ru ####### kerberos authentication auth_param negotiate program /usr/lib/squid3/negotiate_kerberos_auth -d -s HTTP/squid3.test.exonix.ru auth_param negotiate children 10 auth_param negotiate keep_alive on ####### provide access via ldap for clients not authenticated via kerberos auth_param basic program /usr/lib/squid3/basic_ldap_auth -R \ -b "dc=test,dc=exonix,dc=ru" \ -D squidread@test.exonix.ru \ -w "1q2w#E$R" \ -f sAMAccountName=%s \ -h dc1.test.exonix.ru auth_param basic children 10 auth_param basic realm Internet Proxy auth_param basic credentialsttl 1 minute ####### ldap authorizations # restricted proxy access logged external_acl_type internet_users %LOGIN /usr/lib/squid3/ext_ldap_group_acl -R -K \ -b "dc=test,dc=exonix,dc=ru" \ -D squidread@test.exonix.ru \ -w "1q2w#E$R" \ -f "(&(objectclass=person)(sAMAccountName=%v)(memberof=CN=INTERNET,OU=OU,DC=test,DC=exonix,DC=ru))" \ -h dc1.test.exonix.ru ####### acl for proxy auth and ldap authorizations acl auth proxy_auth REQUIRED # format "acl, aclname, acltype, acltypename, activedirectorygroup" acl RestrictedAccessLog external internet_users INTERNET ####### squid Defaults acl local_net src 192.168.29.0/24 acl SSL_ports port 443 #https acl Safe_ports port 80 # http acl Safe_ports port 21 # ftp acl Safe_ports port 443 # https acl Safe_ports port 70 # gopher acl Safe_ports port 210 # wais acl Safe_ports port 1025-65535 # unregistered ports acl Safe_ports port 280 # http-mgmt acl Safe_ports port 488 # gss-http acl Safe_ports port 591 # filemaker acl Safe_ports port 777 # multiling http acl CONNECT method CONNECT http_access allow manager localhost http_access deny manager http_access deny !Safe_ports http_access deny CONNECT !SSL_ports http_access allow localhost ####### enforce auth: order of rules is important for authorization levels http_access allow RestrictedAccessLog auth ####### logging access_log /var/log/squid3/access.log squid ####### squid defaults http_access deny all !local_net http_port 3128 hierarchy_stoplist cgi-bin ? coredump_dir /var/spool/squid3 refresh_pattern ^ftp: 1440 20% 10080 refresh_pattern ^gopher: 1440 0% 1440
Установим веб-сервер apache2 для настройки файла WPAD:
aptitude install apache2
apache2 -v
Server version: Apache/2.4.10 (Debian)
Server built: Aug 28 2015 16:28:08
mkdir /etc/apache2/conf.d/
vi /etc/apache2/conf.d/wpad.dat
AddType application/x-ns-proxy-autoconfig .dat
vi /var/www/html/wpad.dat
function FindProxyForURL(url, host)
{ $proxy = "PROXY squid3.test.exonix.ru:3128";
// URLs within this network are accessed direct
if (isInNet(host, "192.168.29.0", "255.255.255.0")) {return "DIRECT";}
if (isInNet(host, "127.0.0.0", "255.0.0.0")) {return "DIRECT";}
//Return proxy for EVERYTHING else
else return $proxy;
}
apachectl restart
Для работы необходимо настроить браузер. Адрес сервер пишется в виде FQDN. Если написать IP - работать не будет. Проверьте, что ДНС сервер содержит запись о прокси сервере.
сразу после настройки и перезагрузки Windows 8.1, она (не браузер) полезет на некоторые MS службы:
1450799659.744 0 192.168.29.91 TCP_DENIED/407 3640 GET http://www.msftncsi.com/ncsi.txt - HIER_NONE/- text/html
1450799659.822 70 192.168.29.91 TCP_MISS/200 563 GET http://www.msftncsi.com/ncsi.txt PC1$@TEST.EXONIX.RU HIER_DIRECT/84.53.136.59 text/plain
1450799679.104 0 192.168.29.91 TCP_DENIED/407 3795 GET http://de-de.appex-rf.msn.com/cgtile/v1/de-DE/Sports/Today.xml? - HIER_NONE/- text/html
1450799679.178 63 192.168.29.91 TCP_CLIENT_REFRESH_MISS/200 1916 GET http://de-de.appex-rf.msn.com/cgtile/v1/de-DE/Sports/Today.xml? aleks@TEST.EXONIX.RU HIER_DIRECT/84.53.136.49 application/xml
1450799679.279 55 192.168.29.91 TCP_CLIENT_REFRESH_MISS/200 442 GET http://service.weather.microsoft.com/appex/DesktopTile/PreInstallLiveTile? aleks@TEST.EXONIX.RU HIER_DIRECT/104.86.135.245 -
1450799679.339 54 192.168.29.91 TCP_CLIENT_REFRESH_MISS/200 1292 GET http://foodanddrink.tile.appex.bing.com/api/feed/? aleks@TEST.EXONIX.RU HIER_DIRECT/84.53.136.49 application/json
1450799679.359 17 192.168.29.91 TCP_CLIENT_REFRESH_MISS/200 1626 GET http://de-de.appex-rf.msn.com/cgtile/v1/de-DE/News/Today.xml aleks@TEST.EXONIX.RU HIER_DIRECT/84.53.136.49 application/xml
1450799679.377 17 192.168.29.91 TCP_CLIENT_REFRESH_MISS/200 1525 GET http://de-de.appex-rf.msn.com/cgtile/v1/de-DE/HealthAndFitness/Home.xml? aleks@TEST.EXONIX.RU HIER_DIRECT/84.53.136.49 application/xml
1450799679.443 55 192.168.29.91 TCP_CLIENT_REFRESH_MISS/200 1694 GET http://finance.services.appex.bing.com/Market.svc/AppTileV2? aleks@TEST.EXONIX.RU HIER_DIRECT/84.53.136.66 application/xml
1450799679.973 485 192.168.29.91 TCP_MISS/200 425 GET http://cdf-anon.xboxlive.com/de-DE/video/feeds/1.2/videolivetile aleks@TEST.EXONIX.RU HIER_DIRECT/104.86.115.40 text/xml
Windows 10 Enterprise лезет на несколько другие MS сервисы:
1450800646.959 0 192.168.29.89 TCP_DENIED/407 3644 GET http://ipv6.msftncsi.com/ncsi.txt - HIER_NONE/- text/html
1450800646.969 6 192.168.29.89 TCP_MISS/503 6260 GET http://ipv6.msftncsi.com/ncsi.txt DESKTOP-TVN4TLQ$@TEST.EXONIX.RU HIER_DIRECT/2003:8:0:1f::5096:c061 text/html
1450800649.968 0 192.168.29.89 TCP_DENIED/407 3640 GET http://www.msftncsi.com/ncsi.txt - HIER_NONE/- text/html
1450800650.018 45 192.168.29.89 TCP_MISS/200 563 GET http://www.msftncsi.com/ncsi.txt DESKTOP-TVN4TLQ$@TEST.EXONIX.RU HIER_DIRECT/84.53.136.59 text/plain
1450800738.929 0 192.168.29.89 TCP_DENIED/407 3808 CONNECT www.bing.com:443 - HIER_NONE/- text/html
1450800749.694 0 192.168.29.89 TCP_DENIED/407 3687 POST http://ssw.live.com/UploadData.aspx - HIER_NONE/- text/html
1450800799.200 0 192.168.29.89 TCP_DENIED/407 3939 GET http://ctldl.windowsupdate.com/msdownload/update/v3/static/trustedr/en/pinrulesstl.cab? - HIER_NONE/- text/html
1450800799.289 76 192.168.29.89 TCP_MISS/200 8070 GET http://ctldl.windowsupdate.com/msdownload/update/v3/static/trustedr/en/pinrulesstl.cab? aleks@TEST.EXONIX.RU HIER_DIRECT/84.53.136.92 application/octet-stream
Windows Update работает через прокси без дополнительных настроек:
1450800900.147 65896 192.168.29.89 TCP_MISS/200 5501 CONNECT fe2.update.microsoft.com:443 aleks@TEST.EXONIX.RU HIER_DIRECT/134.170.165.248 -
27.12.2015