Port-Umleitung für alle Schnittstellen mit nft (nftables)

Port-Umleitung für alle Schnittstellen mit nft (nftables)

Ich habe eine relativ einfache Anforderung, die ich mit nft (nftables) lösen möchte. Sie besteht darin, alle eingehenden Pakete von Port 445 auf Port 1445 umzuleiten. Dies soll für alle Netzwerkschnittstellen durchgeführt werden.

Meine aktuelle Implementierung funktioniert nur lokal und nicht für externe Anfragen. Port 445 ist für externe Verbindungen nicht verfügbar.

table ip nat {                                                             
    chain prerouting {                                                 
            type nat hook prerouting priority 0; policy accept;        
            redirect                                                   
            tcp dport microsoft-ds redirect to :1445                   
    }                                                                  

    chain postrouting {                                                
            type nat hook postrouting priority 100; policy accept;     
    }                                                                  

    chain output {                                                     
            type nat hook output priority 100; policy accept;          
            tcp dport microsoft-ds redirect to :1445                   
    } 
}

Hat jemand einen Tipp? Danke.

Antwort1

Ich habe mein Problem gelöst.

Das funktioniert bei mir:

table ip nat {
    chain prerouting {
        type nat hook prerouting priority 0; policy accept;
        tcp dport microsoft-ds counter packets 1 bytes 52 dnat to :1445
    }

    chain postrouting {
        type nat hook postrouting priority 100; policy accept;
    }

    chain output {
        type nat hook output priority 100; policy accept;
        tcp dport microsoft-ds counter packets 3 bytes 180 dnat to :1445
    }
}

verwandte Informationen