Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Set the default policies to allow everything while we set up new rules
- # Prevents cutting yourself off when running from remote SSH
- iptables -P INPUT ACCEPT
- iptables -P FORWARD ACCEPT
- iptables -P OUTPUT ACCEPT
- # Flush any existing rules, leaving just the defaults
- iptables -F
- iptables -X
- iptables -t nat -F
- iptables -t nat -X
- iptables -t mangle -F
- iptables -t mangle -X
- # Open port 22 only for incoming SSH connections
- iptables -A INPUT -p tcp --dport 22 -j ACCEPT
- # accept any localhost (loopback) calls
- iptables -A INPUT -i lo -j ACCEPT
- # allow any existing connection to remain
- iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
- # reset the default policies to stop all incoming and forward requests
- iptables -P INPUT DROP
- iptables -P FORWARD DROP
- # accept any outbound requests from this server
- iptables -P OUTPUT ACCEPT
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement