By default there are no netfilter rules:
Restart the server and check that the rules are still active.
admin@host:~$ sudo iptables -L Chain INPUT (policy ACCEPT) target prot opt source destination Chain FORWARD (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination
admin@host:~$ cat it.sh iptables -A OUTPUT -o eth0 -p tcp --dport 27017 -m owner --uid-owner user -j REJECT
admin@host:~$ sudo iptables-apply -c ./it.sh Running command './it.sh'... done. Can you establish NEW connections to the machine? (y/N) y ... then my job is done. See you next time.
user@host:~$ telnet mongodb0.host 27017 Trying *.*.*.*... telnet: Unable to connect to remote host: Connection refused
admin@host:~$ sudo iptables -L --line-numbers Chain INPUT (policy ACCEPT) num target prot opt source destination Chain FORWARD (policy ACCEPT) num target prot opt source destination Chain OUTPUT (policy ACCEPT) num target prot opt source destination 1 REJECT tcp -- anywhere anywhere tcp dpt:27017 owner UID match user reject-with icmp-port-unreachable
admin@host:~$ sudo apt install iptables-persistent
admin@host:~$ sudo sh -c "iptables-save > /etc/iptables/rules.v4"
No comments:
Post a Comment