Your SlideShare is downloading. ×
0
Linux Networking Commands
Linux Networking Commands
Linux Networking Commands
Linux Networking Commands
Linux Networking Commands
Linux Networking Commands
Linux Networking Commands
Linux Networking Commands
Linux Networking Commands
Linux Networking Commands
Linux Networking Commands
Linux Networking Commands
Linux Networking Commands
Linux Networking Commands
Linux Networking Commands
Linux Networking Commands
Linux Networking Commands
Linux Networking Commands
Linux Networking Commands
Linux Networking Commands
Linux Networking Commands
Linux Networking Commands
Linux Networking Commands
Linux Networking Commands
Linux Networking Commands
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Linux Networking Commands

4,244

Published on

Linux/Unix Networking Commands

Linux/Unix Networking Commands

Published in: Technology
0 Comments
7 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
4,244
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
451
Comments
0
Likes
7
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Linux Networking Commands Copyright, 2002 © NTM Consulting Inc. TCP/IP Lecture Series Professor Tom Mavroidis
  • 2. Commands Reviewed Ifconfig dmesg netstat ping route traceroute nslookup arp dig
  • 3. ifconfig <ul><li>ifconfig is used to assign an address to a network interface and/or configure network interface parameters. ifconfig must be used at boot time to define the network address of each interface present on a machine; it may also be used at a later time to redefine an interface&apos;s address or other operating parameters. </li></ul>
  • 4. ifconfig eth0 <ul><li>eth0 Link encap:Ethernet HWaddr 00:04:AC:16:54:4C </li></ul><ul><li>inet addr:192.168.2.1 Bcast:192.168.2.255 Mask:255.255.255.0 </li></ul><ul><li>inet6 addr: fe80::204:acff:fe16:544c/10 Scope:Link </li></ul><ul><li>UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 </li></ul><ul><li>RX packets:116242 errors:0 dropped:0 overruns:0 frame:0 </li></ul><ul><li>TX packets:123380 errors:0 dropped:0 overruns:0 carrier:0 </li></ul><ul><li>collisions:9052 </li></ul><ul><li>RX bytes:39103579 (37.2 Mb) TX bytes:106270739 (101.3 Mb) </li></ul>
  • 5. When would you use ifconfig? <ul><li>To determine if an interface has been recognized and configured on a system </li></ul><ul><li>To initially assign an IP address to an interface </li></ul><ul><li>to bring an interface up or down </li></ul>
  • 6. What should you do if the interface isn’t found? <ul><li>This kind of problem usually appears on initial setup of a machine </li></ul><ul><li>[root@localhost root]# ifconfig eth3 up </li></ul><ul><li>eth3: unknown interface: No such device </li></ul>
  • 7. See if the device has been found - use dmesg <ul><li>The command &apos;dmesg&apos;, which is used to print kernel messages, is very useful in determining if a piece of hardware has been found, and if so, what the system is referring to it as. </li></ul><ul><li>Don’t forger to monitor the /var/log/messages file for any strange activity. </li></ul>TIP pipe the dmesg to the less command or the reply will scroll off the screen dmesg | less
  • 8. Before you have a useable interface <ul><li>Determine if you can ping the localhost </li></ul><ul><li>ping localhost or </li></ul><ul><li>ping 127.0.0.1 </li></ul>
  • 9. Does the localhost respond? <ul><li>[root@localhost root]# ping localhost </li></ul><ul><li>PING localhost.localdomain (127.0.0.1) from 127.0.0.1 : 56(84) bytes of data. </li></ul><ul><li>64 bytes from localhost.localdomain (127.0.0.1): icmp_seq=0 ttl=255 time=1.968 msec </li></ul><ul><li>64 bytes from localhost.localdomain (127.0.0.1): icmp_seq=1 ttl=255 time=113 usec </li></ul><ul><li>64 bytes from localhost.localdomain (127.0.0.1): icmp_seq=2 ttl=255 time=178 usec </li></ul><ul><li>64 bytes from localhost.localdomain (127.0.0.1): icmp_seq=3 ttl=255 time=116 usec </li></ul>
  • 10. Confirm you have set up the interface correctly. <ul><li>ping the address returned by the ifconfig command “Ping 192.168.2.1” </li></ul>eth0 Link encap:Ethernet HWaddr 00:04:AC:16:54:4C inet addr: 192.168.2.1 Bcast:192.168.2.255 Mask:255.255.255.0 inet6 addr: fe80::204:acff:fe16:544c/10 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:116242 errors:0 dropped:0 overruns:0 frame:0 TX packets:123380 errors:0 dropped:0 overruns:0 carrier:0 collisions:9052 RX bytes:39103579 (37.2 Mb) TX bytes:106270739 (101.3 Mb)
  • 11. ping <ul><li>System administration command. Confirm that a remote host is online and responding. ping is intended for use in network testing, measurement, and management. Because of the load it can impose on the network, it is unwise to use ping during normal operations or from automated scripts. </li></ul>
  • 12. route <ul><li>Gateways route data between networks </li></ul><ul><li>All devices make routing decisions </li></ul><ul><ul><li>local network? Deliver to destination </li></ul></ul><ul><ul><li>remote network? Forward to local gateway </li></ul></ul>
  • 13. route -n <ul><li>-n prevents route from converting IP addresses to hostnames </li></ul><ul><li>the 0.0.0.0 entry is the default gateway </li></ul>[root@localhost root]# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1 127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo 0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth1
  • 14. route -Cn (display cache table) <ul><li>[root@localhost root]# route -Cn </li></ul><ul><li>Kernel IP routing cache </li></ul><ul><li>Source Destination Gateway Flags Metric Ref Use Iface </li></ul><ul><li>192.168.1.101 192.168.1.55 192.168.1.55 il 0 0 65 lo </li></ul><ul><li>192.168.2.1 192.168.2.75 192.168.2.75 0 1 0 eth0 </li></ul><ul><li>192.168.1.55 192.175.48.42 192.168.1.1 0 0 0 eth1 </li></ul><ul><li>192.168.1.55 192.168.1.101 192.168.1.101 0 0 1 eth1 </li></ul><ul><li>192.168.1.55 192.168.1.101 192.168.1.101 0 1 0 eth1 </li></ul><ul><li>127.0.0.1 127.0.0.1 127.0.0.1 l 0 0 3 lo </li></ul><ul><li>192.168.1.101 192.168.1.255 192.168.1.255 ibl 0 0 4 lo </li></ul><ul><li>127.0.0.1 127.0.0.1 127.0.0.1 l 0 0 1 lo </li></ul>
  • 15. traceroute <ul><li>Trace route taken by packets to reach network host. traceroute attempts tracing by launching UDP probe packets with a small TTL (time to live), then listening for an ICMP &amp;quot;time exceeded&amp;quot; reply from a gateway. host is the destination hostname or the IP number of host to reach. packetsize is the packet size in bytes of the probe datagram. Default is 38 bytes. </li></ul>Note Traceroute has lost some of its effectiveness since most ISP’s disallow it from running on their networks
  • 16. nslookup <ul><li>Query Internet domain name servers. nslookup has two modes: interactive and noninteractive. Interactive mode allows the user to query name servers for information about various hosts and domains or to print a list of hosts in a domain. It is entered either when no arguments are given (default name server will be used) or when the first argument is a hyphen and the second argument is the hostname or Internet address of a name server. Noninteractive mode is used to print just the name and requested information for a host or domain. It is used when the name of the host to be looked up is given as the first argument. Any of the keyword = value pairs listed under the interactive set command can be used as an option on the command line by prefacing the keyword with a -. The optional second argument specifies a name server. </li></ul>
  • 17. arp <ul><li>Physical networks have their own addressing scheme </li></ul><ul><li>IP addresses are used to direct a datagram to a specific physical network </li></ul>
  • 18. arp table <ul><li>arp maintains a table of translations between IP addresses and ethernet addresses </li></ul><ul><li>[root@localhost root]# arp </li></ul><ul><li>Address HWtype HWaddress Flags Mask Iface </li></ul><ul><li>192.168.1.1 ether 00:04:5A:DB:A1:C5 C eth1 </li></ul><ul><li>192.168.2.75 ether 00:10:E0:04:61:84 C eth0 </li></ul><ul><li>192.168.1.101 ether 00:09:B7:13:AA:13 C eth1 </li></ul>
  • 19. /etc/hosts <ul><li>Setting the hosts file will resolve names to addresses </li></ul>[root@localhost root]# less /etc/hosts # Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 localhost.localdomain localhost 192.168.1.1 gatewayout.tcp-ip.ca 192.168.2.75 basement.tcp-ip.ca 192.168.1.101 just_a_node.tcp-ip.ca
  • 20. arp -a will then resolve <ul><li>Instead of just names, you also get IP addresses </li></ul><ul><li>[root@localhost root]# arp -a </li></ul><ul><li>gatewayout.tcp-ip.ca (192.168.1.1) at 00:04:5A:DB:A1:C5 [ether] on eth1 </li></ul><ul><li>basement.tcp-ip.ca (192.168.2.75) at 00:10:E0:04:61:84 [ether] on eth0 </li></ul><ul><li>just_a_node.tcp-ip.ca (192.168.1.101) at 00:09:B7:13:AA:13 [ether] on eth1 </li></ul>
  • 21. netstat <ul><li>The netstat command symbolically displays the contents of various net- work-related data structures. There are a number of output formats, de- pending on the options for the information presented. The first form of the command displays a list of active sockets for each protocol. The second form presents the contents of one of the other network data struc- tures according to the option selected. Using the third form, with a wait interval specified, netstat will continuously display the informa- tion regarding packet traffic on the configured network interfaces. The fourth form displays statistics about the named protocol. </li></ul>
  • 22. netstat -nr <ul><li>[root@localhost root]# netstat -nr </li></ul><ul><li>Kernel IP routing table </li></ul><ul><li>Destination Gateway Genmask Flags MSS Window irtt Iface </li></ul><ul><li>192.168.2.0 0.0.0.0 255.255.255.0 U 40 0 0 eth0 </li></ul><ul><li>192.168.1.0 0.0.0.0 255.255.255.0 U 40 0 0 eth1 </li></ul><ul><li>127.0.0.0 0.0.0.0 255.0.0.0 U 40 0 0 lo </li></ul><ul><li>0.0.0.0 192.168.1.1 0.0.0.0 UG 40 0 0 eth1 </li></ul>
  • 23. dig - supercharged nslookup <ul><li>oroot@localhost root]# dig cs.senecac.on.ca </li></ul><ul><li>; &lt;&lt;&gt;&gt; DiG 9.1.3 &lt;&lt;&gt;&gt; cs.senecac.on.ca </li></ul><ul><li>;; global options: printcmd </li></ul><ul><li>;; Got answer: </li></ul><ul><li>;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 10483 </li></ul><ul><li>;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 6, ADDITIONAL: 4 </li></ul><ul><li>;; QUESTION SECTION: </li></ul><ul><li>;cs.senecac.on.ca. IN A </li></ul><ul><li>;; ANSWER SECTION: </li></ul><ul><li>cs.senecac.on.ca. 86400 IN A 142.204.57.48 </li></ul>
  • 24. dig - better than nslookup <ul><li>;; AUTHORITY SECTION: </li></ul><ul><li>senecac.on.ca. 86400 IN NS ns.onet.on.ca. </li></ul><ul><li>senecac.on.ca. 86400 IN NS ns2.senecac.on.ca. </li></ul><ul><li>senecac.on.ca. 86400 IN NS hades.senecac.on.ca. </li></ul><ul><li>senecac.on.ca. 86400 IN NS ittads.senecac.on.ca. </li></ul><ul><li>senecac.on.ca. 86400 IN NS pulsar.senecac.on.ca. </li></ul><ul><li>senecac.on.ca. 86400 IN NS nsprime.senecac.on.ca. </li></ul><ul><li>;; ADDITIONAL SECTION: </li></ul><ul><li>ns2.senecac.on.ca. 86400 IN A 142.204.10.100 </li></ul><ul><li>hades.senecac.on.ca. 86400 IN A 142.204.57.15 </li></ul><ul><li>ittads.senecac.on.ca. 86400 IN A 142.204.6.57 </li></ul><ul><li>pulsar.senecac.on.ca. 86400 IN A 142.204.119.97 </li></ul><ul><li>;; Query time: 2202 msec </li></ul><ul><li>;; SERVER: 127.0.0.1#53(127.0.0.1) </li></ul><ul><li>;; WHEN: Sun Sep 29 16:38:20 2002 </li></ul><ul><li>;; MSG SIZE rcvd: 238 </li></ul>
  • 25. References <ul><li>For detailed syntax on these and other linux commands look at </li></ul><ul><li>http://www. oreillynet .com/ linux / cmd / </li></ul>

×