Armadilloフォーラム

ファイアーウォール設定後 apt updateできない

mod-mm

2020年8月27日 17時20分

iptablesでファイアーウォール設定後、apt update出来なくなりました。
ファイアーウォールの設定をしないと、apt updateは出来ます。
恐れ入りますが、原因と対策を教えていただけないでしょうか?

・設定は以下になります。
# デフォルトポリシーを設定
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT DROP

# ループバックを許可する
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT

# すでにコネクションを確立しているものは許可
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

# 新規の接続リクエストを許可 SSH(22), HTTP(80), HTTPS(443)
iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT

・結果は以下になりました。
root@armadillo:~# apt update
Err:1 http://security.debian.org stretch/updates InRelease
Temporary failure resolving 'security.debian.org'
Err:2 http://ftp.jp.debian.org/debian stretch InRelease
Temporary failure resolving 'ftp.jp.debian.org'
Err:3 http://download.atmark-techno.com/debian stretch InRelease
Temporary failure resolving 'download.atmark-techno.com'
Err:4 http://download.atmark-techno.com/debian stretch-backports InRelease
Temporary failure resolving 'download.atmark-techno.com'
Reading package lists... Done
Building dependency tree
Reading state information... Done
44 packages can be upgraded. Run 'apt list --upgradable' to see them.
W: Failed to fetch http://ftp.jp.debian.org/debian/dists/stretch/InRelease Temp
orary failure resolving 'ftp.jp.debian.org'
W: Failed to fetch http://security.debian.org/dists/stretch/updates/InRelease T
emporary failure resolving 'security.debian.org'
W: Failed to fetch http://download.atmark-techno.com/debian/dists/stretch/InRele
ase Temporary failure resolving 'download.atmark-techno.com'
W: Failed to fetch http://download.atmark-techno.com/debian/dists/stretch-backpo
rts/InRelease Temporary failure resolving 'download.atmark-techno.com'
W: Some index files failed to download. They have been ignored, or old ones used
instead.

お手数ですが、よろしくお願いいたします。

コメント

at_akihito.irie

2020年8月27日 18時17分

入江です。

DNSへの問い合わせができなくなっているようです。
また、DNSで名前解決ができてもaptのリポジトリにアクセスできなくなってし
まっているため、httpのOUTPUTも許可する必要があります。

以下の2つの設定を加えて再確認していただいてもよろしいでしょうか。

iptables -A OUTPUT -p udp -m state --state NEW -m udp --dport 53 -j ACCEPT
iptables -A OUTPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT

mod-mm

2020年8月31日 11時45分

入江様

ご回答ありがとうございます。
ご指摘の設定を行ったところ、無事にapt updateが出来るようになりました。
お忙しい中ありがとうございました。