Project

General

Profile

Feature #9352

netstat(1M) should be able to print IPv4 networks in CIDR form

Added by Dan McDonald over 1 year ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
-
Start date:
2018-03-26
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
needs-triage

Description

Because of existing scripts that parse traditional netstat output, printing IPv4 networks with CIDR notation should be enabled with a new flag: -c.

WS-nowhere-WS(usr.bin/netstat)[0]% ./netstat -r ; ./netstat -rn ; ./netstat -rc ; ./netstat -rnc ;

Routing Table: IPv4
  Destination           Gateway           Flags  Ref     Use     Interface 
-------------------- -------------------- ----- ----- ---------- --------- 
default              192.168.1.1          UG        2    7567491           
localhost            localhost            UH        3       9048 lo0       
192.168.4.0           nowhere              U        10   22721511 igb2      
exp.work.kebe.com    192.168.1.1          UGH       2       1054           
192.168.1.0          nowhere-bridge       U         3          0 kebelab0  
192.168.2.0          192.168.2.2          U         3   14829049 nfshackrelay0 

Routing Table: IPv6
  Destination/Mask            Gateway                   Flags Ref   Use    If   
--------------------------- --------------------------- ----- --- ------- ----- 
localhost                   localhost                   UH      2      16 lo0   

Routing Table: IPv4
  Destination           Gateway           Flags  Ref     Use     Interface 
-------------------- -------------------- ----- ----- ---------- --------- 
default              192.168.1.1          UG        2    7567491           
127.0.0.1            127.0.0.1            UH        3       9096 lo0       
192.168.4.0           172.24.4.1           U        10   22721520 igb2      
192.168.4.254         192.168.1.1          UGH       2       1054           
192.168.1.0          192.168.1.2          U         3          0 kebelab0  
192.168.2.0          192.168.2.2          U         3   14829049 nfshackrelay0 

Routing Table: IPv6
  Destination/Mask            Gateway                   Flags Ref   Use    If   
--------------------------- --------------------------- ----- --- ------- ----- 
::1                         ::1                         UH      2      16 lo0   

Routing Table: IPv4
  Destination           Gateway           Flags  Ref     Use     Interface 
-------------------- -------------------- ----- ----- ---------- --------- 
default              192.168.1.1          UG        2    7567491           
localhost            localhost            UH        3       9096 lo0       
192.168.4.0/24        nowhere              U        10   22721527 igb2      
exp.work.kebe.com    192.168.1.1          UGH       2       1054           
192.168.1.0/30       nowhere-bridge       U         3          0 kebelab0  
192.168.2.0/30       192.168.2.2          U         3   14829049 nfshackrelay0 

Routing Table: IPv6
  Destination/Mask            Gateway                   Flags Ref   Use    If   
--------------------------- --------------------------- ----- --- ------- ----- 
localhost                   localhost                   UH      2      16 lo0   

Routing Table: IPv4
  Destination           Gateway           Flags  Ref     Use     Interface 
-------------------- -------------------- ----- ----- ---------- --------- 
default              192.168.1.1          UG        2    7567491           
127.0.0.1            127.0.0.1            UH        3       9144 lo0       
192.168.4.0/24        172.24.4.1           U        10   22721536 igb2      
192.168.4.254         192.168.1.1          UGH       2       1054           
192.168.1.0/30       192.168.1.2          U         3          0 kebelab0  
192.168.2.0/30       192.168.2.2          U         3   14829049 nfshackrelay0 

Routing Table: IPv6
  Destination/Mask            Gateway                   Flags Ref   Use    If   
--------------------------- --------------------------- ----- --- ------- ----- 
::1                         ::1                         UH      2      16 lo0   
WS-nowhere-WS(usr.bin/netstat)[0]% 

History

#1

Updated by Dan McDonald over 1 year ago

  • Subject changed from netstat(1M) should be able to print IPv4 network in CIDR form to netstat(1M) should be able to print IPv4 networks in CIDR form
#2

Updated by Dan McDonald over 1 year ago

