first commit: import form prod

This commit is contained in:
Adrien Marquès 2019-08-03 11:21:34 +02:00
commit 3160c6effe
3 changed files with 67 additions and 0 deletions

7
LICENSE Normal file
View File

@ -0,0 +1,7 @@
Copyright 2019 xdrm-brackets <xdrm.brackets.dev@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

45
opt/firewall/example.fw Normal file
View File

@ -0,0 +1,45 @@
#!/bin/bash
# 1/ flush all
printf "flush\n";
iptables -F;
ip6tables -F;
# 2/ default policies
printf "set default policy (drop)\n";
iptables -P FORWARD DROP; #WARN
ip6tables -P FORWARD DROP; #WARN
iptables -P INPUT DROP;
ip6tables -P INPUT DROP;
iptables -P OUTPUT ACCEPT;
ip6tables -P OUTPUT ACCEPT;
# 3/ allow localhost
iptables -A INPUT -i lo -j ACCEPT;
iptables -A FORWARD -i lo -j ACCEPT;
ip6tables -A INPUT -i lo -j ACCEPT;
ip6tables -A FORWARD -i lo -j ACCEPT;
# 4/ allow ping
iptables -A INPUT -p icmp -j ACCEPT;
ip6tables -A INPUT -p icmp -j ACCEPT;
# 5/ allow ssh
iptables -A INPUT -p tcp --dport 22 -j ACCEPT;
ip6tables -A INPUT -p tcp --dport 22 -j ACCEPT;
# 5/ allow http
iptables -A INPUT -p tcp --dport 80 -j ACCEPT;
ip6tables -A INPUT -p tcp --dport 80 -j ACCEPT;
# 6/ allow https
iptables -A INPUT -p tcp --dport 443 -j ACCEPT;
ip6tables -A INPUT -p tcp --dport 443 -j ACCEPT;
# x/ keep established connections
printf "keep established connections\n";
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT;

View File

@ -0,0 +1,15 @@
[Unit]
Description=Firewall autoconf (%i)
Before=network-pre.target
Wants=network-pre.target
[Service]
User=root
Group=root
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/bash /opt/firewall/%i.fw
[Install]
WantedBy=multi-user.target