Bug 755905 - netstat truncates IP address in connection output
Summary: netstat truncates IP address in connection output
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: net-tools
Version: 6.1
Hardware: All
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Jiri Popelka
QA Contact: qe-baseos-daemons
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-11-22 11:35 UTC by Stanislav Kozina
Modified: 2013-03-04 01:35 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-12-06 18:59:56 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 176465 0 medium CLOSED IPv6: 'netstat -A inet6 -n' truncates most global IPv6 addresses 2021-02-22 00:41:40 UTC

Internal Links: 176465

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


Note You need to log in before you can comment on or make changes to this bug.