<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
> <channel><title>gHacks Technology News &#124; Latest Tech News, Software And Tutorials &#187; DOS attack</title> <atom:link href="http://www.ghacks.net/tag/dos-attack/feed/" rel="self" type="application/rss+xml" /><link>http://www.ghacks.net</link> <description>A technology news blog covering software, mobile phones, gadgets, security, the Internet and other relevant areas.</description> <lastBuildDate>Sat, 11 Feb 2012 17:32:23 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/> <item><title>Netstat: Quick and useful Linux network information</title><link>http://www.ghacks.net/2009/07/12/netstat-quick-and-useful-linux-network-information/</link> <comments>http://www.ghacks.net/2009/07/12/netstat-quick-and-useful-linux-network-information/#comments</comments> <pubDate>Sun, 12 Jul 2009 20:18:41 +0000</pubDate> <dc:creator>Jack Wallen</dc:creator> <category><![CDATA[Advice]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[Networks]]></category> <category><![CDATA[Open Source]]></category> <category><![CDATA[Security]]></category> <category><![CDATA[Server]]></category> <category><![CDATA[Tutorials Advanced]]></category> <category><![CDATA[Tutorials Basic]]></category> <category><![CDATA[denial of service]]></category> <category><![CDATA[DOS attack]]></category> <category><![CDATA[netstat]]></category> <category><![CDATA[network statistics]]></category> <guid
isPermaLink="false">http://www.ghacks.net/?p=14352</guid> <description><![CDATA[If you use Linux (especially on a server) it is important to be able to have plenty of information at the tips of your fingers. This includes all types of information. One of the first places to look for for information is /var/log, however that can be cumbersome and doesn&#8217;t always give you the specific [...]]]></description> <content:encoded><![CDATA[<p>If you use Linux (especially on a server) it is important to be able to have plenty of information at the tips of your fingers. This includes all types of information. One of the first places to look for for information is <strong>/var/log</strong>, however that can be cumbersome and doesn&#8217;t always give you the specific networking information you need.</p><p>There is one tool that is ready to hand you much of the networking information you will need from your server. That tool? Netstat. The netstat tool prints out (on the command line) information about the Linux networking subsystem. With this tool you can get valuable information about: Open sockets, routing tables,  multicast group membership, network interfaces, masqueraded connections, and protocol statistics. Each type of information can also be narrowed with the help of options.</p><p>In this article you will learn how to be able to make use of the netstat tool, so you can have as much networking information as you need at your fingertips.</p><p><span
id="more-14352"></span><strong>Basic structure</strong></p><p>The basic netstat command looks like:</p><p><em>netstat ARGUMENT OPTIONS</em></p><p>Where <em>ARGUMENT</em> is the type of address family you want information about and <em>OPTIONS</em> is the optional option(s) that will specify the type of information you get returned.</p><p>Now let&#8217;s break this command down into address families.</p><p><strong>Open Sockets</strong></p><p>This is the easiest way to use <em>netstat</em>. If you issue the command without any arguments you will get a list of all sockets that are currently listening on a system. The output would look something like:</p><p><code>Proto RefCnt Flags Type       State         I-Node   Path<br
/> unix  3      [ ]   STREAM     CONNECTED     205824   /tmp/.X11-unix/X0<br
/> unix  3      [ ]   STREAM     CONNECTED     205823<br
/> unix  3      [ ]   STREAM     CONNECTED     203856   /tmp/.X11-unix/X0<br
/> unix  3      [ ]   STREAM     CONNECTED     203855</code></p><p>As you can see, from the output above, the information isn&#8217;t terribly useful. We can make it much more useful with a few options. What we want to do is tell netstat to give us output for specific applications that are listening for tcp connections. To do this we issue the command:</p><p><em>netstat &#8211;tcp &#8211;listening &#8211;programs</em></p><p>The output for this command would look something like:</p><p><code>Proto Recv-Q Send-Q Local Address Foreign Address Stat    PID/Program<br
/> tcp   0      0      *:ssh         *:*             LISTEN  25469/sshd<br
/> tcp   0      0      *:httpd       *:*             LISTEN  26754/httpd<br
/> tcp   0           0           localhost:ipp *:*             LISTEN  -<br
/> </code></p><p>Now you can actually see some useful information. In the above output you can see that both sshd and httpd are listening for incoming connections. The above is just a snippet of what the output can look like. What is very handy about this command is it will show you if there is a command or local address listening for incoming connections that shouldn&#8217;t be listening. If you find an application that shouldn&#8217;t be listening, kill it to be safe.<br
/> <strong>Route</strong></p><p>Netstat is able to quickly print your machines&#8217; kernel routing table with the command:</p><p><em>netstat -r</em></p><p>The output of this command will look like:</p><p><code>Kernel IP routing table<br
/> Destination  Gateway     Genmask         Flags   MSS Window  irtt Iface</code><code> 192.168.1.0  *           255.255.255.0   U       0 0         0    eth0<br
/> default      192.168.1.1 0.0.0.0         UG      0 0         0    eth0</code></p><p><strong>Statistics</strong></p><p>This is one of the handier of the netstat tools. With this you can find out exactly the statics for each protocol. The basic command structure is:</p><p><em>netstat &#8211;statistics</em></p><p>which will give you far more information than you want. Say, you only want to see statistics on the TCP protocol. For this you can issue the command:</p><p><em>netstat -t &#8211;statistics</em></p><p>The output to the above command will include information such as:</p><p><code>Tcp:<br
/> 4343 active connections openings<br
/> 8 passive connection openings<br
/> 5 failed connection attempts<br
/> 178 connection resets received<br
/> 6 connections established<br
/> 59075 segments received<br
/> 60033 segments send out<br
/> 76 segments retransmited<br
/> 0 bad segments received.<br
/> 303 resets sent</code></p><p>Or you could get information on UDP as well with the command:</p><p><em>netstat -u &#8211;statistics</em></p><p>Which would give you similar output for the UDP protocol.</p><p><strong>Get creative</strong></p><p>What if you wanted to see all unique IP addresses connected to a server? You can do that with netstat (and the help of a few other tools) like so:</p><p><code>netstat -nat | awk '{ print $5}' | cut -d: -f1 | sed -e '/^$/d' | uniq</code></p><p>The output of the above command would depend upon how much traffic your machine/server is getting. But it will include all unique IP addresses attempting to connect to your server.</p><p>What about checking to see if your server is under a DOS attack? You can do that with netstat like this:<br
/> <code>netstat -anp |grep 'tcp\|udp' | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n</code></p><p>The above command will list out the IP addresses requesting the highest amount of connections to your server. If you see a number that is far higher than it should be, you most likely are under a Denial of Service attack.</p><p><strong>Final thoughts</strong></p><p>As you can see the <em>netstat</em> command is quite useful. And its usefulness is only limited to your creativity. Have you discovered a handy use for netstat? If so, share it with your fellow ghacks readers.</p><p><span><span
style="margin-left: 0px ! important"><code></code><code><br
/> </code></span></span></p> ]]></content:encoded> <wfw:commentRss>http://www.ghacks.net/2009/07/12/netstat-quick-and-useful-linux-network-information/feed/</wfw:commentRss> <slash:comments>6</slash:comments> </item> </channel> </rss>
