Cheat Sheet

Thursday, January 5, 2017

CentOS/Fedora/Ubuntu (FirewallD/ufw) allow specific port from specific IP

I wanted to allow only certain port incoming from certain IP
Rich rules for FirewallD (CentOS 7+ or Fedora)
firewall-cmd --permanent --add-rich-rule='rule family=ipv4 source address=10.X.X.X/32 port port=6556 protocol=tcp accept'
or for full,
sudo firewall-cmd --permanent --add-rich-rule='rule family=ipv4 source address=10.X.X.X/32 port port=6556 protocol=tcp accept' && sudo firewall-cmd --reload
For Ubuntu with UFW;
sudo ufw allow from 10.X.X.X/32 to any port 6556

No comments:

Post a Comment