Skip to content

Instantly share code, notes, and snippets.

@alexesDev
Last active September 20, 2017 06:55
Show Gist options
  • Save alexesDev/2888fd9dd2ea548712d91ff3ac25cd65 to your computer and use it in GitHub Desktop.
Save alexesDev/2888fd9dd2ea548712d91ff3ac25cd65 to your computer and use it in GitHub Desktop.
#!/bin/bash
ADDR=$1
echo $ADDR
firewall-cmd --permanent --zone=drop --add-rich-rule="
rule family='ipv4'
source address=${ADDR}
port protocol='tcp' port='2377' accept"
firewall-cmd --permanent --zone=drop --add-rich-rule="
rule family='ipv4'
source address=${ADDR}
port protocol='tcp' port='7946' accept"
firewall-cmd --permanent --zone=drop --add-rich-rule="
rule family='ipv4'
source address=${ADDR}
port protocol='udp' port='7946' accept"
firewall-cmd --permanent --zone=drop --add-rich-rule="
rule family='ipv4'
source address=${ADDR}
port protocol='udp' port='4789' accept"
#!/bin/bash
ADDR=$1
echo $ADDR
iptables -I INPUT -p tcp -s $ADDR --dport 2377 -j ACCEPT
iptables -I INPUT -p tcp -s $ADDR --dport 7946 -j ACCEPT
iptables -I INPUT -p udp -s $ADDR --dport 7946 -j ACCEPT
iptables -I INPUT -p udp -s $ADDR --dport 4789 -j ACCEPT
@alexesDev
Copy link
Author

alexesDev commented Sep 20, 2017

firewall-cmd --zone=drop --add-service=ssh --permanent
firewall-cmd --zone=drop --change-interface=eth0
firewall-cmd --set-default-zone=drop
firewall-cmd --reload

@alexesDev
Copy link
Author

alexesDev commented Sep 20, 2017

firewall-cmd --list-all | grep 'rule fam' | xargs -L 1 -I{} -- firewall-cmd --permanent --zone=drop --remove-rich-rule='{}'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment