0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

CentOS8 firewalld iptables 肝

0
Posted at

firewalldとiptablesの違いは他のページで沢山説明されているのでここでは省略w

長年使用していたCentOS6もそろそろ限界(セキュリティ的に)だし、使用しているマシンも限界だし次の10年に向けてリニューアルを考え、CentOS8への移行準備中に解った肝の部分を公開。
公開と言うと自分的には大げさなんだが、まぁ、誰かの助けになればと言うことです。

今回、自宅サーバ環境で必須のファイアウォールを一新することにもなるのでまずはそこから。

現行はCentOS6のiptables PREROUTINGを使って基本的なポート管理。
CentOS7からこのiptablesがfirewalldになって使いやすくなったということで、ならば試すかという次第。

ネットでfirewalld PREROUTINGを探るも、皆さま苦労してるのねという結果と
実際にそれを試して、あ~こうなっちゃうのねという理解から、これで良し!ということまで漕ぎつけたので公開します。(思考錯誤、Try and Error、楽しかった)

では結論。
iptables PREROUTINGは忘れましょう。PREROUTINGという言葉も忘れましょう。
firewalldではrich ruleを使います。

firewall-cmd --list-all --zone=external

   external (active)
   target: default
   icmp-block-inversion: no
   interfaces: eth0
   sources:
   services: ssh
   ports:
   protocols:
   masquerade: yes
   forward-ports:
   source-ports:
   icmp-blocks:
   rich rules: <-- here!

firewall-cmd --permanent --zone=external --add-rich-rule 'rule family=ipv4 forward-port port=22 protocol=tcp to-port=22 to-addr=172.xx.xx.1'

   defGW
    ↑
	□  zone=external
/------------+
| Firewall-1 | □ zone=dmz(172.xx.xx.3) 
+------------/
	□ zone=internal

上記で、externalに届いたport22 sshパケットは172.xx.xx.1へ届けられた。
当然接続確認済。

   external (active)
   target: default
   icmp-block-inversion: no
   interfaces: eth0
   sources:
   services: ssh
   ports:
   protocols:
   masquerade: yes
   forward-ports:
   source-ports:
   icmp-blocks:
   rich rules:
         rule family="ipv4" forward-port port="22" protocol="tcp" to-port="22" to-addr="172.xx.xx.1"

今回は、ここまで。 2019/11/20

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?