Skip to content

Instantly share code, notes, and snippets.

@roramirez
Created May 21, 2016 19:21
Show Gist options
  • Save roramirez/25e355ed6f4e915748e3277c6e157a14 to your computer and use it in GitHub Desktop.
Save roramirez/25e355ed6f4e915748e3277c6e157a14 to your computer and use it in GitHub Desktop.
Log Bash script firewall
root@vagrant-ubuntu-trusty-32:~# wget https://gist.githubusercontent.com/roramirez/b43bbef3b7944e771dfc/raw/ce39b289b4f07512ca97f38eb4320c496e21678b/simple_iptables_firewall_init.sh
--2016-05-21 15:19:05-- https://gist.githubusercontent.com/roramirez/b43bbef3b7944e771dfc/raw/ce39b289b4f07512ca97f38eb4320c496e21678b/simple_iptables_firewall_init.sh
Resolving gist.githubusercontent.com (gist.githubusercontent.com)... 23.235.47.133
Connecting to gist.githubusercontent.com (gist.githubusercontent.com)|23.235.47.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1869 (1.8K) [text/plain]
Saving to: ‘simple_iptables_firewall_init.sh’
100%[=========================================================================================================================================>] 1,869 --.-K/s in 0s
2016-05-21 15:19:11 (141 MB/s) - ‘simple_iptables_firewall_init.sh’ saved [1869/1869]
root@vagrant-ubuntu-trusty-32:~# mv simple_iptables_firewall_init.sh /etc/init.d/firewall
root@vagrant-ubuntu-trusty-32:~# chmod x /etc/init.d/firewall
chmod: invalid mode: ‘x’
Try 'chmod --help' for more information.
root@vagrant-ubuntu-trusty-32:~# chmod +x /etc/init.d/firewall
root@vagrant-ubuntu-trusty-32:~# /etc/init.d/firewall start
* Starting Firewall ... root@vagrant-ubuntu-trusty-32:~# /etc/init.d/firewall stop
* Stopping Firewall ... root@vagrant-ubuntu-trusty-32:~# /etc/init.d/firewall reload
* Reloading Rules root@vagrant-ubuntu-trusty-32:~# cat /etc/issue
Ubuntu 14.04 LTS \n \l
root@vagrant-ubuntu-trusty-32:~# /etc/init.d/firewall status
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- 1.1.1.1 2.2.2.2 tcp spts:1024:65535 dpt:mysql state NEW,ESTABLISHED
REJECT tcp -- anywhere anywhere tcp dpt:mysql reject-with icmp-port-unreachable
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- 1.1.1.1 anywhere tcp spt:mysql dpts:1024:65535 state ESTABLISHED
Chain PREROUTING (policy ACCEPT)
target prot opt source destination
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain POSTROUTING (policy ACCEPT)
target prot opt source destination
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment