LoginSignup
7
7

More than 5 years have passed since last update.

IPアドレスを用いてアクセス制限をする(Centos7, firewalld)

Last updated at Posted at 2016-04-08

参考:http://nullpopopo.blogcube.info/2015/01/firewalld-deny-tips.html
参考:http://www.unix-power.net/centos7/firewalld.html

firewalldでは事前にゾーンを定義し、ゾーンごとに許可するサービスを定義する。
ゾーンの確認。

firewall-cmd --get-zones

デフォルトでは下記のようなゾーンがある。

block(変更不可):全てのパケットを破棄しますが内部から外部への戻りパケットは許可されます。
dmz:デフォルトで「ssh」のみ許可されています。
drop(変更不可):全てのパケットを破棄します。現実的に使用されることはありません。
external:デフォルトで「ssh」のみ許可されています。IPマスカレードが有効になっています。
home:デフォルトで「dhcpv6-client」,「ipp-client」,「mdns」,「samba-client」,「ssh」が許可されています。
internal:デフォルトで「dhcpv6-client」,「ipp-client」,「mdns」,「samba-client」,「ssh」が許可されています。
public:デフォルトゾーンです。デフォルトで「shh」と「dhcpv6-client」のみ許可されています。
trusted(変更不可):全てのパケットが許可されます。
work:デフォルトで「dhcpv6-client」,「ipp-client」,「 ssh」が許可されています。

特定のIPアドレスをdropゾーンに入れる。

firewall-cmd --zone=drop --permanent --add-source=[IPアドレス]

dropゾーンに入れた設定が反映されているか確認。

firewall-cmd --get-active-zones

dropゾーンに入れた設定を解除。

firewall-cmd --zone=drop --permanent --remove-source=[IPアドレス]

7
7
2

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
7
7