<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://wiki.nftables.org/wiki-nftables/index.php?action=history&amp;feed=atom&amp;title=Output_text_modifiers</id>
	<title>Output text modifiers - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://wiki.nftables.org/wiki-nftables/index.php?action=history&amp;feed=atom&amp;title=Output_text_modifiers"/>
	<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Output_text_modifiers&amp;action=history"/>
	<updated>2026-06-13T02:58:43Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.6</generator>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Output_text_modifiers&amp;diff=529&amp;oldid=prev</id>
		<title>Arturo: create page</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Output_text_modifiers&amp;diff=529&amp;oldid=prev"/>
		<updated>2020-07-22T10:36:59Z</updated>

		<summary type="html">&lt;p&gt;create page&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;This page contains information on the several &amp;#039;&amp;#039;&amp;#039;output text modifiers&amp;#039;&amp;#039;&amp;#039; that nftables support when using the command line interface &amp;#039;&amp;#039;&amp;#039;nft&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
You can generally check all the output modifiers by using &amp;#039;&amp;#039;&amp;#039;nft --help&amp;#039;&amp;#039;&amp;#039; or reading the manpage &amp;#039;&amp;#039;&amp;#039;nft(8)&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  -n, numeric                   Print fully numerical output.&lt;br /&gt;
  -s, stateless                 Omit stateful information of ruleset.&lt;br /&gt;
  -N, reversedns                Translate IP addresses to names.&lt;br /&gt;
  -S, service                   Translate ports to service names as described in /etc/services.&lt;br /&gt;
  -a, handle                    Output rule handle.&lt;br /&gt;
  -j, json                      Format output in JSON&lt;br /&gt;
  -u, guid                      Print UID/GID as defined in /etc/passwd and /etc/group.&lt;br /&gt;
  -y, numeric-priority          Print chain priority numerically.&lt;br /&gt;
  -p, numeric-protocol          Print layer 4 protocols numerically.&lt;br /&gt;
  -T, numeric-time              Print time values numerically.&lt;br /&gt;
  -t, terse                     Omit contents of sets.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The default output prints some information in numeric form and for well-known names it will use a string instead (like icmp types, conntrack status, chain priorities, etc).&lt;br /&gt;
