Hide Forgot
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:
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.
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.
(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