If it is not explicitly told in following recipe, setting up services are described for Ubuntu 16.04 server, but applications are described for Ubuntu 16.04 and/or Lubuntu 16.04 workstation. If you use different Ubuntu version or Linux distribution, settings as well as content, names and places of configuration files may be different!
Got it.

Iptables pakešu filtrēšanas pārvaldības lietotne

See also:  Ufw ugunssiena

Iptables ir Linux standarta pakešu filtrēšanas ietvara konfigurācijas lietotne.
Ar to var veikt "stāvokļjūtīgu" pakešu filtrēšanu, adrešu translāciju u.c.
# Following picture shows packet processing sequence of tables and rules
# lowercase - tables, UPPERCASE - CHAINS
#
#                 Network
#                   |
#                  raw
#                 mangle
#                  nat
#               PREROUTING
#                   |
#      -------<routing decision>--------
#      |                               |
#    mangle                            |
#    filter                            |
#    INPUT                             |
#      |                               |
#  Local process                       |
# <routing decision>                   |
#      |                               |
#     raw                            mangle
#    mangle                          filter
#     nat                            FORWARD
#    filter                            |
#    OUTPUT                            |
#      |                               |
#      ---------------------------------
#                   |
#                 mangle
#                  nat
#               POSTROUTING
#                   |
#                Network
#

Pakešu pārvaldības piemēri

  1. iptables -L parāda filtrēšanas likumus noklusētajai tabulai
  2. iptables -L -t mangle parāda filtrēšanas likumus mangle tabulai
  3. Likumu pievienošana un dzēšana:

    iptables -A INPUT -p icmp -j ACCEPT
    iptables -D INPUT -p icmp -j ACCEPT
    iptables -A INPUT -p icmp -j REJECT --reject-with icmp-host-prohibited
  4. Likumu izdzēš ar:

    iptables -D INPUT -p icmp -j REJECT --reject-with icmp-host-prohibited
  5. Pievieno likumu, kas paketi nomet:

    iptables -A INPUT -p icmp -j DROP
  6. Pievieno likumu, kas nomet paketi uz 22 portu:

    iptables -A INPUT -p tcp --dport 22 -j DROP

Konfigurēšana

  1. Ja  nav izveidot, izveido mapi /home/bin:

    mkdir /home/bin
  2. root izveido failu /home/bin/iptables.rules, padara šo failu izpildāmu:

    touch /home/bin/iptables.rules
    chmod 700 /home/bin/iptables.rules
  3. Izveido faila saturu, ņemot par piemēru:
    1. piemērs darbstacijai ar vmware
    2. triviāls maršrutētāja piemērs
    3. piemērs serverim
    4. piemērs serverim ar divām publiskā tīkla saskarnēm
    5. Portu pārsūtīšana ar iptables
  4. Izpilda šo failu:

    /home/bin/iptables.rules
  5. Pārbauda ar komandu:

    iptables -L -nv
    watch 'iptables -L -nv'
  6. Iptables inicializācijas skripts

Saites


  
Created by Valdis Vītoliņš on 2008-08-09 13:28
Last modified by Valdis Vītoliņš on 2020-04-06 13:42
 
Xwiki Powered
Creative Commons Attribution 3.0 Unported License