Firwall 5105

Aus Xinux Wiki
Zur Navigation springen Zur Suche springen

Erklärung

  • TN = 200 + Platznummer
  • HS = Klassensaal

Hostname

Grundkonfiguration
  • debian-setup.sh -f fw.it213.int -a 192.168.HS.TN/24 -g 192.168.HS.254. -n 1.1.1.1
  • reboot
Weitere Interfaces
  • cat /etc/network/interfaces
auto lo
iface lo inet loopback

auto enp0s3
iface enp0s3 inet static
 address 192.168.HS.TN/24
 gateway 192.168.HS.254
 post-up ip route add 10.88.0.0/16 via 192.168.HS.88

auto enp0s8
iface enp0s8 inet static
 address 172.26.TN.1/24

auto enp0s9
iface enp0s9 inet static
 address 10.88.TN.1/24

NAT mit nftables

  • cat /etc/nftables.conf
#!/usr/sbin/nft -f

# Variablen
define LAN = 172.26.TN.0/24
define DMZ = 10.88.TN.0/24

# Alte Regeln löschen (flush)
flush ruleset

# NAT-Tabelle erstellen/verwenden
table ip nat {
    chain postrouting {
        type nat hook postrouting priority 100; policy accept;
        
        # DMZ nach 192.168.HS.0/24 - kein NAT (RETURN)
        ip saddr $DMZ ip daddr 192.168.HS.0/24 return
        
        # DMZ nach 10.88.0.0/16 - kein NAT (RETURN)
        ip saddr $DMZ ip daddr 10.88.0.0/16 return
        
        # DMZ nach außen (enp0s3) - Masquerade
        ip saddr $DMZ oif enp0s3 masquerade
        
        # LAN nach außen - Masquerade
        ip saddr $LAN oif enp0s3 masquerade
        
    }
}

Tests

Manuelles aktivieren
  • nft -f /etc/nftables.conf
Anzeigen
  • nft list ruleset
Löschen
  • nft flush ruleset

Aktivieren

  • systemctl enable nftables.service

Forward

  • echo "net.ipv4.ip_forward=1" | sudo tee /etc/sysctl.d/99-ip-forward.conf
  • sudo sysctl -p /etc/sysctl.d/99-ip-forward.conf

Resolver

  • cat /etc/resolv.conf
search it213.int
nameserver 192.168.9.88 

Reboot

  • sudo systemctl reboot