Disable truncation of hostnames in netstat's output

5

1

By default, the netstat command truncates hostnames in it's output. How can this truncation of hostnames be disabled in the output of the netstat command?

Brandon Galbraith

Posted 2015-04-06T21:54:00.573

Reputation: 271

Answers

11

On older versions of OSX and Ubuntu 10.04/16.04, use the -W flag:

netstat -W

On older versions of Linux and OSX 10.13.3, use the -T flag:

netstat -T

On Windows 7/8, use the -f flag:

netstat -f

Brandon Galbraith

Posted 2015-04-06T21:54:00.573

Reputation: 271

You might want to specify your operating system. netstat does not have a -W option on Windows 7 (or apparently on Linux) ... – DavidPostill – 2015-04-07T08:45:51.123

@DavidPostill Updated my answer. Added Linux-specific information. Can you test on Windows 7 if the -T flag is accepted? I don't have access to a Windows 7 environment. – Brandon Galbraith – 2015-04-07T16:07:47.700

@BrandonGalbraith: Win 7's netstat accepts -T, but interprets it as -t: Displays the current connection offload state. netstat -W isn't accepted, i.e. it shows the help. See http://www.computerhope.com/netstat.htm

– mpy – 2015-04-07T17:25:43.730

@mpy I believe the -f flag works on Windows 7. I'll test later today on a VM. – Brandon Galbraith – 2015-04-07T17:35:51.813

@BrandonGalbraith: Oh yes, looks good! – mpy – 2015-04-07T18:27:59.357

@mpy Excellent! Thanks for confirming! I've updated my answer as well! – Brandon Galbraith – 2015-04-07T18:34:00.750

Where does that -T flag for Linux come from? On Ubuntu the correct flag is -W (at least in 10.04 and 16.04) – Rennex – 2016-11-02T21:21:52.120

@Rennex I believe that was on CentOS. I should've noted the specific distro, sorry about that! I'll edit my answer to include you observation. – Brandon Galbraith – 2016-11-04T19:32:42.200