LoginSignup
1
0

More than 5 years have passed since last update.

firewalldの設定例(CentOS7)

Last updated at Posted at 2018-12-06

1つのサーバーに、DNS, Mailサーバー, Webサーバー, 監視用としてZabbix Agentをインストールしている場合。

現在の設定確認

firewall-cmd --info-zone=public --permanent

世界中にオープンにするサービス (DNS,Web,Mail)

firewall-cmd --add-service=dns --zone=public --permanent
firewall-cmd --add-service=http --zone=public --permanent 
firewall-cmd --add-service=https --zone=public --permanent 
firewall-cmd --add-service=smtp --zone=public --permanent
firewall-cmd --add-service=smtps --zone=public --permanent
firewall-cmd --add-service=smtp-submission --zone=public --permanent
firewall-cmd --add-service=imap --zone=public --permanent
firewall-cmd --add-service=imaps --zone=public --permanent
firewall-cmd --add-service=pop3 --zone=public --permanent
firewall-cmd --add-service=pop3s --zone=public --permanent

アクセス元IPとポートを限定して許可するサービス (ssh,zabbix-agent)

firewall-cmd --remove-service=ssh --zone=public --permanent
firewall-cmd --permanent --zone=public --add-rich-rule="rule family="ipv4" source address="198.51.100.0/24" port protocol="tcp" port="22" accept"
firewall-cmd --permanent --zone=public --add-rich-rule="rule family="ipv6" source address="2001:DB8:4E:1000::/64" port protocol="tcp" port="22" accept"
firewall-cmd --permanent --zone=public --add-rich-rule="rule family="ipv4" source address="203.0.113.0/24" port protocol="tcp" port="22" accept"
firewall-cmd --permanent --zone=public --add-rich-rule="rule family="ipv6" source address="2001:DB8:400:900::/64" port protocol="tcp" port="22" accept"
firewall-cmd --permanent --zone=public --add-rich-rule="rule family="ipv4" source address="192.0.2.0/24" port protocol="tcp" port="10050" accept"

アクセス元IPはすべてのポートでオープンする場合

firewall-cmd --add-source=192.0.2.0/24 --zone=public --permanent

アクセス元を拒否したい場合

firewall-cmd --add-source=192.0.2.0/24 --zone=drop --permanent

設定を保存しfirewalldをリロード

firewall-cmd --reload
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0