2016-11-08 8 views
1

포트 80의 트래픽을 포트 8080로 리디렉션하도록 서버를 설정했지만 작동하지 않습니다. (포트 80으로 텔넷하고 파이어 폭스와 연결할 수 없다면 "Connection refused"오류가 발생합니다.)포트 80을 8080으로 리디렉션 할 수 없습니다.

iptables를 사용하여 작동 시키지만 nftables를 사용하는 것이 좋습니다. 문제가 무엇인지 알 수있는 사람이 있습니까? (여기서 서버가 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 nat 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을 통해 볼 수 있습니다.