WS-nowhere-WS(usr.bin/netstat)[0]% ./netstat -i ; ./netstat -in ; ./netstat -ic ; ./netstat -inc
Name  Mtu  Net/Dest      Address        Ipkts  Ierrs Opkts  Oerrs Collis Queue 
lo0   8232 loopback      localhost      4744   0     4744   0     0      0     
igb2  9000 nowhere       nowhere        23025613 0     22901905 0     0      0     
kebelab0 9000 nowhere-bridge nowhere-bridge 12259442 0     7656569 0     0      0     
nfshackrelay0 9000 192.168.2.0   192.168.2.2    10555409 0     14860319 0     0      0     

Name  Mtu  Net/Dest                    Address                     Ipkts  Ierrs Opkts  Oerrs Collis
lo0   8252 localhost                   localhost                   4752   0     4752   0     0     
Name  Mtu  Net/Dest      Address        Ipkts  Ierrs Opkts  Oerrs Collis Queue 
lo0   8232 127.0.0.0     127.0.0.1      4752   0     4752   0     0      0     
igb2  9000 192.168.4.0    172.24.4.1     23025620 0     22901913 0     0      0     
kebelab0 9000 192.168.1.0   192.168.1.2    12259442 0     7656569 0     0      0     
nfshackrelay0 9000 192.168.2.0   192.168.2.2    10555409 0     14860319 0     0      0     

Name  Mtu  Net/Dest                    Address                     Ipkts  Ierrs Opkts  Oerrs Collis
lo0   8252 ::1                         ::1                         4752   0     4752   0     0     
Name  Mtu  Net/Dest      Address        Ipkts  Ierrs Opkts  Oerrs Collis Queue 
lo0   8232 loopback/8    localhost      4752   0     4752   0     0      0     
igb2  9000 nowhere/24    nowhere        23025629 0     22901921 0     0      0     
kebelab0 9000 nowhere-bridge/30 nowhere-bridge 12259442 0     7656569 0     0      0     
nfshackrelay0 9000 192.168.2.0/30 192.168.2.2    10555409 0     14860319 0     0      0     

Name  Mtu  Net/Dest                    Address                     Ipkts  Ierrs Opkts  Oerrs Collis
lo0   8252 localhost                   localhost                   4760   0     4760   0     0     
Name  Mtu  Net/Dest      Address        Ipkts  Ierrs Opkts  Oerrs Collis Queue 
lo0   8232 127.0.0.0/8   127.0.0.1      4760   0     4760   0     0      0     
igb2  9000 192.168.4.0/24 172.24.4.1     23025636 0     22901929 0     0      0     
kebelab0 9000 192.168.1.0/30 192.168.1.2    12259442 0     7656569 0     0      0     
nfshackrelay0 9000 192.168.2.0/30 192.168.2.2    10555409 0     14860319 0     0      0     

Name  Mtu  Net/Dest                    Address                     Ipkts  Ierrs Opkts  Oerrs Collis
lo0   8252 ::1                         ::1                         4760   0     4760   0     0     
WS-nowhere-WS(usr.bin/netstat)[0]% 

#3

Updated by Dan McDonald over 1 year ago

NOTE: While netstat -c can handle non-contiguous netmasks, the kernel does not allow them anymore.

#4

Updated by Electric Monk over 1 year ago

  • Status changed from New to Closed
  • % Done changed from 0 to 100

git commit d38b7101435717bb1c3c2f90a7c5ad2f9c3c4dc4

commit  d38b7101435717bb1c3c2f90a7c5ad2f9c3c4dc4
Author: Dan McDonald <danmcd@joyent.com>
Date:   2018-04-06T13:47:28.000Z

    9352 netstat(1M) should be able to print IPv4 networks in CIDR form
    Reviewed by: Yuri Pankov <yuripv@yuripv.net>
    Reviewed by: Andy Fiddaman <omnios@citrus-it.net>
    Approved by: Gordon Ross <gordon.ross@nexenta.com>

Also available in: Atom PDF