アプリ版:「スタンプのみでお礼する」機能のリリースについて

こんにちは。現在自宅サーバーを作っているものです。

先日パソコンAにwebサーバーを作りました。そのパソコン自身からはindex.htmlが見えます。
しかし、同じローカル下にあるパソコンBからhttp://<192.で始まるパソコンAのローカルIP>で接続してもindex.htmlが見れません。

現在試したこと、分かったことは以下です。
・ファイアウォールを停止(service iptables stop)をするとパソコンBからindex.htmlがみれる
・DDNSを既に登録しており、外部からhttp://<登録したホスト名>で接続するとindex.htmlが見れる
・パソコンBからパソコンAへのローカルipへのpingは応答が確認されている
・iptablesには以下の3つを追加
/sbin/iptables -A INPUT -p tcp --dport http -j ACCEPT
/sbin/iptables -A INPUT -p tcp --dport https -j ACCEPT
/sbin/iptables -A INPUT -s 192.168.11.0/24 -j ACCEPT

ファイアウォールを停止すると接続できるできることからiptablesに問題があると思うのですが、なにを削除、もしくは追加すればいいのか分かりません。
よろしくお願いします。

A 回答 (4件)

>RH-Firewall-1-INPUT all -- anywhere anywhere


>ACCEPT tcp -- anywhere anywhere tcp dpt:https
>REJECT all -- anywhere anywhere reject-with icmp-host-prohibited

RH-Firewall-1-INPUTチェーンの最後でREJECTされてます。
挿入位置はそちらに変更して下さい。
# またはRH-Firewall-1-INPUTより前でACCEPTさせて下さい。

>だと、ユーザ下のpublic_html/index.htmlは見れません。
>(service iptables stopすると見れます。)
>このエラーも今回質問したiptablesの設定の間違いが関係しているのですかね?

iptablesは関係ない…と思われますが……どうなんでしょうかねぇ。
httpdのログにどう記録されているか…が問題のような気がします。
    • good
    • 0

ディストリビューションはなんでしょうかね??


まあ、それほど重要ではありませんが……。

回答No.1のお礼に書かれたのはINPUTチェーンのもの…ですよね?

>ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ssh
>REJECT all -- anywhere anywhere reject-with icmp-host-prohibited

で、REJECTされるチェーンの後ろに追加しても、その前にREJECTされているのですから無意味…かと思われますが。

-Aではなく-Iでインサートするか、書き出されたルールファイルを直接編集するなりしてREJECTの前の部分に挿入しないとダメかと。
# Redhat系列なら/etc/sysconfig/iptables に設定情報があります。
# 私はもっぱらこっちのファイルを編集して、service iptables restartで適用していたりしますね。
sshの設定があるでしょうから、その行を2つコピーして、dportをhttpとhhtpsに、ソースアドレスの指定を追加する。
というのでどうでしょうか?
-A INPUT -m state --state NEW -m tcp -p tcp -s 192.168.11.0/24 --dport http -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp -s 192.168.11.0/24 --dport https -j ACCEPT
ですかね。

この回答への補足

ちなみに、外部からの接続だと
http://<ホスト名>
だと/var/wwwのindex.htmlが見れるのですが
http://<ホスト名>/~<ユーザー名>
だと、ユーザ下のpublic_html/index.htmlは見れません。
(service iptables stopすると見れます。)
このエラーも今回質問したiptablesの設定の間違いが関係しているのですかね?

補足日時:2013/01/21 21:52
    • good
    • 0
この回答へのお礼

すみません、リストを全部記載してなかったです。
以下のようになっていました。
Chain INPUT (policy ACCEPT)
target prot opt source destination
RH-Firewall-1-INPUT all -- anywhere anywhere
ACCEPT tcp -- anywhere anywhere tcp dpt:https
ACCEPT tcp -- anywhere anywhere tcp dpt:http
ACCEPT tcp -- anywhere anywhere tcp spt:http
ACCEPT tcp -- 192.168.11.0/24 anywhere tcp dpt:http
ACCEPT tcp -- 192.168.11.0/24 anywhere tcp dpt:https
ACCEPT all -- anywhere anywhere

Chain FORWARD (policy ACCEPT)
target prot opt source destination
RH-Firewall-1-INPUT all -- anywhere anywhere

Chain OUTPUT (policy ACCEPT)
target prot opt source destination

Chain RH-Firewall-1-INPUT (2 references)
target prot opt source destination
ACCEPT all -- anywhere anywhere
ACCEPT icmp -- anywhere anywhere icmp any
ACCEPT esp -- anywhere anywhere
ACCEPT ah -- anywhere anywhere
ACCEPT udp -- anywhere 224.0.0.251 udp dpt:mdns
ACCEPT udp -- anywhere anywhere udp dpt:ipp
ACCEPT tcp -- anywhere anywhere tcp dpt:ipp
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ssh
REJECT all -- anywhere anywhere reject-with icmp-host-prohibited

お礼日時:2013/01/21 21:55

 お尋ねの件ですが、iptablesの記述を夫々、「iptables -A INPUT -p tcp --dport 80 -j ACCEPT」、「iptables -A INPUT -p tcp --dport 443 -j ACCEPT」、「iptables -P INPUT DROP」


「iptables -P OUTPUT ACCEPT」、「iptables -P FORWARD DROP」、「iptables -A INPUT -i lo -j ACCEPT」を変更・追記してみては如何ですか?
    • good
    • 0

>・iptablesには以下の3つを追加


>/sbin/iptables -A INPUT -p tcp --dport http -j ACCEPT
>/sbin/iptables -A INPUT -p tcp --dport https -j ACCEPT
>/sbin/iptables -A INPUT -s 192.168.11.0/24 -j ACCEPT

追加、というからには元の設定があるはずですが、そちらはどうなっていますか?
iptables --list
で設定内容が確認できますけど……。
    • good
    • 0
この回答へのお礼

お返事ありがとうございます。
リストをみたところ、以下のような設定になっていました。
target prot opt source destination
ACCEPT all -- anywhere anywhere
ACCEPT icmp -- anywhere anywhere icmp any
ACCEPT esp -- anywhere anywhere
ACCEPT ah -- anywhere anywhere
ACCEPT udp -- anywhere 224.0.0.251 udp dpt:mdns
ACCEPT udp -- anywhere anywhere udp dpt:ipp
ACCEPT tcp -- anywhere anywhere tcp dpt:ipp
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ssh
REJECT all -- anywhere anywhere reject-with icmp-host-prohibited

お礼日時:2013/01/21 13:29

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!