SLIDE 11 11
nft nft ' 'add add chain chain ip ip mytable mytable myoutputchain myoutputchain { type filter hook { type filter hook output
priority 1; policy drop drop; }' ; }'
nft nft add add rule rule mytable mytable myinputchain myinputchain iifname iifname enp0s3 enp0s3 tcp tcp sport 1024 sport 1024-
65535 tcp tcp dport dport 23 23 ip ip saddr saddr 0.0.0.0/0 0.0.0.0/0 ip ip daddr daddr 192.168.4.1/32 192.168.4.1/32 accept accept nft nft add add rule rule mytable mytable myoutputchain myoutputchain oifname
enp0s3 tcp tcp sport 23 sport 23 tcp tcp dport dport 1024 1024-
65535 ip ip saddr saddr 192.168.4.1 192.168.4.1 ip ip daddr daddr 0.0.0.0/0 0.0.0.0/0 accept accept
nft nft ' 'add add chain chain ip ip mytable mytable myinputchain myinputchain { type filter hook { type filter hook input input priority 1; policy priority 1; policy drop drop; }' ; }'
A 2 A 2-
chain, 2
2-
rule filtering firewall
filtering firewall
- n telnet server 192.168.4.1
- n telnet server 192.168.4.1
Executed in chronological sequence as shown, resultant 2-rule firewall permits telnet request into this machine 192.168.4.1 from others via enp0s3, and reply from it out to them. And nothing else. (0.0.0.0/0 matches any address; aa.bb.cc.dd/32, the single address aa.bb.cc.dd)
create 2 chains, for input and
- utput, with default "drop"
but accept incoming to port 23 and outgoing from port 23
address translations: address translations: rules that alter packet
rules that alter packet
NAT (source network address translation)
nft nft add add rule rule mynat mynat mypostrouting mypostrouting ip ip saddr saddr 192.168.4.0/24 192.168.4.0/24 oif
enp0s10 snat snat 10.0.0.195 10.0.0.195
Port forwarding (destination network address translation)
nft nft add add rule rule mynat mynat myprerouting myprerouting iif iif enp0s10 enp0s10 tcp tcp dport dport 23 23 dnat dnat 192.168.4.1 192.168.4.1 given (table and chains): given (table and chains):
nft nft add table add table mynat mynat nft nft 'add chain 'add chain mynat mynat mypostrouting mypostrouting { type { type nat nat hook hook postrouting postrouting priority 100 ; }' priority 100 ; }' nft nft 'add chain 'add chain mynat mynat myprerouting myprerouting { type { type nat nat hook hook prerouting prerouting priority priority -
100; }'