Шукати в цьому блозі

четвер, 13 жовтня 2022 р.

В статті Налаштування OpenVPN-сервера на Mikrotik було наведено скрипт, який оновлює інформацію щодо публічних ntp-серверів, з яких Mikrotik може брати інформацію про точний час. Але справа в тому, що то для RouterOS гілки 6.x, а от для 7.x його доведеться трохи переписати:

/system script
add dont-require-permissions=no name=NTPupdate owner=olden policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive source=":global SYSname [/system identity get name];\r\
    \n\r\
    \n# NTP pools to use (check www.pool.ntp.org)\r\
    \n:global SYSntpa \"0.ua.pool.ntp.org\";\r\
    \n:global SYSntpb \"1.ua.pool.ntp.org\";\r\
    \n\r\
    \nping \$SYSntpa count=2 do-not-fragment;\r\
    \nping \$SYSntpb count=2 do-not-fragment;\r\
    \n\r\
    \n# Resolve the two ntp pool hostnames\r\
    \n:local ntpipa [:resolve \$SYSntpa];\r\
    \n:local ntpipb [:resolve \$SYSntpb];\r\
    \n\r\
    \n# Get the current settings\r\
    \n:local ntpcura [/system/ntp/client/servers/get 0];\r\
    \n:local ntpcurb [/system/ntp/client/servers/get 1];\r\
    \n\r\
    \n# Define a variable so we know if anything's changed.\r\
    \n:local changea 0;\r\
    \n:local changeb 0;\r\
    \n\r\
    \n# Change primary if required\r\
    \n:if (\$ntpipa != \$ntpcura) do={\r\
    \n    :put (\"Old: \" . \$ntpcura . \" New: \" . \$ntpipa);\r\
    \n    :put \"Changing primary NTP\";\r\
    \n    /system/ntp/client/servers/set 0 address=\"\$ntpipa\";\r\
    \n    :set changea 1;\r\
    \n    }\r\
    \n\r\
    \n# Change secondary if required\r\
    \n:if (\$ntpipb != \$ntpcurb) do={\r\
    \n    :put (\"Old: \" . \$ntpcurb . \" New: \" . \$ntpipb);\r\
    \n    :put \"Changing secondary NTP\";\r\
    \n    /system/ntp/client/servers/set 1 address=\"\$ntpipb\";\r\
    \n    :set changeb 1;\r\
    \n    }\r\
    \n\r\
    \n:if (\$changea=1 or \$changeb=1) do={\r\
    \n    /system ntp client set enabled=\"no\"\r\
    \n    /ip dhcp-server network set [ find comment=\"dhcp-server\" ] ntp-server=\"192.168.31.1,\$ntpipa,\$ntpipb\"\r\
    \n    /system ntp client set enabled=\"yes\"\r\
    \n    }\r\
    \n"
Ну й не забуваємо його періодично викликати, для актуалізації інформації по ip-адресах ntp-серверів:
/system scheduler
add comment="Check and set NTP servers" interval=12h name=NTPupdate on-event="/system script run NTPupdate\r\
    \n" policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive start-date=jan/01/1970 start-time=00:00:00

четвер, 6 жовтня 2022 р.

winget

 Настільки наскільки я не люблю Windows, настільки сьогодні був вражений інструментом winget - сподобалося ;)

Знадобилося швиденько, на нову систему проінстальованого Windwos 10, встановити Google Chrome, PuTTY, WinSCP та деякі інші додатки. Що ж, це стало зручно робити, не витрачаючи час на пошуки ресурсів через Google, достатньо простого cmd.

Вводимо:

winget search putty

Бачимо id і далі просто:

winget install --id=PuTTY.PuTTY -e

Аналогічно

