Kevin Deldycke - lsofhttps://kevin.deldycke.com/2011-04-11T16:25:54+02:00Professional Yak ShaverNetwork Commands2011-04-11T16:25:54+02:002011-04-11T16:25:54+02:00Kevin Deldycketag:kevin.deldycke.com,2011-04-11:/2011/04/network-commands/<h2 id="interfaces">Interfaces<a class="headerlink text-decoration-none small pl-2" href="#interfaces" title="Permanent link">&para;</a></h2> <ul> <li> <p>Get the list of all wireless networks reachable by the <code>wlan0</code> interface:</p> <div class="highlight"><pre><span></span><code><span class="gp">$</span> iwlist wlan0 scanning <span class="p">|</span> grep ESSID </code></pre></div> </li> <li> <p>Get some informations about open&nbsp;ports:</p> <div class="highlight"><pre><span></span><code><span class="gp">$</span> netstat --taupen <span class="gp">$</span> netstat --lapute </code></pre></div> </li> <li> <p>Watch network activity in&nbsp;real-time:</p> <div class="highlight"><pre><span></span><code><span class="gp">$</span> watch -n <span class="m">1</span> <span class="s2">&quot;lsof -i&quot;</span> </code></pre></div> </li> <li> <p>Reboot machine if the <code>192.168.0.254</code> host doesn&rsquo;t reply …</p></li></ul><h2 id="interfaces">Interfaces<a class="headerlink text-decoration-none small pl-2" href="#interfaces" title="Permanent link">&para;</a></h2> <ul> <li> <p>Get the list of all wireless networks reachable by the <code>wlan0</code> interface:</p> <div class="highlight"><pre><span></span><code><span class="gp">$</span> iwlist wlan0 scanning <span class="p">|</span> grep ESSID </code></pre></div> </li> <li> <p>Get some informations about open&nbsp;ports:</p> <div class="highlight"><pre><span></span><code><span class="gp">$</span> netstat --taupen <span class="gp">$</span> netstat --lapute </code></pre></div> </li> <li> <p>Watch network activity in&nbsp;real-time:</p> <div class="highlight"><pre><span></span><code><span class="gp">$</span> watch -n <span class="m">1</span> <span class="s2">&quot;lsof -i&quot;</span> </code></pre></div> </li> <li> <p>Reboot machine if the <code>192.168.0.254</code> host doesn&rsquo;t reply to at least one ping after 15 attemps or 600&nbsp;seconds:</p> <div class="highlight"><pre><span></span><code><span class="gp">$</span> ping -c <span class="m">15</span> -o -t <span class="m">600</span> <span class="m">192</span>.168.0.254 <span class="o">||</span> shutdown -r now </code></pre></div> </li> </ul> <h2 id="domain-names">Domain Names<a class="headerlink text-decoration-none small pl-2" href="#domain-names" title="Permanent link">&para;</a></h2> <ul> <li> <p>Get the <span class="caps">IP</span> address where a domain points&nbsp;to:</p> <div class="highlight"><pre><span></span><code><span class="gp">$</span> host kevin.deldycke.com </code></pre></div> </li> <li> <p>Get different kind of <span class="caps">DNS</span> records of the <code>example.com</code> domain:</p> <div class="highlight"><pre><span></span><code><span class="gp">$</span> dig example.com CNAME <span class="gp">$</span> dig example.com MX </code></pre></div> </li> </ul> <h2 id="content-inspection">Content Inspection<a class="headerlink text-decoration-none small pl-2" href="#content-inspection" title="Permanent link">&para;</a></h2> <ul> <li>Save all images passing through <code>eth0</code>:<div class="highlight"><pre><span></span><code><span class="gp">$</span> driftnet -i eth0 -a -d ./http-pics </code></pre></div> </li> </ul> <h2 id="samba-cifs">Samba / <span class="caps">CIFS</span><a class="headerlink text-decoration-none small pl-2" href="#samba-cifs" title="Permanent link">&para;</a></h2> <ul> <li>Mount a samba share:<div class="highlight"><pre><span></span><code><span class="gp">$</span> mkdir /mnt/freebox <span class="gp">$</span> mount_smbfs -I <span class="m">192</span>.168.0.254 //Guest@/Disque<span class="se">\ </span><span class="m">1</span>/ /mnt/freebox </code></pre></div> </li> </ul>