Bug 755905

Summary: netstat truncates IP address in connection output
Product: Red Hat Enterprise Linux 6 Reporter: Stanislav Kozina <skozina>
Component: net-toolsAssignee: Jiri Popelka <jpopelka>
Status: CLOSED NOTABUG QA Contact: qe-baseos-daemons
Severity: medium Docs Contact:
Priority: medium    
Version: 6.1CC: maarten.litmaath, mhomolov
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-12-06 18:59:56 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Stanislav Kozina 2011-11-22 11:35:08 UTC
Description of problem:

When netstat is run without '-n' option, and there is established connection on port 445 and IP address consisting of 4 3-digit values, the last digit of IP address is discarded in output.
With '-n' option the Foreign Address is displayed fine.

$ netstat | grep 40584
tcp        0      0 192.168.100.1:40584         192.168.100.23:microsoft-ds ESTABLISHED 
$ netstat -n | grep 40584
tcp        0      0 192.168.100.1:40584         192.168.100.234:445         ESTABLISHED 

See the Foreign Address field. Without -n option, the last digit of IP address is truncated.

Version-Release number of selected component (if applicable):

$ rpm -qf /bin/netstat
net-tools-1.60-105.el6.x86_64

How reproducible:

Always.

Steps to Reproduce:
1. Run 'nc -l 445' as root
2. Run 'telnet 127.100.100.100 445' as any user
3. See 'netstat' and 'netstat -n' output for port 445/microsoft-ds
  
Actual results:

Foreign address column displays '127.100.100.10:microsoft-ds'

Expected results:

Foreign address column should display '127.100.100.100:microsoft-ds'

Additional info:

Comment 1 Jiri Popelka 2011-12-06 18:59:56 UTC
Hi Stanislav,

this is expected behavior.

Netstat produces output formatted to approx. 80 characters wide.
To achieve this width, columns are truncated.
Red Hat's version of netstat include a -T/--notrim (upstream named it -W/--wide) option that ensures no information is trimmed, even if it means making the output a little less pretty.

Comment 2 Maarten Litmaath 2013-02-07 23:22:42 UTC
Hi all,
for the record, the problem even occurs when the "-n" option _is_ used:

-----------------------------------------------------------------------------
[root@wms302 ~]# rpm -qf /bin/netstat 
net-tools-1.60-82.el5
-----------------------------------------------------------------------------
[root@wms302 ~]# netstat -pan > /tmp/pan & netstat -panT > /tmp/panT
[1] 2057
[1]+ Done netstat -pan > /tmp/pan
-----------------------------------------------------------------------------
[root@wms302 ~]# diff /tmp/pan /tmp/panT
173c173
< tcp 0 0 ::ffff:128.142.16.169:9001 ::ffff:138.253.178.11:52489 FIN_WAIT2 -
---
> tcp 0 0 ::ffff:128.142.16.169:9001 ::ffff:138.253.178.110:52489 FIN_WAIT2 -
-----------------------------------------------------------------------------

Note how the IP address got truncated when the "-T" option was not used.

This issue just bit me badly, which is how I found out about it.

It is beyond me why anyone would prefer "nice" formatting over correct output...

I would say this gross misfeature actually is a bug that needs fixing.

Comment 3 Jiri Popelka 2013-02-11 10:50:09 UTC
(In reply to comment #2)
> for the record, the problem even occurs when the "-n" option _is_ used:

Yes, it's not dependent on the '-n' option.
 
> It is beyond me why anyone would prefer "nice" formatting over correct
> output...
> I would say this gross misfeature actually is a bug that needs fixing.

That's how it's always been working.
If you think default should be wide/notrim raise this idea upstream at
https://lists.sourceforge.net/lists/listinfo/net-tools-devel