Debian 8 サーバーでポート 443 を開こうとすると、許可拒否エラーが発生します。
私のRules.v4ファイルは次のとおりです。
# Generated by iptables-save v1.4.21 on Wed Feb 15 14:42:03 2017
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [208710:151335680]
-A INPUT -p icmp -m comment --comment "000 accept all icmp" -j ACCEPT
-A INPUT -i lo -m comment --comment "001 accept all to lo interface" -j ACCEPT
-A INPUT -m comment --comment "002 accept related established rules" -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m multiport --dports 22 -m comment --comment "099 allow ssh access" -j ACCEPT
-A INPUT -p tcp -m multiport --dports 80,443 -m comment --comment "100 allow http and https access" -j ACCEPT
-A INPUT -p tcp -m multiport --dports 1122 -m comment --comment "150 allow phpmyadmin access" -j ACCEPT
-A INPUT -m comment --comment "999 drop all" -j DROP
COMMIT
# Completed on Wed Feb 15 14:42:03 2017
変更後に/etc/iptables/rules.v4
保存しようとしています。
sudo iptables-save > /etc/iptables/rules.v4
エラーメッセージが表示されます-bash: /etc/iptables/rules.v4: Permission denied
ファイルが存在するときsudo bash -C "iptables-save > /etc/iptables/rules.v4"
i getを試してみました。no such file or directory
私も試しましたtee
sudo tee iptables-save > /etc/iptables/rules.v4
そして
sudo sh -c "iptables-save > /etc/iptables/rules.v4"
これはnetstat -tulnp | grep 443
出力を出ません。
ベストアンサー1
これには、次の2つの権限が含まれています。
- 読み取りを許可
iptables-save
- 書き込み権限
/etc/iptables/rules.v4
2番目の必要な権限にはsudoを使用できません。
公開した最後のコマンドが機能するはずです。それ以外の場合は、次のコマンドを使用してルートシェルを削除するように変更-C
します-c
。
sudo su -