winget install --id=WinSCP.WinSCP -e
winget install --id=TeraTermProject.teraterm -e
winget install --id=Mozilla.Firefox -e
winget install --id=eloston.ungoogled-chromium -e
winget install --id=Google.Chrome -e --force
winget install --id=Microsoft.WindowsTerminal -e
winget install --id=Debian.Debian -e

Я у захваті. Сподобалося ;)

вівторок, 4 жовтня 2022 р.

Ways to install Windows 11

 This article describes ways to install Windows 11.

Note: To upgrade to Windows 11, devices should meet the Windows 11 minimum system requirements. Some Windows 10 features aren't available in Windows 11. System requirements to experience some Windows 11 features and apps will exceed the Windows 11 minimum system requirements. Find Windows 11 specs, features, and computer requirements

Before you begin

Make sure the device you want to install Windows 11 on meets the minimum system requirements. If your device is currently running Windows 10, we recommend you verify the minimum system requirements using the PC Health Check app. We do not recommend installing Windows 11 on a device that doesn't meet requirements. For more info, see Installing Windows 11 on devices that don't meet minimum system requirements.

Windows Update in Settings (recommended)

If you’re upgrading from Windows 10, we recommend you wait until you're notified through Windows Update that the upgrade is ready for your device. To check if Windows 11 is ready for your device, select Start  > Settings  > Update & Security  > Windows Update  > Check for updates.

For known issues that might affect your device, you can also check the Windows release health hub.

Other ways to install Windows 11 (not recommended) 

Use the Installation Assistant to upgrade

We recommend you wait until your device has been offered the upgrade to Windows 11 before you use the Installation Assistant. When you're ready, you can find it on the Windows 11 software download page.

Create Windows 11 installation media

On the Windows 11 software download page, select Create tool now and follow the instructions to install Windows 11.

Warning: 

  • Microsoft recommends against installing Windows 11 on a device that does not meet the Windows 11 minimum system requirements. If you choose to install Windows 11 on a device that does not meet these requirements, and you acknowledge and understand the risks, you can create the following registry key values and bypass the check for TPM 2.0 (at least TPM 1.2 is required) and the CPU family and model.

  • Registry Key: HKEY_LOCAL_MACHINE\SYSTEM\Setup\MoSetup

  • Name: AllowUpgradesWithUnsupportedTPMOrCPU

  • Type: REG_DWORD

  • Value: 1

  • Note: Serious problems might occur if you modify the registry incorrectly by using Registry Editor or by using another method. These problems might require that you reinstall the operating system. Microsoft cannot guarantee that these problems can be solved. Modify the registry at your own risk.

There are two installation paths available:

  1. Upgrade by launching Setup on the media while running Windows 10. You will have the option to: 

    a. Perform a Full Upgrade, which keeps personal files (including drivers), apps, and Windows Settings. This is the default experience and is the one that Installation Assistant uses.

    b. Keep Data Only will keep personal files (including drivers) only, not apps and not Windows Settings.
     
    c. Clean Install will install Windows 11 and keep nothing from the Windows 10 installation. For more info, see Give your PC a Fresh Start.

  2. Boot from media to launch Setup. This path is a clean install and will not retain previous files or settings. For more info, see Give your PC a Fresh Start.

    Important: You should verify that your device meets minimum system requirements before you choose to boot from media, because it will allow you to install Windows 11 if you have at least TPM 1.2 (instead of the minimum system requirement of TPM 2.0), and it will not verify that your processor is on the approved CPU list based on family and model of processor.

Create an image install

Use DISM or 3rd party tools to directly apply an existing Windows 11 image to the disk.
 

Important: An image install of Windows 11 will not check for the following requirements: TPM 2.0 (at least TPM 1.2 is required) and CPU family and model.

https://support.microsoft.com/en-us/windows/ways-to-install-windows-11-e0edbbfb-cfc5-4011-868b-2ce77ac7c70e

пʼятницю, 9 вересня 2022 р.

Налаштування OpenVPN-сервера на Mikrotik

