Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

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:
Embargoed:

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