Zdravím všechny,
Začal jsem se učit s nftables. Celkem se mě i daří. Nemůžu ovšem za boha přijít na to jak nastavit masquardu pro firewall s dvouma lan. Přikládám konfigurační script s nftables. V tomto skriptu funguje vše až po definici NAT.
Při spuštění scriptu napíší nftables chybu ohledně požadovaného natu.
Děkuji všem za případnou radu kde mám chybu.
Začal jsem se učit s nftables. Celkem se mě i daří. Nemůžu ovšem za boha přijít na to jak nastavit masquardu pro firewall s dvouma lan. Přikládám konfigurační script s nftables. V tomto skriptu funguje vše až po definici NAT.
Kód [Vybrat]
#!/usr/sbin/nft -f
# Nft firewall for 2 nic firewall with internal network for internet acces
flush ruleset
table inet filter {
chain input { # specifakace rozhrani pro rozdeleni
type filter hook input priority 0;
iifname lo accept # vzdy povol loopbcak
iifname enp0s25 jump input_wan # 192.168.3.0/26
iifname enp4s0 jump input_lan # 172.16.1.0/24
reject with icmp type port-unreachable # refuse traffic from all other interfaces
}
chain input_wan { # pravidla pro rozhrani wan
ct state {established,related} accept
ct state invalid drop
ip saddr {192.168.3.0/26} tcp dport { 22 } log prefix "Wan SSH pripojeni:" accept
reject with icmp type port-unreachable # all other traffic
}
chain input_lan { # pravidla pro rozhrani lan
ct state {established,related} accept
ct state invalid drop
ip saddr {172.16.1.0/24} tcp dport {22} log prefix "Lan SSH pripojeni:" accept
ip protocol icmp icmp type echo-request log accept
tcp dport {domain} log prefix "DNS input pozadavek:" accept # Povoleni DNS pro interni DHCP LAN
udp dport {domain} accept
tcp dport {bootpc,bootps} log prefix "DHCP input pozadavek:" accept # povoleni DHCP z interni site
udp dport {bootpc,bootps} log prefix "DHCP input pozadavek:" accept # povoleni DHCP z interni site
counter drop
}
chain ouput { # we let everything out
type filter hook output priority 0;
tcp dport {domain} log prefix "DNS output pozadavek:" accept # Povoleni DNS pro interni site
udp dport {domain} accept
tcp dport {bootpc,bootps} log prefix "DHCP output pozadavek:" accept # povoleni DHCP replies pozadavku
udp dport {bootpc,bootps} log prefix "DHCP output pozadavek:" accept # povoleni DHCP replies pozadavku
accept
}
chain forward {
type filter hook forward priority 0;
drop
}
# NAT
table ip nat {
chain prerouting {
type nat hook prerouting priority 0; policy accept;
}
# for all packets to WAN, after routing, replace source address with primary IP of WAN interface
chain postrouting {
type nat hook postrouting priority 100; policy accept;
ip saddr 172.16.1.0/24 oif enp0s25 snat 192.168.3.22
}
}
Při spuštění scriptu napíší nftables chybu ohledně požadovaného natu.
Kód [Vybrat]
nftables.2NicFw.sh.v3:46:1-5: Error: syntax error, unexpected table
table ip nat {
^^^^^
nftables.2NicFw.sh.v3:54:52-55: Error: NAT is only supported for IPv4/IPv6
ip saddr 172.16.1.0/24 oif enp0s25 snat 192.168.3.22
Děkuji všem za případnou radu kde mám chybu.