Перше зауваження, OpenVPN доволі чутливий до розходження часу між клієнтом та сервером, тому, перед тим як почати створювати сертифікати та налаштовувати OpenVPN-сервер, давайте спочатку змусимо наш роутер правильно виставляти і синхронізувати час. Не всі провайдери віддають по DHCP інформацію про свої NTP-сервера (якщо взагалі їх мають), тому будемо користуватися публічними серверами і намагатися час від часу оновлювати інформацію про них.
/system clock set time-zone-name=Europe/Kiev
/system script add dont-require-permissions=no name=NTPupdate owner=admin policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive source=":global SYSname [/system identity get name];\r\
    \n\r\
    \n# NTP pools to use (check www.pool.ntp.org)\r\
    \n:global SYSntpa \"0.ua.pool.ntp.org\";\r\
    \n:global SYSntpb \"1.ua.pool.ntp.org\";\r\
    \n\r\
    \nping \$SYSntpa count=2 do-not-fragment;\r\
    \nping \$SYSntpb count=2 do-not-fragment;\r\
    \n\r\
    \n# Resolve the two ntp pool hostnames\r\
    \n:local ntpipa [:resolve \$SYSntpa];\r\
    \n:local ntpipb [:resolve \$SYSntpb];\r\
    \n\r\
    \n# Get the current settings\r\
    \n:local ntpcura [/system ntp client get primary-ntp];\r\
    \n:local ntpcurb [/system ntp client get secondary-ntp];\r\
    \n\r\
    \n# Define a variable so we know if anything's changed.\r\
    \n:local changea 0;\r\
    \n:local changeb 0;\r\
    \n\r\
    \n# Change primary if required\r\
    \n:if (\$ntpipa != \$ntpcura) do={\r\
    \n    :put (\"Old: \" . \$ntpcura . \" New: \" . \$ntpipa);\r\
    \n    :put \"Changing primary NTP\";\r\
    \n    /system ntp client set primary-ntp=\"\$ntpipa\";\r\
    \n    :set changea 1;\r\
    \n    }\r\
    \n\r\
    \n# Change secondary if required\r\
    \n:if (\$ntpipb != \$ntpcurb) do={\r\
    \n    :put (\"Old: \" . \$ntpcurb . \" New: \" . \$ntpipb);\r\
    \n    :put \"Changing secondary NTP\";\r\
    \n    /system ntp client set secondary-ntp=\"\$ntpipb\";\r\
    \n    :set changeb 1;\r\
    \n    }\r\
    \n"
/system scheduler add comment="Check and set NTP servers" interval=12h name=NTPupdate on-event="/system script run NTPupdate\r\
    \n" policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive start-date=jan/01/1970 start-time=00:00:00
Все! Тепер ми знаємо кунг-фу… тобто тепер наш роутер має коректний час. В принципі такі налаштування бажано зробити як на роутері з OpenVPN-сервером так і з OpenVPN-клієнтом.

Тепер давайте згенеруємо та підпишемо сертифікати.

Створимо корневий сертифікат нашого "сертифікаційного центру".

/certificate add name=ca country="UA" state="AI" locality="Irpin" organization="OSBB" unit="Head" common-name="ca" key-size=8192 days-valid=3650 key-usage=crl-sign,key-cert-sign
/certificate sign ca
Тепер створимо сертифікат та закритий ключ для OpenVPN-сервера.
/certificate add name=ovpn-server country="UA" state="AI" locality="Irpin" organization="OSBB" unit="OpenVPN-server" common-name="ovpn-server" key-size=4096 days-valid=3650 key-usage=digital-signature,key-encipherment,tls-server
/certificate sign ovpn-server ca="ca"
Ну й створюємо клієнтський сертифікат.
/certificate add name=ovpn-muter country="UA" state="AI" locality="Kyiv" organization="Muter" unit="OpenVPN-client-00" common-name="ovpn-muter" key-size=2048 days-valid=3650 key-usage=tls-client
/certificate sign ovpn-muter ca="ca"
Ну от, корньовий сертифікат, сертифікат OpenVPN-сервера та OpenVPN-клієнта згенеровано. Подивимося, що у нас вийшло:
/certificate print terse 
 0 KL A  T name=ca digest-algorithm=sha256 key-type=rsa country=UA state=AI locality=Irpin organization=OSBB unit=Head common-name=ca key-size=8192 subject-alt-name="" days-valid=3650 trusted=yes key-usage=key-cert-sign,crl-sign serial-number=251F3D523
8145BF4 fingerprint=58d9ff1808abbd38019c2e1b1d4b1f5c71a24d41fd6fc0e7b031661e0097e0aa akid="" skid=31c7dab19f80c4fa884d5efb9298a45e7de4d8cc invalid-before=sep/09/2022 13:58:13 invalid-after=sep/06/2032 13:58:13 expires-after=521w2d23h48m56s 
 1 K   I   name=ovpn-server digest-algorithm=sha256 key-type=rsa country=UA state=AI locality=Irpin organization=OSBB unit=OpenVPN-server common-name=ovpn-server key-size=4096 subject-alt-name="" days-valid=3650 trusted=no key-usage=digital-signature,k
ey-encipherment,tls-server ca=ca serial-number=3EDCD88C2647E3F4 fingerprint=0554fd7ec66f744918a362350ab9bebeb715ccb0e7d425f87ec1b0b398a1b069 akid=31c7dab19f80c4fa884d5efb9298a45e7de4d8cc skid=4bf227acb26304896949a77468a438dceac2222f invalid-before=sep/
09/2022 14:01:49 invalid-after=sep/06/2032 14:01:49 expires-after=521w2d23h52m32s 
 2 K   I   name=ovpn-muter digest-algorithm=sha256 key-type=rsa country=UA state=AI locality=Kyiv organization=Muter unit=OpenVPN-client-00 common-name=ovpn-muter key-size=2048 subject-alt-name="" days-valid=3650 trusted=no key-usage=tls-client ca=ca s
erial-number=4FBA81F2BB4BB3C4 fingerprint=3f8eef1079b14c1d81478f22263f382ab10f21ccc5fa010d0443aa019ee7a2b0 akid=31c7dab19f80c4fa884d5efb9298a45e7de4d8cc skid=d319e641924be93afe83eca512a1cb7ba7dbd879 invalid-before=sep/09/2022 14:07:30 invalid-after=sep
/06/2032 14:07:30 expires-after=521w2d23h58m13s
Експортуємо клієнтський сертифікат в файл формату PKCS12
/certificate export-certificate ovpn-muter type=pkcs12 export-passphrase="p@\$\$w0rd"
/file print terse where type=".p12 file" 
 0 name=cert_export_ovpn-muter.p12 type=.p12 file size=5.8KiB creation-time=sep/09/2022 14:12:52
Як бачимо, за допомогою RouterOS доволі легко керувати сертифікатами, не треба заморочуватися з будь-якими додатковими інструментами. Ну ok, поїхали далі.

Нарешті ж давайте налаштуємо OpenVPN-сервер.

І хоч OpenVPN-канали зв'язку можна налаштовувати як точка-точка, ми підемо більш "універсальним" шляхом і будемо використовувати пул адрес для наших клієнтів. Створення каналів точка-точка нехай залишиться як "домашнє завдання".

/ip pool add name=ovpn-pool ranges=192.168.120.98-192.168.120.110
/ppp profile add name=ovpn local-address=192.168.120.97 remote-address=ovpn-pool
/ppp aaa set accounting=yes
/interface ovpn-server server set auth=sha1 certificate=ovpn-server cipher=aes128,aes256 default-profile=ovpn enabled=yes netmask=28 require-client-certificate=yes
Додаємо користувачів
/ppp secret add name=muter password=PASSWORD profile=ovpn service=ovpn
Не забуваємо відкрити 1194/tcp на вхідних правилах файрволу.
/ip firewall filter add action=accept chain=input dst-port=1194 protocol=tcp
Ну от, ми налаштували OpenVPN-сервер на Mikrotik-у.