Also, state information such as counter values and set elements are printed as well.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
% nft list ruleset&lt;br /&gt;
table inet filter {&lt;br /&gt;
	set s {&lt;br /&gt;
		type inet_service&lt;br /&gt;
		elements = { 80, 443 }&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	chain input {&lt;br /&gt;
		type filter hook input priority filter; policy accept;&lt;br /&gt;
		counter packets 4447 bytes 1619415&lt;br /&gt;
		iif &amp;quot;lo&amp;quot; counter packets 337 bytes 25076 accept&lt;br /&gt;
		ct state established,related counter packets 44899 bytes 106405802 accept&lt;br /&gt;
		ip6 nexthdr ipv6-icmp icmpv6 type { nd-router-advert, nd-neighbor-solicit, nd-neighbor-advert } counter packets 1 bytes 72 accept&lt;br /&gt;
		tcp dport 22 drop&lt;br /&gt;
		ip saddr 8.8.8.8 drop&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== translation modifiers ==&lt;br /&gt;
&lt;br /&gt;
Translate various values to text equivalents, or the other way around. We can group here things like ports, DNS names, service names, UID/GID, etc.&lt;br /&gt;
&lt;br /&gt;
The options can be combined at will. The example below shows service names (instead of the integer number), chain priority value (instead of the well-known string), conntrack/protocol numbers and constants (instead of well-known strings) and shows reverse DNS names (instead of the numeric IP address):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
% nft -nNSy list ruleset&lt;br /&gt;
table inet filter {&lt;br /&gt;
	set s {&lt;br /&gt;
		type inet_service&lt;br /&gt;
		elements = { &amp;quot;http&amp;quot;, &amp;quot;https&amp;quot; }&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	chain input {&lt;br /&gt;
		type filter hook input priority 0; policy accept;&lt;br /&gt;
		iif &amp;quot;lo&amp;quot; counter packets 365 bytes 27092 accept&lt;br /&gt;
		ct state 0x2,0x4 counter packets 48535 bytes 142472901 accept&lt;br /&gt;
		ip6 nexthdr 58 icmpv6 type { 134, 135, 136 } counter packets 1 bytes 72 accept&lt;br /&gt;
		ip saddr dns.google counter packets 0 bytes 0&lt;br /&gt;
		tcp dport &amp;quot;ssh&amp;quot; accept&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that translating some elements might take additional operation time when generating the output. For example translating IP addresses to names require queries to DNS servers, which can be very slow for large rulesets (and therefore is disabled by default).&lt;br /&gt;
&lt;br /&gt;
== operations and parsing modifiers ==&lt;br /&gt;
&lt;br /&gt;
These modifiers add or remove information about the ruleset, generally useful when parsing the output or doing related operations.&lt;br /&gt;
&lt;br /&gt;
You can display the ruleset without stateful information (for example, without counter values), with handles, and with no set contents:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
% nft -sta list ruleset&lt;br /&gt;
table inet filter { # handle 5&lt;br /&gt;
	set s { # handle 9&lt;br /&gt;
		type inet_service&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	chain input { # handle 1&lt;br /&gt;
		type filter hook input priority filter; policy accept;&lt;br /&gt;
		iif &amp;quot;lo&amp;quot; counter accept # handle 3&lt;br /&gt;
		ct state established,related counter accept # handle 4&lt;br /&gt;
		ip6 nexthdr ipv6-icmp icmpv6 type { nd-router-advert, nd-neighbor-solicit, nd-neighbor-advert } counter accept # handle 5&lt;br /&gt;
		ip saddr 8.8.8.8 counter # handle 8&lt;br /&gt;
		tcp dport 22 accept # handle 10&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Special mention to the JSON representation of the ruleset. The JSON will be printed in a single line fashion. Here we format the JSON using perl&amp;#039;s json_pp utility:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
% nft -j list ruleset | json_pp&lt;br /&gt;
{&lt;br /&gt;
   &amp;quot;nftables&amp;quot; : [&lt;br /&gt;
      {&lt;br /&gt;
         &amp;quot;metainfo&amp;quot; : {&lt;br /&gt;
            &amp;quot;json_schema_version&amp;quot; : 1,&lt;br /&gt;
            &amp;quot;release_name&amp;quot; : &amp;quot;Capital Idea #2&amp;quot;,&lt;br /&gt;
            &amp;quot;version&amp;quot; : &amp;quot;0.9.6&amp;quot;&lt;br /&gt;
         }&lt;br /&gt;
      },&lt;br /&gt;
      {&lt;br /&gt;
         &amp;quot;table&amp;quot; : {&lt;br /&gt;
            &amp;quot;family&amp;quot; : &amp;quot;inet&amp;quot;,&lt;br /&gt;
            &amp;quot;handle&amp;quot; : 5,&lt;br /&gt;
            &amp;quot;name&amp;quot; : &amp;quot;filter&amp;quot;&lt;br /&gt;
         }&lt;br /&gt;
      },&lt;br /&gt;
      {&lt;br /&gt;
         &amp;quot;set&amp;quot; : {&lt;br /&gt;
            &amp;quot;elem&amp;quot; : [&lt;br /&gt;
               80,&lt;br /&gt;
               443&lt;br /&gt;
            ],&lt;br /&gt;
            &amp;quot;family&amp;quot; : &amp;quot;inet&amp;quot;,&lt;br /&gt;
            &amp;quot;handle&amp;quot; : 9,&lt;br /&gt;
            &amp;quot;name&amp;quot; : &amp;quot;s&amp;quot;,&lt;br /&gt;
            &amp;quot;table&amp;quot; : &amp;quot;filter&amp;quot;,&lt;br /&gt;
            &amp;quot;type&amp;quot; : &amp;quot;inet_service&amp;quot;&lt;br /&gt;
         }&lt;br /&gt;
      },&lt;br /&gt;
      {&lt;br /&gt;
         &amp;quot;chain&amp;quot; : {&lt;br /&gt;
            &amp;quot;family&amp;quot; : &amp;quot;inet&amp;quot;,&lt;br /&gt;
            &amp;quot;handle&amp;quot; : 1,&lt;br /&gt;
            &amp;quot;hook&amp;quot; : &amp;quot;input&amp;quot;,&lt;br /&gt;
            &amp;quot;name&amp;quot; : &amp;quot;input&amp;quot;,&lt;br /&gt;
            &amp;quot;policy&amp;quot; : &amp;quot;accept&amp;quot;,&lt;br /&gt;
            &amp;quot;prio&amp;quot; : 0,&lt;br /&gt;
            &amp;quot;table&amp;quot; : &amp;quot;filter&amp;quot;,&lt;br /&gt;
            &amp;quot;type&amp;quot; : &amp;quot;filter&amp;quot;&lt;br /&gt;
         }&lt;br /&gt;
      },&lt;br /&gt;
      {&lt;br /&gt;
         &amp;quot;rule&amp;quot; : {&lt;br /&gt;
            &amp;quot;chain&amp;quot; : &amp;quot;input&amp;quot;,&lt;br /&gt;
            &amp;quot;expr&amp;quot; : [&lt;br /&gt;
               {&lt;br /&gt;
                  &amp;quot;counter&amp;quot; : {&lt;br /&gt;
                     &amp;quot;bytes&amp;quot; : 37707381,&lt;br /&gt;
                     &amp;quot;packets&amp;quot; : 8062&lt;br /&gt;
                  }&lt;br /&gt;
               }&lt;br /&gt;
            ],&lt;br /&gt;
            &amp;quot;family&amp;quot; : &amp;quot;inet&amp;quot;,&lt;br /&gt;
            &amp;quot;handle&amp;quot; : 7,&lt;br /&gt;
            &amp;quot;table&amp;quot; : &amp;quot;filter&amp;quot;&lt;br /&gt;
         }&lt;br /&gt;
      },&lt;br /&gt;
[..]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Arturo</name></author>
	</entry>
</feed>