<?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>Zero Intellect &#187; unix</title>
	<atom:link href="http://www.zerointellect.com/tag/unix/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.zerointellect.com</link>
	<description>Technology Blog requiring Zero Intellect to follow !!!</description>
	<lastBuildDate>Mon, 28 Jun 2010 14:09:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Nslookup command overview</title>
		<link>http://www.zerointellect.com/networking/nslookup-command-overview/</link>
		<comments>http://www.zerointellect.com/networking/nslookup-command-overview/#comments</comments>
		<pubDate>Wed, 09 Dec 2009 06:00:27 +0000</pubDate>
		<dc:creator>zrydento</dc:creator>
				<category><![CDATA[Networking]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Tool Zone]]></category>
		<category><![CDATA[CNAME]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[dns]]></category>
		<category><![CDATA[DNS record]]></category>
		<category><![CDATA[fully qualified domain name]]></category>
		<category><![CDATA[ls command]]></category>
		<category><![CDATA[lserver]]></category>
		<category><![CDATA[MX]]></category>
		<category><![CDATA[mx record]]></category>
		<category><![CDATA[NS]]></category>
		<category><![CDATA[nslookup]]></category>
		<category><![CDATA[PTR]]></category>
		<category><![CDATA[query refused]]></category>
		<category><![CDATA[querytype]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[system32]]></category>
		<category><![CDATA[type]]></category>
		<category><![CDATA[unix]]></category>
		<category><![CDATA[utility]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[zone transfer]]></category>

		<guid isPermaLink="false">http://www.zerointellect.com/?p=286</guid>
		<description><![CDATA[<p> </p>
<p>Nslookup.exe (abbreviation for name server lookup) is a command line utility used for testing and troubleshooting DNS servers. It is built into Unix (including Linux and variants) and Windows. The main purpose of the utility is to query DNS servers to find DNS details, MX records for a domain, NS servers of a domain</p>
<p>In Windows, Nslookup.exe <p>Continue reading <a href="http://www.zerointellect.com/networking/nslookup-command-overview/">Nslookup command overview</a></p>]]></description>
			<content:encoded><![CDATA[<p> </p>
<p>Nslookup.exe (abbreviation for name server lookup) is a command line utility used for testing and troubleshooting DNS servers. It is built into Unix (including Linux and variants) and Windows. The main purpose of the utility is to query DNS servers to find DNS details, MX records for a domain, NS servers of a domain</p>
<p>In Windows, Nslookup.exe is automatically installed along with the TCP/IP protocol installation which is done by default during a new Windows installation or setup. The actual executable lies in the system directory <strong>c:\windows\system32 directory</strong> by default in Windows XP and most other versions of Windows.</p>
<p> </p>
<p><strong>To get started with Nslookup.exe, the following prerequisites need to be present: </strong></p>
<p>The TCP/IP protocol must be installed on the computer that you want to execute the Nslookup command without which the command will not be available</p>
<p>When you run the ipconfig /all command, at least one DNS server should exist in the list of DNS servers</p>
<p> </p>
<p><img class="aligncenter" src="http://www.zerointellect.com/uploads/09122009-diagram-1-1.png" alt="" width="505" height="309" /></p>
<p> </p>
<p>The Nslookup command always devolves (delegates from) the domain name from the current context (depending on the DNS Server settings listed). If you fail to use a fully qualified domain name, i.e. ending the domain name with a trailing dot (.), the first query will append the DNS settings to your query domain name. For example, if you have your DNS settings listed as <strong>xyz.com</strong> and you run a query for <strong>www.bing.com</strong>, the actual query will go out as <strong>www.bing.com.xyz.com</strong> because of you entering an unqualified query. However, if you were to query for <strong>www.bing.com. </strong>[with the trailing dot (.)], then the query would rightly go out to <strong>www.bing.com</strong> only (diagram below). This strange behavior is specific to the Microsoft version of the Nslookup command. I do not know of how Nslookup behaves while run with other vendors.</p>
<p> </p>
<p><img class="aligncenter" src="http://www.zerointellect.com/uploads/09122009-diagram-1-2.png" alt="" width="450" height="350" /></p>
<p> </p>
<p>If the DNS search list is being used in the Domain suffix search order in TCP/IP advanced properties DNS tab (diagram below), devolution will not take place. The query will be appended to the domain suffixes specified in the list. To override the search list, always use the Fully Qualified Domain Name in your query.</p>
<p> </p>
<p><img class="aligncenter" src="http://www.zerointellect.com/uploads/09122009-diagram-1-3.png" alt="" width="550" height="632" /></p>
<p> </p>
<p>The command can be used directly (<strong>non-interactive</strong> mode) or with subcommands (<strong>interactive</strong> mode). Using Nslookup.exe in the non-interactive mode is useful when we just need the output of a specific query and only a single value needs to be returned. But when we need to get the output for multiple queries and actions it is better to use the interactive mode</p>
<p> </p>
<p>The syntax of Non Interactive Mode is as follows:</p>
<p> </p>
<blockquote><p><strong>nslookup [-option] [hostname] [server]</strong></p>
<p> nslookup [-opt ...]                          # interactive mode using default server</p>
<p>nslookup [-opt ...] &#8211; server          # interactive mode using &#8216;server&#8217;</p>
<p>nslookup [-opt ...] host                 # just look up &#8216;host&#8217; using default server</p>
<p>nslookup [-opt ...] host server    # just look up &#8216;host&#8217; using &#8216;server&#8217;</p>
<p>Option refers to the various options that are available covered below</p>
<p>Hostname refers to the query that we need information on</p>
<p>Server refers to the DNS server to be used to search for the host</p></blockquote>
<p> </p>
<p> Look at the following output from a unix and windows based host</p>
<p> </p>
<p><strong>Command line output (without subcommands)</strong></p>
<p> </p>
<blockquote><p><strong>UNIX</strong></p>
<p>unix% nslookup example.com</p>
<p>Server:        192.168.1.1<br />
Address:    192.168.1.1#53</p>
<p>Non-authoritative answer:</p>
<p>Name:    example.com<br />
Address: 202.7.18.16</p>
<p> </p>
<p><strong>Windows</strong></p>
<p>C:\&gt;nslookup microsoft.com.</p>
<p>Server:  PQRTVXXXXD002DNS076<br />
Address:  210.213.34.3</p>
<p>Non-authoritative answer:</p>
<p>Name:    microsoft.com<br />
Addresses:  207.46.197.32, 207.46.232.182</p></blockquote>
<p> </p>
<p><strong>Using subcommands (unix example)</strong></p>
<p> </p>
<blockquote><p><strong>nslookup</strong></p>
<p><strong>&gt; server ns1.com</strong></p>
<p>Default Server:  ns1.com<br />
Address:  172.204.22.25</p>
<p>&gt; set<br />
&gt; example.com</p>
<p>Server:  ns1.com<br />
Address:  202.7.18.16</p>
<p>example.com   MX preference = 10, mail exchanger = mail.example.com<br />
&gt; exit</p></blockquote>
<p> </p>
<p>After entering the interactive mode, typing ? or help will reveal all the options that are available</p>
<p> </p>
<p><img class="aligncenter" src="http://www.zerointellect.com/uploads/09122009-diagram-1-4.png" alt="" width="550" height="371" /> </p>
<p>To interrupt interactive commands, press CTRL+C. To exit interactive mode and return to the command prompt, type exit at the command prompt. A number of different options can be set in Nslookup.exe by running the set command at the command prompt. A complete listing of these options is obtained by typing set all.</p>
<p> </p>
<p><strong>Looking up different data types: type and querytype</strong> </p>
<p>We will discuss the two options, type and querytype that belong to the set command. To look at different query type options within the domain name space, we use the set type or set querytype command at the command prompt. Both of them are exactly the same and are interchangeable. For example, to query for mail exchanger records (mail server details) of a particular domain like yahoo.com, we can type the following:</p>
<p> </p>
<blockquote><p><strong>C:\&gt;nslookup</strong></p>
<p>&gt; set q=mx<br />
&gt; yahoo.com.</p>
<p>Server:  google-public-dns-a.google.com<br />
Address:  8.8.8.8</p>
<p>Non-authoritative answer:<br />
yahoo.com       MX preference = 1, mail exchanger = a.mx.mail.yahoo.com<br />
yahoo.com       MX preference = 1, mail exchanger = b.mx.mail.yahoo.com<br />
yahoo.com       MX preference = 1, mail exchanger = c.mx.mail.yahoo.com<br />
yahoo.com       MX preference = 1, mail exchanger = e.mx.mail.yahoo.com<br />
yahoo.com       MX preference = 1, mail exchanger = f.mx.mail.yahoo.com<br />
yahoo.com       MX preference = 1, mail exchanger = g.mx.mail.yahoo.com</p></blockquote>
<p> </p>
<p>The first time a remote host is queried, the local DNS server contacts the DNS server that is authoritative for that domain. The local DNS server will then cache that information, so that subsequent queries are answered nonauthoritatively out of the local server&#8217;s cache. The first time a query is made for a remote name, the answer is authoritative, but subsequent queries are nonauthoritative.</p>
<p> </p>
<p><strong>Querying another name server directly: server  and lserver</strong></p>
<p>If we wanted to use another DNS server on the internet to send our queries, we can use the server or lserver commands. For example, using the DNS server 8.8.8.8 that is the Google Public DNS server</p>
<p> </p>
<blockquote><p><strong>C:\&gt;nslookup</strong></p>
<p>Default Server:  nameserver1.example.com<br />
Address:  10.1.2.3</p>
<p>&gt; server 8.8.8.8<br />
Default Server:  google-public-dns-a.google.com<br />
Address:  8.8.8.8</p></blockquote>
<p> </p>
<p>The difference between the <strong>server</strong> and <strong>lserver</strong> commands is that the server command is uses the current default server to get the address of the server to switch to, whereas the lserver uses the local server to get the same address. For example, if you have a broadband connection and get a DHCP IP address from your ISP, you would also automatically get some DNS servers (assume dns1.isp1.com), the lserver command forces the usage of these local dns servers that were retrieved from your ISP. However, while using the Nslookup.exe command, if you earlier changed the DNS server that is used to query for other domains (assume you changed it to dns1.somefreedns.com), the server command would use the current default server (dns1.somefreedns.com) and not the local dns servers (dns1.isp1.com)</p>
<p> </p>
<p><strong>Zone Transfers : LS command</strong></p>
<p>Nslookup.exe can be used to transfer an entire zone by using the ls command. The best use of this command is if you want to store a list of all host names within a particular remote domain into a local file (example below)</p>
<p> </p>
<p>The syntax of this command is</p>
<p> </p>
<blockquote><p><strong>ls [opt] DOMAIN [&gt; FILE] &#8211; list addresses in DOMAIN (optional: output to FILE)<br />
</strong>    -a          -  list canonical names and aliases<br />
    -d          -  list all records<br />
    -t TYPE     -  list records of the given type (e.g. A,CNAME,MX,NS,PTR etc.)</p></blockquote>
<p> </p>
<p>Using ls with no arguments will return a list of all address and name server data. The -a switch will return alias and canonical names, -d will return all data, and -t will filter by type.</p>
<p> </p>
<blockquote><p><strong>&gt;ls example.com</strong></p>
<p>[nameserver1.example.com]</p>
<p>nameserver1.example.com.    NS     server = ns1.example.com<br />
nameserver2.example.com     NS     server = ns2.example.com<br />
nameserver1                            A      10.0.0.1<br />
nameserver2                            A      10.0.0.2</p></blockquote>
<p> </p>
<p>While this is obviously a security issue, zone transfers can be blocked at the DNS Server level and this would be the case most of the time on the internet (unless someone foolish enough would like you to see his internal structure and naming conventions). This command is useful if we want to see the structure of hosts within a LAN environment. If zone transfers have been blocked, we would get output like the following</p>
<p> </p>
<blockquote><p><strong>&gt; ls google.com.<br />
*** Can&#8217;t list domain example.com.: Query refused</strong></p></blockquote>
<p> </p>
<p>When we want to send the output to a file (the file will be saved in the location that was mentioned in the command prompt before the nslookup command was started, we can do so as follows</p>
<p> </p>
<blockquote><p><strong>&gt; ls google.com. &gt; lsoutput.txt<br />
Received 0 records.<br />
*** Can&#8217;t list domain google.com.: Query refused</strong></p></blockquote>
<p> </p>
<p>In the following example below, we want to view all mail server records within a particular domain and store the output to a file</p>
<p> </p>
<blockquote><p><strong>&gt; ls –t MX google.com. &gt; lsoutput.txt<br />
Received 0 records.<br />
*** Can&#8217;t list domain google.com.: Query refused</strong></p></blockquote>
<p> </p>
<p>In this article the Nslookup command was covered. While this was just a brief overview, there are many other issues like troubleshooting and whether using Nslookup itself is recommend which will be covered in future articles</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zerointellect.com/networking/nslookup-command-overview/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Netstat Torn Apart</title>
		<link>http://www.zerointellect.com/toolzone/netstat-torn-apart/</link>
		<comments>http://www.zerointellect.com/toolzone/netstat-torn-apart/#comments</comments>
		<pubDate>Fri, 27 Nov 2009 10:34:51 +0000</pubDate>
		<dc:creator>zrydento</dc:creator>
				<category><![CDATA[Tool Zone]]></category>
		<category><![CDATA[active connections]]></category>
		<category><![CDATA[arguments]]></category>
		<category><![CDATA[icmp]]></category>
		<category><![CDATA[ipv4]]></category>
		<category><![CDATA[ipv6]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[netstat]]></category>
		<category><![CDATA[netstat tutorial]]></category>
		<category><![CDATA[process explorer]]></category>
		<category><![CDATA[routing table]]></category>
		<category><![CDATA[sysinternals]]></category>
		<category><![CDATA[tcp]]></category>
		<category><![CDATA[udp]]></category>
		<category><![CDATA[unix]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.zerointellect.com/?p=128</guid>
		<description><![CDATA[<p> </p>
<p>I use the NETSTAT command frequently during my consulting assignments, however apart from the common options; I never delved into using all options of the command. My curiosity got the better of me and I went on to explore all the options of the NETSTAT command, so here goes</p>
<p>NETSTAT (network statistics) is a command-line utility that <p>Continue reading <a href="http://www.zerointellect.com/toolzone/netstat-torn-apart/">Netstat Torn Apart</a></p>]]></description>
			<content:encoded><![CDATA[<p> </p>
<p>I use the NETSTAT command frequently during my consulting assignments, however apart from the common options; I never delved into using all options of the command. My curiosity got the better of me and I went on to explore all the options of the NETSTAT command, so here goes</p>
<p>NETSTAT (network statistics) is a command-line utility that displays incoming &amp; outgoing network connections, routing tables and various network interface statistics. The command has various parameters that can be used and is available on Unix, Linux and Windows based operating systems</p>
<p>Parameters of the netsat command on Windows based systems. Linux, Unix, BSD based systems have most of the parameters common with a few exceptions</p>
<p>A quick output of the help of the netstat command by appending /? gives us the following parameter options</p>
<p> </p>
<p style="text-align: center"><img class="aligncenter" src="http://www.zerointellect.com/uploads/0000004-diagram-1.png" alt="" width="550" height="402" /></p>
<p> </p>
<p>A detailed explanation of each parameter with examples follows</p>
<p> </p>
<p><strong><strong>-a</strong>   Displays all connections and listening ports</strong></p>
<p>Running the netstat command with the -a parameter displays the of active connections as is displayed in the output below</p>
<p> </p>
<blockquote><p><strong>C:\&gt;netstat</strong></p>
<p><strong>Active Connections</strong></p>
<p><strong>  Proto  Local Address          Foreign Address              State<br />
  TCP    host540:19208          microsoft.com:http    CLOSE_WAIT<br />
  TCP    host540:19473          yahoo.com:http             ESTABLISHED</strong></p></blockquote>
<p> </p>
<p>Starting with the protocol as the first column which could be either TCP/UDP based. The &#8220;host540:19208&#8243; in the second column is a combination of the host name of the computer that the command is being run on which in this case is <strong>host540</strong> and the local port number which is 19208. For well known services the protocol would be appended, for example <strong>host540:ntp</strong> but for services that are not well known the local port number would be mentioned</p>
<p>The foreign address is the website and the service that the connection was opened to which is <strong>microsoft.com:http</strong> in this case with port 80 (http) or web traffic and the connection state is <strong>CLOSE_WAIT</strong></p>
<p>If the port is not yet established, the port number is shown as a * which would normally be seen in the output as &#8220;*:*&#8221;</p>
<p> </p>
<p><strong>-b   Displays the executable involved in creating each connection or listening port. In some cases well-known executables host multiple independent components, and in these cases the sequence of components involved in creating the connection or listening port is displayed.</strong></p>
<p><strong> </strong> </p>
<blockquote><p><strong>C:\&gt;netstat -b</strong></p>
<p><strong>Active Connections</strong></p>
<p><strong>Proto  Local Address          Foreign Address               State                        PID<br />
  TCP    host540:19208       microsoft.com:http   CLOSE_WAIT       1148<br />
  [iexplore.exe]</strong></p>
<p><strong>  TCP    host540:19473       yahoo.com:http             ESTABLISHED   7848<br />
  [firefox.exe]</strong></p>
<p> </p></blockquote>
<p>Additionally the process id of the process is also available. In this case the executable name is in [] at the bottom, on top is the component it called, and so forth until TCP/IP was reached. Note that this option can be time-consuming and will fail unless you have sufficient permissions</p>
<p><strong> </strong> </p>
<p><strong>-e   Displays Ethernet statistics. This may be combined with the -s option<br />
 </strong></p>
<blockquote><p><strong>C:\&gt;netstat -e<br />
Interface Statistics</strong></p>
<p><strong>                                                    Received            Sent</strong></p>
<p><strong>Bytes                                              41185465        10381455<br />
Unicast packets                      248414             246100<br />
Non-unicast packets           48535               303<br />
Discards                                        0                          0<br />
Errors                                             0                          1<br />
Unknown protocols             0</strong></p></blockquote>
<p><strong> </strong></p>
<p>The number of packets, bytes, errors and other information received and sent is displayed. This may be useful when tracking network usage and can be combined with the -s option.  For example one may only want to see received packets of type http, which can be done using the -e and -s options</p>
<p> </p>
<p><strong>-n   Displays addresses and port numbers in numerical form</strong></p>
<p>This is similar to the standard netstat option without any parameters, however dns queries are done to convert all addresses and port numbers into numerical form. For example, in the output microsoft.com would be listed as its corresponding ip address and http would be displayed as 80<br />
<strong> </strong></p>
<p><strong>-o   Displays the owning process ID associated with each connection</strong></p>
<p>The process ID which owns the connection can be viewed and then other utilities like <strong>Sysinternals Process Explorer</strong> can be used to drill down and get further information. The process id is also displayed other options like -b as was mentioned above</p>
<p><strong> </strong></p>
<p><strong>-p proto</strong>   Shows connections for the protocol specified by proto; proto may be any of: TCP, UDP, TCPv6, or UDPv6.  If used with the -s option to display per-protocol statistics, proto may be any of IP, IPv6, ICMP, ICMPv6, TCP, TCPv6, UDP, or UDPv6</p>
<p>This is one of the most useful options to view specific connections opened by the protocol specified. For example, if one wants to view the opened UDP connections, the command <strong>netstat -p proto UDP</strong> could be used</p>
<p><strong> </strong></p>
<p><strong>-r   Displays the routing table</strong></p>
<p>Here all interfaces present in the system with their netmask, gateway, metric and name of the ethernet adapter is displayed. It gives you  a quick overview of ip addresses assigned and interface name, etc. Active as well as persistent routes are displayed</p>
<p><strong> </strong></p>
<p><strong>-s</strong>   Displays per-protocol statistics.  By default, statistics are shown for IP, IPv6, ICMP, ICMPv6, TCP, TCPv6, UDP, and UDPv6; the -p option may be used to specify a subset of the default</p>
<p>Another useful option to view statistics per protocol. For example, to view only UDP statistics, the following command could be used</p>
<blockquote><p><strong>C:\&gt;netstat -s -p UDP</strong></p>
<p><strong>UDP Statistics for IPv4</strong></p>
<p><strong>  Datagrams Received    = 328852<br />
  No Ports              = 16880<br />
  Receive Errors        = 79<br />
  Datagrams Sent        = 197475</strong></p>
<p><strong>Active Connections</strong></p>
<p><strong>  Proto  Local Address          Foreign Address        State</strong></p></blockquote>
<p><strong> </strong></p>
<p><strong> </strong> The output above does not have any active UDP connections</p>
<p> </p>
<p><strong>-v            When used in conjunction with -b, will display sequence of components involved in creating the connection or listening port for all executables.<br />
</strong></p>
<p>After we have used the -b option to drill down and find out that a component [iexplore.exe] as well as other components were involved in creating the connection, we can further use the -v option to order the components involved in creating the connection. This is useful when understanding the sequencing of connection requests by an arbitrary application. It gives you an internal listing of .dll&#8217;s being called in real time</p>
<p> </p>
<p><strong>interval</strong>      Redisplays selected statistics, pausing interval seconds between each display.  Press CTRL+C to stop redisplaying statistics.  If omitted, netstat will print the current configuration information once</p>
<p>This is a good way to auto refresh the screen with any output desired. I might want to see the output of the netstat -n every 5 seconds. I would then use the <strong>netstat -n 5</strong> command</p>
<p> </p>
<p>To summarize, netstat is an external tool that is built into Windows, Unix, Linux, etc and displays a lot of useful information</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zerointellect.com/toolzone/netstat-torn-apart/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