OpenVPN-сервер налаштовано, давайте тепер налаштуємо OpenVPN-клієнта.

Для початку перенесемо експортований файл сертифікату cert_export_ovpn-muter.p12 на клієнтський роутер.

Імпортуємо сертифікат.

/certificate import file-name=cert_export_ovpn-muter.p12 passphrase="p@\$\$w0rd"
     certificates-imported: 2
     private-keys-imported: 1
            files-imported: 1
       decryption-failures: 0
  keys-with-no-certificate: 0
  /certificate print terse 
 0 K     T name=cert_export_ovpn-muter.p12_0 issuer=C=UA,ST=AI,L=Irpin,O=OSBB,OU=Head,CN=ca digest-algorithm=sha256 key-type=rsa country=UA state=AI locality=Kyiv organization=Muter unit=
OpenVPN-client-00 common-name=ovpn-muter key-size=2048 subject-alt-name="" days-valid=3650 trusted=yes key-usage=tls-client serial-number=4FBA81F2BB4BB3C4 fingerprint=3f8eef1079b14c1d8147
8f22263f382ab10f21ccc5fa010d0443aa019ee7a2b0 akid=31c7dab19f80c4fa884d5efb9298a45e7de4d8cc skid=d319e641924be93afe83eca512a1cb7ba7dbd879 invalid-before=sep/09/2022 14:07:30 invalid-after=
sep/06/2032 14:07:30 expires-after=521w2d23h24m31s 
 1    A  T name=cert_export_ovpn-muter.p12_1 issuer=C=UA,ST=AI,L=Irpin,O=OSBB,OU=Head,CN=ca digest-algorithm=sha256 key-type=rsa country=UA state=AI locality=Irpin organization=OSBB unit=
Head common-name=ca key-size=8192 subject-alt-name="" days-valid=3650 trusted=yes key-usage=key-cert-sign,crl-sign serial-number=251F3D5238145BF4 fingerprint=58d9ff1808abbd38019c2e1b1d4b1
f5c71a24d41fd6fc0e7b031661e0097e0aa akid="" skid=31c7dab19f80c4fa884d5efb9298a45e7de4d8cc invalid-before=sep/09/2022 13:58:13 invalid-after=sep/06/2032 13:58:13 expires-after=521w2d23h15m
14s
А тепер просто з'єднаємося з сервером
/interface ovpn-client add certificate=cert_export_ovpn-muter.p12_0 cipher=aes256 connect-to=f97709ad83b1.sn.mynetname.net name=ovpn-out1 password=PASSWORD use-peer-dns=no user=muter
Якщо все було зроблено правильно, OpenVPN-тунель підніметься майже миттєво. Ну, а налаштування файрволу, маршрутизації, тощо - це тема для зовсім іншої розмови.

суботу, 3 вересня 2022 р.

Налаштування UserManager для WPA2-EAP на Mikrotik

Маємо RB4011iGS+5HacQ2HnD з RouterOS 6.49.6, RBcAPGi-5acD2nD з RouterOS 7.5 та 2011UiAS-2HnD з RouterOS 6.49.6.

На RBcAPGi-5acD2nD налаштовуємо сучасний UserManager (Radius-server). Відповідно RB4011iGS+5HacQ2HnD та 2011UiAS-2HnD є клієнтами для нього.

RB4011iGS+5HacQ2HnD в мережі називається master.lan з ip 192.168.88.1

2011UiAS-2HnD в мережі називається lte.lan з ip 192.168.88.2

RBcAPGi-5acD2nD в мережі називається slave.lan з ip 192.168.88.2

Поїхали.

Налаштовуємо сертифікати на slave.lan де у нас буде піднято UserManager.

/certificate settings
set crl-use=yes

/certificate

# Generating a Certificate Authority
add name=radius-ca common-name="RADIUS CA" key-size=secp384r1 digest-algorithm=sha384 days-valid=3650 key-usage=key-cert-sign,crl-sign
sign radius-ca name=radius-ca ca-crl-host=slave.lan

# Generating a server certificate for User Manager
add name=usermanager common-name=slave.lan subject-alt-name=IP:192.168.88.3 key-size=secp384r1 digest-algorithm=sha384 days-valid=3650 key-usage=tls-server,digital-signature,key-encipherment
sign usermanager name=usermanager ca=radius-ca
set usermanager trusted=yes

# Generating a client certificate
add name=eap-client common-name=eap-client days-valid=3650 key-size=secp384r1 digest-algorithm=sha384 key-usage=tls-client 
sign eap-client name=eap-client ca=radius-ca

export-certificate radius-ca file-name=radius-ca
export-certificate eap-client type=pkcs12 export-passphrase="p@\$\$word"
Налаштовуємо UserManager і прописуємо клієнтів для нього:
/user-manager
set enabled=yes certificate=usermanager

/user-manager router
add name=master.lan address=192.168.88.1 shared-secret=NDUyOTNiNWQwZjYyMzE4YTdhNmJhZTYwMThkYTdmNTEzZDdmOWQxYzhjNTY5
add name=lte.lan address=192.168.88.2 shared-secret=Yjk1MjAxMGM0Nzg2ODM0ODFjOTNmZGEzYzA3NDIyNWI4ZDU1MTNkOWRiMzY4
add name=slave.lan address=192.168.88.3 shared-secret=OTkxOTFhNDJiNGZhZmYwOWU4ZThhMDMwMzIxMTA4NjExYWVjMjVlMjMwMDFi

/user-manager user group
add inner-auths=peap-mschap2 name=eap outer-auths=eap-peap
add name=certificate-authenticated outer-auths=eap-tls

/user-manager user
add name=master.lan group=certificate-authenticated
add name=lte.lan group=certificate-authenticated
add name=slave.lan group=certificate-authenticated
Ну й додаємо безпосередньо клієнтів WPA2-EAP:
/user-manager user
add name=user_one group=eap password=super@puper_parrwosd shared-users=1
Ну й налаштовуємо radius-клієнтів. На RBcAPGi-5acD2nD:
/radius
add address=192.168.88.3 secret=OTkxOTFhNDJiNGZhZmYwOWU4ZThhMDMwMzIxMTA4NjExYWVjMjVlMjMwMDFi service=wireless src-address=192.168.88.3
/radius incoming
set accept=yes
На RB4011iGS+5HacQ2HnD:
/radius
add address=192.168.88.3 secret=NDUyOTNiNWQwZjYyMzE4YTdhNmJhZTYwMThkYTdmNTEzZDdmOWQxYzhjNTY5 service=wireless src-address=192.168.88.1
/radius incoming
set accept=yes
На 2011UiAS-2HnD:
/radius
add address=192.168.88.3 secret=Yjk1MjAxMGM0Nzg2ODM0ODFjOTNmZGEzYzA3NDIyNWI4ZDU1MTNkOWRiMzY4 service=wireless src-address=192.168.88.2
/radius incoming
set accept=yes
В принципі на цьому все, можна налаштовувати wireless на використання нашого UserManager-а.
В класичному налаштуванні wireless все просто, а в capsman-і в профілі безпеки малюємо щось накшталт:
/caps-man security
add authentication-types=wpa2-eap eap-methods=passthrough encryption=aes-ccm group-encryption=aes-ccm name=security tls-mode=no-certificates
При бажанні можна прикрутити TLS, але це тема для зовсім іншої розмови…