Pavel Mikula
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Test B # Instalace DNS VM, který má nastavené: - Karta 1 - NAT - Karta 2 - Síť pouze s hostem -> bez DHCP ## Pro přehlednost <small>optional</small> ``` hostname dns ``` ## Nastavení sítě Soubor `/etc/network/interfaces` nastavím na ```bash # The loopback network interface auto lo iface lo inet loopback # Karta 1 - NAT auto enp0s3 iface enp0s3 inet dhcp # Karta 2 - Host auto enp0s8 iface enp0s8 inet static address 192.168.68.10 netmask 255.255.255.0 ``` Restartujeme -> `service networking restart` ## Dependencies ```bash apt update apt install bind9 bind9utils bind9-dnsutils ``` ## Postup Vytvořím si zone konfig pro mojí doménu `cenda.cz`: `/etc/bind/named.conf.local` ```yml zone "cenda.cz" { type master; file "/etc/bind/zones/cenda.cz.db"; }; ``` Definuji DNS nastavení: `/etc/bind/named.conf.options` ```yml options { directory "/var/cache/bind"; forwarders { 158.196.0.53; # Školní DNS # 8.8.8.8; # V případě domácí sítě }; listen-on { 127.0.0.1; 192.168.68.10; }; # Druhá IP je od tvé DNS listen-on-v6 { none; }; allow-query { any; }; recursion yes; allow-recursion { any; }; dnssec-validation no; }; ``` Vytvoříme zones složku: `mkdir /etc/bind/zones -p` Nastavíme záznamy v naši DNS `/etc/bind/zones/cenda.cz.db` ``` $TTL 3h ;doba expirace všech záznamů @ IN SOA ns1.cenda.cz. spravce.cenda.cz. ( ; autoritativní DNS server + email správce bez @ 2025111901 ; seriové číslo, často ve formě data 4h ; jak často si stahuje data sekundární server 2h ; za jak dlouho se má sek.server pokusit stáhnout data při neúspěchu 2w ; kdy platnost dat v sek.serveru vyprší 1h ) ; jak dlouho si mají data pamatovat cache servery ; @ IN NS ns1.cenda.cz. ; autoritativní servery pro doménu, musí mít i A záznamy ; Name server ns1 IN A 192.168.68.10 ; IP našeho serveru ; Mail server cenda.cz. IN MX 10 smtp.cenda.cz. ; primární emailový server smtp IN A 192.168.68.20 ; Domena cenda.cz. IN A 192.168.68.30 ; primární záznamy www IN A 192.168.68.30 wiki IN CNAME cenda.cz. ; www -> cenda.cz -> 192.168.68.30. mail IN CNAME cenda.cz. ; Servicy _http._tcp IN SRV 1 2 80 www ; _http sluzba, _tcp protokol, 1 priorita, 2 váha _smtp._tcp IN SRV 1 2 25 smtp.cenda.cz. _imap._tcp IN SRV 1 2 143 smtp.cenda.cz. *._tcp IN SRV 0 0 0 . ; ostatní služby nejsou podporovány ``` Restartujeme `service named restart` > [!Note] Druhy DNS záznamů > | Typ záznamu | vysvětlení | > |-------------|----------------------------------------------------------------------------| > | A | ipv4 záznam (překlad z domény na ipv4 adresu serveru) | > | AAAA | ipv6 záznam (překlad z domény na ipv6 adresu serveru) | > | MX | mail server záznam (mail exchange), kdo je zodpovědný za správu emailu na doméně | > | CNAME | kanonické jméno ukazující z jedné domény na druhou (nikdy neukazuje na IP), slouží pro aliasy na A záznamy | > | SRV | service record - Specifikuje servisu na doméně pod hostnamem a portem (play.tvoje_mama.cz -> 192.168.0.1:25555) | > | PTR | pointer record - Slouží pro obrácené mapování DNS, IP addresa na hostname, často in-adda.arpa. (Dokážu si tak ověřovat doménu. z > > jiné DNS jsem dostal, že google je 6.6.6.6, ale já mám pod 6.6.6.6 pornhub) | > | NS | name server, jaké DNS servery jsou autorativní pro doménu | > | SOA | root config té dns zóny (Start Of Authority) informace o DNS zoně, email na správce a její konfiguraci | ## Test Pro oveření funkčnosti si vytvořím další VM s NAT kartou. Sekundarní karta není potřebná. 1. Nastavím DNS v `/etc/resolv.conf` ``` domain vsb.cz search vsb.cz # nameserver 10.0.2.3 <- Defaultní školní, zakomentuju nameserver 192.168.68.10 # <- Můj nový ``` 2. Pak zkusím: ``` dig @<ip dns serveru> cenda.cz ping cenda.cz ``` - Dig command je z *bind9-dnsutils* - Pokud funguje, řekne ti to IP kam pinguje a dig najde server --- # Instalace Email serverů (Postfix) VM, který má nastavené: - Karta 1 - NAT - Karta 2 - Síť pouze s hostem -> bez DHCP ## Pro přehlednost <small>optional</small> ``` hostname smtp ``` ## Nastavení sítě Nastavím karty v `/etc/network/interfaces`: ```bash # The loopback network interface auto lo iface lo inet loopback # Karta 1 - NAT auto enp0s3 iface enp0s3 inet dhcp # Karta 2 - Host auto enp0s8 iface enp0s8 inet static address 192.168.68.20 netmask 255.255.255.0 ``` Nastavím taky DNS v `/etc/resolv.conf`: ``` domain vsb.cz search vsb.cz # nameserver 10.0.2.3 <- Defaultní školní nameserver 192.168.68.10 # <- Moje DNS ``` Restartujeme -> `service networking restart` ## Dependencies ``` apt install postfix ``` -> Internet Site -> cenda.cz ## Postup Nastavím konfigurace postfix v `/etc/postfix/main.cf` ```c # Optional relayhost = smtp.vsb.cz # -> Přeposílání emailu na VŠB, pokud končí @vsb.cz # Change myorigin = smtp.cenda.cz mydestination = smtp.cenda.cz, localhost.cenda.cz, cenda.cz, localhost myhostname = smtp.cenda.cz # New home_mailbox = Maildir/ ``` Vytvořím si jednoho, nebo více uživatelů pro posílání emailu na ```bash useradd -m jozko mkdir /home/jozko/Maildir/{new,tmp,cur} -p chown jozko:jozko -R /home/jozko/ ``` Na testovacím VM otestuji `telnet smtp.cenda.cz 25` ```bash HELO cenda MAIL FROM: root@cenda.cz # (je to fuk od koho) RCPT TO: jozko@cenda.cz # (client co jsme si udělali) DATA Něco si tu napiš . # Musí končit newline tečka newline ``` Na mail serveru zkontroluji, že email přišel: `cat /home/jozko/Maildir/new/...` (nech si doplnit) Příklad výpisu: ``` Return-Path: <root@cenda.cz> X-Original-To: jozko@cenda.cz Delivered-To: jozko@cenda.cz Received: from cenda (unknown [192.168.68.1]) by smtp.cenda.cz (Postfix) with SMTP id 3B27B1FF084 for <jozko@cenda.cz>; Sat, 29 Nov 2025 12:06:06 -0600 (CST) Něco si tu napiš ``` Pokud jsem dostal errory, najdu si log v journalu -> `journalctl -u postfix` ### Aliasy v mailu Alias - přesměruje příjemce (jen příchozí, ne odchozí), nesahá na hlavičku. (např. `rektor@vsb.cz`, skupinové jako "rektor: pepa@cenda.cz, karel@cenda.cz, lojza@cenda.cz") V `/etc/aliases` vytvořím aliasy: ``` rektor: jozko@cenda.cz # rektor@cenda.cz -> jozko@cenda.cz admin: root, jozko # Funguje i bez @... využívá pak default doménu ``` Potvrzení -> `newaliases` ### Kanonické mapování Upravuje přímo hlavičku; oddělí login od adresy, takže je bezpečnější. Uživatel je skrytý za stringem, který jen mail server ví. Pošlu email na jozka.ponozka.st@cenda.cz, reálně přijde na jozko@cenda.cz, `jozko` je vytvořený uživatel v systému díky čemuž nikdo nikdy neví, jak se přihlásit na můj email. pokud neví můj login `jozko` V `/etc/postfix/main.cf` přidám ``` sender_canonical_maps = hash:/etc/postfix/sender_canonical recipient_canonical_maps = hash:/etc/postfix/recipient_canonical ``` Překlad odesílatele v */etc/postfix/sender_canonical*, odešlu pošlu z **jozko@cenda.cz** ale, dané adrese přijde, že jsem poslal z **jozko.ponozka.st@cenda.cz** ``` jozko@cenda.cz jozko.ponozka.st@cenda.cz ``` Překlad posílatele v */etc/postfix/recipient_canonical*, pokud mi přijde na **jozko.ponozka.st@cenda.cz**, tak to najde správně přijemce **jozko@cenda.cz** ``` jozko.ponozka.st@cenda.cz jozko@cenda.cz ``` Vytvořím DB files pomocí `postmap /etc/postfix/sender_canonical && postmap /etc/postfix/recipient_canonical` Vyzkouším `postmap -q "jozko.ponozka.st@cenda.cz" hash:/etc/postfix/recipient_canonical` Měl bych dostat překlad na `jozko@cenda.cz`, pokud prohodím soubory. Mám to naopak. ### Instalace IMAP (dovecot) Na serveru si nainstaluji package: ```bash apt update apt install dovecot-imapd dovecot-core ``` Upravím si konfiguraci, tak aby používala **Maildir** místo **mbox** v `/etc/dovecot/conf.d/10-mail.conf` ```c mail_driver = maildir mail_path = ~/Maildir #mail_inbox_path = ~/Maildir/.INBOX #mail_driver = mbox #mail_home = /home/%{user | username} #mail_path = %{home}/mail #mail_inbox_path = /var/mail/%{user} ``` Odkomentuji v `/etc/dovecot/conf.d/10-auth.conf`, abych se mohl přihlásit heslem v plainu: ``` auth_allow_cleartext = yes auth_mechanisms = plain login ``` Odkomenuji port v `/etc/dovecot/conf.d/10-master.conf`, jinak IMAP neposlouchá defaultně: ``` service imap-login { inet_listener imap { port = 143 } ... } ``` Restartuji service `systemctl restart dovecot` Zkontoluji zda IMAP běží `ss -tuln | grep 143` -> očekávaný výstup: ``` tcp LISTEN 0 100 0.0.0.0:143 0.0.0.0:* tcp LISTEN 0 100 [::]:143 [::]:* ``` Jelikož jsem vytvořil uživatele bez hesla, nastavím mu ho `passwd jozko` -> heslo: jozko Na testovacím klientovi otestuji čtení pošty, použiju: `telnet smtp.cenda.cz 143` ``` a login jozko jozko # Přihlasím se a select INBOX # Zvolím inbox a fetch 1:* body[] # Přečtu první zprávu -> Pokud vidím že poštu mám, jinak háže error a logout # Odpojím se ``` --- # Instalace LAMP serveru (Linux Apache Mysql Php) VM, který má nastavené: - Karta 1 - NAT - Karta 2 - Síť pouze s hostem -> bez DHCP ## Pro přehlednost <small>optional</small> ``` hostname lamp ``` ## Nastavení sítě `/etc/network/interfaces` ```bash # The loopback network interface auto lo iface lo inet loopback # Karta 1 - NAT auto enp0s3 iface enp0s3 inet dhcp # Karta 2 - Host auto enp0s8 iface enp0s8 inet static address 192.168.68.30 netmask 255.255.255.0 ``` Restartujeme -> `service networking restart` ## Dependencies `apt install apache2 mariadb-server mariadb-client libapache2-mod-php` Vyzkouším otevřít odkaz 192.168.68.30 -> Ukáže se mi default page apache. ### Instalace Roundcube `apt install roundcube roundcube-plugins roundcube-mysql` -> ano -> heslo *roundcube* Vytvořím virtual host v `/etc/apache2/sites-available/mail.cenda.cz.conf` ```xml <VirtualHost *:80> ServerName mail.cenda.cz DocumentRoot /var/lib/roundcube <Directory /var/lib/roundcube> Options -Indexes AllowOverride All Require all granted </Directory> ErrorLog ${APACHE_LOG_DIR}/mail_error.log CustomLog ${APACHE_LOG_DIR}/mail_access.log combined </VirtualHost> ``` Aktivujeme hosta a restartujeme apache2: ``` a2ensite mail.cenda.cz systemctl reload apache2 ``` Zkontroluji config databáze v `/etc/roundcube/debian-db.php` ```c $dbuser='roundcube'; $dbpass='roundcube'; $basepath=''; $dbname='roundcube'; $dbserver='localhost'; $dbport='3306'; $dbtype='mysql'; ``` Upravím roundcube config v `/etc/roundcube/config.inc.php` ```c $config['imap_host'] = ["smtp.cenda.cz:143"]; $config['smtp_host'] = 'smtp.cenda.cz:25'; $config['smtp_user'] = ''; $config['smtp_pass'] = ''; ``` Pokud je něco špatně najdu to v `/var/log/apache2/mail_error.log` ### Instalace MediaWiki ```bash apt install php php-mysql php-intl php-xml php-mbstring php-gd php-curl php-apcu mariadb-client ``` Vytvořím databázového uživatele pro mediawiki: ```bash mariadb CREATE USER 'wikiuser'@'localhost' IDENTIFIED BY 'silne_heslo'; GRANT ALL PRIVILEGES ON *.* TO 'wikiuser'@'localhost'; FLUSH PRIVILEGES; EXIT; ``` > Uživatel si sám vytvoří svojí databázi, proto mu musím dát `*.*`, jinak pičus křičí. 🤬 Stažení wiki: ```bash cd /tmp wget https://releases.wikimedia.org/mediawiki/1.44/mediawiki-1.44.2.tar.gz tar -xzf mediawiki-1.44.2.tar.gz mkdir -p /var/www/wiki mv mediawiki-1.44.2/* /var/www/wiki/ ``` Vytvořím virtual host v `/etc/apache2/sites-available/wiki.cenda.cz.conf` ```xml <VirtualHost *:80> ServerName wiki.cenda.cz DocumentRoot /var/www/wiki <Directory /var/www/wiki> Options FollowSymLinks AllowOverride All Require all granted </Directory> ErrorLog ${APACHE_LOG_DIR}/wiki_error.log CustomLog ${APACHE_LOG_DIR}/wiki_access.log combined </VirtualHost> ``` Aktivujeme hosta a restartujeme apache2 ```bash a2ensite wiki.cenda.cz a2enmod rewrite # Povolení rewrite modulu (přesměrování) systemctl reload apache2 ``` Jdeme na naši wiki stránku a požádáme kouzelníka o instalaci. Po úspěšné instalaci pomocí kouzelníka, tak uložím stažený soubor do `/var/www/wiki/LocalSettings.php` Refresh stránky a jsem happy jak dva grepy.

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully