• Re: nftables ssh Could not resolve service Servname not supported

    From George at Clug@21:1/5 to All on Tue Aug 6 07:00:01 2024
    On Tuesday, 06-08-2024 at 14:40 David Wright wrote:
    On Tue 06 Aug 2024 at 14:25:45 (+1000), George at Clug wrote:

    However I have one issue, my nftables is not recognising the label
    'dns' for port 53, although it is recognising labels for other ports
    that I have been using (e.g. ssh, http, ntp, https).

    My /etc/services uses the term "domain" rather than "dns" for 53.

    Thanks David,

    Using 'domain' does work.

    # nano /etc/nftables.conf
    ...
    oifname "enp1s0" ct state new udp dport domain accept
    oifname "enp1s0" ct state new tcp dport { ssh, domain, http, ntp, https } accept
    ...

    # systemctl restart nftables
    # nft list ruleset
    ...
    oifname "enp1s0" ct state new udp dport 53 accept
    oifname "enp1s0" ct state new tcp dport { 22, 53, 80, 123, 443 } accept
    ...

    George.




    Cheers,
    David.



    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From David Wright@21:1/5 to George at Clug on Tue Aug 6 06:50:01 2024
    On Tue 06 Aug 2024 at 14:25:45 (+1000), George at Clug wrote:

    However I have one issue, my nftables is not recognising the label
    'dns' for port 53, although it is recognising labels for other ports
    that I have been using (e.g. ssh, http, ntp, https).

    My /etc/services uses the term "domain" rather than "dns" for 53.

    Cheers,
    David.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From George at Clug@21:1/5 to All on Tue Aug 6 06:30:01 2024
    Hi,


    I have my simple nftables firewall working (thanks to people who have
    posted).


    However I have one issue, my nftables is not recognising the label
    'dns' for port 53, although it is recognising labels for other ports
    that I have been using (e.g. ssh, http, ntp, https).


    When I checked on the Internet, I find that other people are using the
    label 'dns'. I wonder if I am the only one having this issue? 


    It is not much of an issue, anyway, as it is just as easy to use
    numerical port numbers.



    Other checks on the Internet show that some people have previously
    reported issues with other labels, like ssh, where as I am not.


    George.



    =============================
    On Debian Bookworm headless server (built this morning)



    Set rules to use lables (e.g. dns) and not numerical values


    # nano /etc/nftables.conf

    ...

                    oifname "enp1s0" ct state new udp dport
    dns accept
                    oifname "enp1s0" ct state new tcp dport
    { ssh, dns, http, ntp, https } accept

    ...


    # systemctl restart nftables.service
    Job for nftables.service failed because the control process exited
    with error code.
    See "systemctl status nftables.service" and "journalctl -xeu
    nftables.service" for details.

    # journalctl -xeu nftables.service
    ...
     The process' exit code is 'exited' and its exit status is 1.
    Aug 06 13:54:51 debmcfwt nft[1519]: /etc/nftables.conf:24:50-52:
    Error: Could not resolve service: Servname not supported for
    ai_socktype
    Aug 06 13:54:51 debmcfwt nft[1519]:                
    oifname "enp1s0" ct state new tcp dport { ssh, dns, http, ntp, https }
    accept
    Aug 06 13:54:51 debmcfwt nft[1519]:                                                               
    ^^^
    Aug 06 13:54:51 debmcfwt systemd[1]: nftables.service: Failed with
    result 'exit-code'.
    ...

    Set rules to use 53 and not dns
    # nano /etc/nftables.conf

    ...

                    oifname "enp1s0" ct state new udp dport
    53 accept
                    oifname "enp1s0" ct state new tcp dport
    { ssh, 53, http, ntp, https } accept
    ...


    Restarting nftables no longer causes an error report.
    # systemctl restart nftables.service
    #

    A few web pages of different but similar or not so similar issues:

    https://linux-audit.com/nftables-beginners-guide-to-traffic-filtering/

    ip daddr 127.0.0.1 tcp dport {http, postgresql, ipp} accept
    udp dport dns accept
    tcp dport {dns, http, ntp, https, 9418} accept


    Aug 06 13:46:05 debmcfwt nft[1505]: /etc/nftables.conf:24:45-47:
    Error: Could not resolve service: Servname not supported for
    ai_socktype
    Aug 06 13:46:05 debmcfwt nft[1505]:                
    oifname "enp1s0" ct state new tcp dport { dns, ssh, http, ntp, https }
    accept
    Aug 06 13:46:05 debmcfwt nft[1505]:                                                          
    ^^^
    Aug 06 13:46:05 debmcfwt systemd[1]: nftables.service: Main process
    exited, code=exited, status=1/FAILURE



    https://www.mail-archive.com/[email protected]/msg1821654.html     root@main:~# nft -c 'table filter {chain INPUT {tcp dport
    ssh;};}'
        Error: Could not resolve service: Servname not supported for
    ai_socktype
        table filter {chain INPUT {tcp dport ssh;};}                                         
    ^^^

    https://git.netfilter.org/nftables/commit/?id=818f7dded9c9e8a89a2de98801425536180ae307
    evaluate: reset ctx->set after set interval evaluation
    Otherwise bogus error reports on set datatype mismatch might occur,
    such as:

    Error: datatype mismatch, expected Internet protocol, expression has
    type IPv4 address
        meta l4proto { tcp, udp } th dport 443 dnat to 10.0.0.1
        ~~~~~~~~~~~~ ^^^^^^^^^^^^

    with an unrelated set declaration.


    ============================================


    # cat /etc/nftables.conf
    #!/usr/sbin/nft -f

    flush ruleset

    table ip filter {
        chain INPUT {
            type filter hook input priority filter; policy drop;
            iifname "lo" accept
            iifname "enp1s0" ct state established,related accept
            iifname "enp1s0" ct state new tcp dport ssh accept
            iifname "enp1s0" ct state new tcp dport 25565 accept
            iifname "enp1s0" ct state new tcp dport 8123 accept
        }

        chain FORWARD {
            type filter hook forward priority filter; policy drop;
        }

        chain OUTPUT {
            type filter hook output priority filter; policy drop;
            oifname "lo" accept
            oifname "enp1s0" ct state established,related accept
            oifname "enp1s0" ct state new udp dport 53 accept
            oifname "enp1s0" ct state new tcp dport { ssh, 53, http,
    ntp, https } accept
            oifname "enp1s0" icmp type {echo-request} accept
        }
    }

    <html>
    <head>
    <style type="text/css">
    body,p,td,div,span{
    font-size:13px; font-family:Arial, Helvetica, sans-serif;
    };
    body p{
    margin:0px;
    }
    </style>
    </head>
    <body><div>Hi,</div><div><br></div><div>I have my simple nftables firewall working (thanks to people who have posted).</div><div><br></div><div>However I have one issue, my nftables is not recognising the label 'dns' for port 53, although it is
    recognising labels for other ports that I have been using (e.g. ssh, http, ntp, https).</div><div><br></div><div>When I checked on the Internet, I find that other people are using the label 'dns'. I wonder if I am the only one having this issue?&nbsp;</
    <div><br></div><div>It is not much of an issue, anyway, as it is just as easy to use numerical port numbers.<br></div><div><br></div><div>Other checks on the Internet show that some people have previously reported issues with other labels, like ssh,
    where as I am not.</div><div><br></div><div>George.<br></div><div><br></div><div>=============================</div><div>On Debian Bookworm headless server (built this morning)<br></div><div><br></div><div>Set rules to use lables (e.g. dns) and not
    numerical values</div><div><br></div><div># nano /etc/nftables.conf<br></div><div>...<br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; oifname "enp1s0" ct state new udp dport dns accept<br>&nbsp;&
    nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; oifname "enp1s0" ct state new tcp dport { ssh, dns, http, ntp, https } accept<br></div><div>...<br></div><div><br># systemctl restart nftables.service<br>Job for nftables.
    service failed because the control process exited with error code.<br>See "systemctl status nftables.service" and "journalctl -xeu nftables.service" for details.<br><br># journalctl -xeu nftables.service<br>...<br>&nbsp;The process' exit code is 'exited'
    and its exit status is 1.<br>Aug 06 13:54:51 debmcfwt nft[1519]: /etc/nftables.conf:24:50-52: Error: Could not resolve service: Servname not supported for ai_socktype<br>Aug 06 13:54:51 debmcfwt nft[1519]:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
    nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; oifname "enp1s0" ct state new tcp dport { ssh, dns, http, ntp, https } accept<br>Aug 06 13:54:51 debmcfwt nft[1519]:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
    nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
    nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ^^^<br>Aug 06 13:54:51 debmcfwt systemd[1]: nftables.service: Failed with result 'exit-code'.<br>...<br><br>Set rules to use 53 and not dns<br># nano /etc/nftables.conf<br></div><div>...<br></div><div>&nbsp;&nbsp;&nbsp;
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; oifname "enp1s0" ct state new udp dport 53 accept<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; oifname "enp1s0" ct state new tcp
    dport { ssh, 53, http, ntp, https } accept<br>...</div><div><br></div><div>Restarting nftables no longer causes an error report.<br># systemctl restart nftables.service<br>#<br><br>A few web pages of different but similar or not so similar issues:<br><br>
    https://linux-audit.com/nftables-beginners-guide-to-traffic-filtering/<br><br>ip daddr 127.0.0.1 tcp dport {http, postgresql, ipp} accept<br>udp dport dns accept<br>tcp dport {dns, http, ntp, https, 9418} accept<br><br><br>Aug 06 13:46:05 debmcfwt nft[
    1505]: /etc/nftables.conf:24:45-47: Error: Could not resolve service: Servname not supported for ai_socktype<br>Aug 06 13:46:05 debmcfwt nft[1505]:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; oifname "
    enp1s0" ct state new tcp dport { dns, ssh, http, ntp, https } accept<br>Aug 06 13:46:05 debmcfwt nft[1505]:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
    nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ^^^<br>Aug 06 13:46:05 debmcfwt systemd[1]:
    nftables.service: Main process exited, code=exited, status=1/FAILURE<br><br><br><br>https://www.mail-archive.com/[email protected]/msg1821654.html<br>&nbsp;&nbsp;&nbsp; root@main:~# nft -c 'table filter {chain INPUT {tcp dport ssh;};}'<br>
    &nbsp;&nbsp;&nbsp; Error: Could not resolve service: Servname not supported for ai_socktype<br>&nbsp;&nbsp;&nbsp; table filter {chain INPUT {tcp dport ssh;};}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
    nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ^^^<br><br>https://git.netfilter.org/nftables/commit/?id=818f7dded9c9e8a89a2de98801425536180ae307<br>
    evaluate: reset ctx-&gt;set after set interval evaluation<br>Otherwise bogus error reports on set datatype mismatch might occur, such as:<br><br>Error: datatype mismatch, expected Internet protocol, expression has type IPv4 address<br>&nbsp;&nbsp;&nbsp;
    meta l4proto { tcp, udp } th dport 443 dnat to 10.0.0.1<br>&nbsp;&nbsp;&nbsp; ~~~~~~~~~~~~ ^^^^^^^^^^^^<br><br>with an unrelated set declaration.</div><div><br></div><div>============================================</div><div><br></div><div># cat /etc/
    nftables.conf<br>#!/usr/sbin/nft -f<br><br>flush ruleset<br><br>table ip filter {<br>&nbsp;&nbsp; &nbsp;chain INPUT {<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; type filter hook input priority filter; policy drop;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;
    iifname "lo" accept<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; iifname "enp1s0" ct state established,related accept<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; iifname "enp1s0" ct state new tcp dport ssh accept<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; iifname
    "enp1s0" ct state new tcp dport 25565 accept<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; iifname "enp1s0" ct state new tcp dport 8123 accept<br>&nbsp;&nbsp; &nbsp;}<br><br>&nbsp;&nbsp; &nbsp;chain FORWARD {<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; type
    filter hook forward priority filter; policy drop;<br>&nbsp;&nbsp; &nbsp;}<br><br>&nbsp;&nbsp; &nbsp;chain OUTPUT {<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; type filter hook output priority filter; policy drop;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;
    oifname "lo" accept<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; oifname "enp1s0" ct state established,related accept<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; oifname "enp1s0" ct state new udp dport 53 accept<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; oifname "
    enp1s0" ct state new tcp dport { ssh, 53, http, ntp, https } accept<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; oifname "enp1s0" icmp type {echo-request} accept<br>&nbsp;&nbsp; &nbsp;}<br>}<br></div><div><br></div><div><br></div></body></html>

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Michel Verdier@21:1/5 to George at Clug on Tue Aug 6 08:50:02 2024
    On 2024-08-06, George at Clug wrote:

    # nano /etc/nftables.conf

    /etc/nftables.conf is used to load rules at boot by systemd
    nftables.service. It's safer to edit another file, test it with nft -f,
    then if it's correct to copy it to /etc/nftables.conf. If something goes
    wrong a reboot could restore old working /etc/nftables.conf.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)