2016-11-08 9 views
1

ポート80のトラフィックをポート8080にリダイレクトするようにサーバーを設定しようとしましたが、機能しません。 (私がポート80にtelnetすれば "Connection refused"エラーが出て、firefoxには "Unable to connect"と表示されます)ポート80を8080にリダイレクトするためのnftableを取得できません

iptablesを使って動作させることはできましたが、誰が問題が何であるか考えていますか? (ケースでは、サーバはLinodeのが提供するカーネルと、linode.com上で実行されている、関連するのです。)

は私が/etc/nftables.confに、次の持っている:

#!/usr/sbin/nft -f 

flush ruleset 

table ip fw { 
     chain in { 
       type filter hook input priority 0; 

       # accept any localhost traffic 
       iif lo accept 

       # accept traffic originated from us 
       ct state established,related accept 

       # accept ssh, alternative http 
       tcp dport { ssh, http, http-alt } ct state new counter accept 

       counter drop 
     } 
} 

table ip nat { 
     chain prerouting { 
       type nat hook prerouting priority 0; 
       tcp dport http redirect to http-alt 
     } 

     chain postrouting { 
       type nat hook postrouting priority 0; 
     } 
} 

答えて

0

があなたをしましたtable ip fwの代わりにtable inet filterを意味しますか?

もしそうなら、同様の問題がありました。 ipナットpreroutingを-101に変更すると正常に動作しますが、理由はわかりません。これはNF_IP_PRI_NAT_DST (-100): destination NATのデフォルトの優先度に関連している可能性があります。動作するように思われた唯一の範囲は-101〜-200でした。

#!/usr/sbin/nft -f 

flush ruleset 

table inet filter { 
    chain input { 
     type filter hook input priority 0; 
     counter 

     # accept any localhost traffic 
     iif lo accept 

     # accept traffic originated from us 
     ct state {established,related} accept 

     # activate the following line to accept common local services 
     tcp dport { 22, 80, 443, 9443 } ct state new accept 

     # accept neighbour discovery otherwise IPv6 connectivity breaks. 
     ip6 nexthdr icmpv6 icmpv6 type { nd-neighbor-solicit, nd-router-advert, nd-neighbor-advert } accept 

     # count and drop any other traffic 
     counter drop 
    } 
} 

table ip nat { 

    chain input { 
     type nat hook input priority 0; 
     counter 
    } 

    chain prerouting { 
     type nat hook prerouting priority -101; 
     counter 
     tcp dport 443 counter redirect to 9443 
    } 

    chain postrouting { 
     type nat hook postrouting priority 0; 
     counter 
    } 
} 

counterルールはチェーンでも処理されているかどうかを確認することが容易になります。カウンター値はnft list rulesetで確認できます。

関連する問題