Selected from Linux Selected from PHP
- Ubuntu 17.10 Install google's mod pagespeed for apache - PHP-Ubuntu-Youtube-dl simple script for converting and downloading youtube video or mp3
- Ubuntu SSH tunnel via proxy - PHP while loop with every row with a different color
- Install GoAccess Apache Log Analyzer Tool on Ubuntu 17.10 - PHP use while loop in function
- SSHFS and map folder with a proxy - PHP List Files And Folders As links
- How to connect to SSH server with a proxy - PHP Extract Text From String
➥ A simple iptables firewall script to block all ports except port 80 and give port 22 to certain ip's
Added by sonik on 08-05-2017 and keywords: sbin, iptables, firewall, script, block, all, ports, except, 80, specific, ip, for, 22 [ Print Article ]
This simple script is very useful and very simple and will give you the basics of what you can do with linux iptables firewall.

Make a file:
pico /root/

Paste all the info and correct the ip addresses with you owns.
iptables -P FORWARD DROP # we aren't a router
iptables -A INPUT -m state --state INVALID -j DROP
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -s -j ACCEPT
iptables -A INPUT -s -j ACCEPT
iptables -P INPUT DROP # Drop everything we don't accept
iptables -A INPUT -p tcp --dport 80 -j ACCEPT

Give it some permissions
chmod 777 /root/

And run the script.

Now this was tested in ubuntu 17.04 but if you have problems with the destination of the iptables you can try adding sbin/iptables.
You can list all the active iptables rules with the command
iptables -L

-L is capital.

@All rights reserved with Copyright 2018 by Sonik_Blast [ Site Map ] [ RSS ] [ YouTube Mp3 Downloader and converter ]