カールを使用してポート8081で接続が拒否されました。

カールを使用してポート8081で接続が拒否されました。

TurboとDemoという2つのCentOS 7システムがあります。最初のTurboでデーモン/サービスを開始し、2番目のデモでそのサービスを呼び出したかったのです。ポート8081を監視するサービスを開始しました。他のデーモンが8080ポートを使用していて、次回ポート8081を使うかと思ったりしました。

FirewallDどちらのボックスもファイアウォールデーモンが実行されていません。

iptablesにエントリを追加し、システムを再起動しました。ファイルの内容です。

# Generated by iptables-save v1.4.21 on Tue Nov 10 13:00:36 2015
*filter
:INPUT ACCEPT [900:143014]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [781:136535]
-A INPUT -p tcp -m state --state NEW -m tcp --dport 8081 -m comment --comment "DataMover Service Port" -j ACCEPT
COMMIT
# Completed on Tue Nov 10 13:00:36 2015

これは、ファイアウォール(無効)を使用してポートを開こうとすると予想される結果です。

[root@Turbo Downloads]# firewall-cmd --permanent --add-port=8081/tcp
FirewallD is not running

私が使用するカールコマンドは次のとおりです。

[hts@jmr-server2 raid1]$ curl -H "Accept: application/xml" "http://192.168.20.88:8081/base/TestService/sayHello"

Google検索を行いましたが、ほとんどの結果でiptableを編集したり、ファイアウォールでポートを開くことがわかりました。

私が探していますこのウェブサイト、CentOSの共通ポート番号がリストされています。

両方のポートについて次のように説明します。

8080  webcache  World Wide Web (WWW) caching service  
8081  tproxy  Transparent Proxy  

リクエストの結果は次のとおりですiptables -L

[root@Turbo Downloads]# service iptables restart
Redirecting to /bin/systemctl restart  iptables.service
[root@Turbo Downloads]# iptables -L
Chain INPUT (policy ACCEPT)
    target     prot opt source               destination         
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:tproxy /* TestService Service Port */

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
[root@Turbo Downloads]# 

質問は次のとおりです。

[root@Turbo Downloads]# netstat -nap|grep 8081
tcp6       0      0 127.0.0.1:8081          :::*                    LISTEN      7272/java           
[root@Turbo Downloads]# 

私はテストにlocalhostを使用していますが、次の手順を実行して別のシステムに移動したいと思います。 localhostの結果は次のとおりです。

[root@Turbo Downloads]# curl -H "Accept: application/xml" "http://localhost:8081/base/TestService/getHello"
<?xml version="1.0" encoding="UTF-8"?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>

ターミナルウィンドウでサービスを開始しました。まだサービス自動ロードポイントに到達できませんでした。

あるサーバーから別のサーバーへのカールアクセスはポート8080でのみ機能し、別のポートでは機能しませんか、それとも別の問題がありますか?

ベストアンサー1

問題は次のとおりです。 netstat 出力に、サービスが外部からアクセス可能な IP ではなく localhost でリッスンしていると表示されます。

127.0.0.1:8081

(または「すべて」)IPを受信するようにサービスを編集して再起動します。

おすすめ記事