Unix: Networking basics for the beginner

Need a jump start on Unix networking? Whether you're working on your home network or setting up systems at work, here are some Unix commands and insights that might prove helpful.

By  

Even if your system is assigned an address dynamically, this doesn't mean that the address will change every time you boot it. Even DHCP addresses tends to be stable for a while. There is some likelihood that the same IP address will be assigned to a system for weeks, even months -- just no guarantee.

As I like to tell my students, clients need to be able to find servers like shoppers need to find supermarkets. Servers never need to find their clients and supermarkets don't need to find their customers. Since clients initiate the connections, they can be coming from nearly anywhere.

Examining your network interfaces

To view your network settings, you would use the ifconfig command. If you try this command and get an error that claims the command cannot be found, it is likely that /sbin is not on your search path. You can try typing /sbin/ifconfig instead or you can modify your search path and then try ifconfig again.

$ ifconfig
-bash: ifconfig: command not found
$ PATH=$PATH:/sbin
$ ifconfig
eth0      Link encap:Ethernet  HWaddr 00:16:35:69:BD:79
          inet addr:192.168.0.11  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::212:ff35:fe69:bd12/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:16791460 errors:0 dropped:0 overruns:0 frame:0
          TX packets:30066639 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:2182259898 (2.0 GiB)  TX bytes:3951206845 (3.6 GiB)
          Interrupt:209 Memory:fdef0000-fdf00000

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:32098 errors:0 dropped:0 overruns:0 frame:0
          TX packets:32098 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:3227365 (3.0 MiB)  TX bytes:3227365 (3.0 MiB)

Output like that shown above tells you a number of things. It tells you that the local network is a private network. You can tell this by the IP address shown in the second line. Any IP address that starts with 192.168 is part of a private address range. Many home networks will make use of a local router that assigns addresses like these to systems on the LAN as they boot. You can also tell, by looking at the 255.255.255.0 mask, that this network is capable of accommodating hundreds of systems, even if the router only provides eight ports. In today's typical home network, systems are likely to use wireless networking, so the number of available ports on the router isn't particularly significant.

We can also see that the network interface is operational (RUNNING), view some numbers that tell us that data is going out and coming in (RX and TX packets), and note that a second network interface is listed.

Photo Credit: 

flickr / jonjohnson

Join us:
Facebook

Twitter

Pinterest

Tumblr

LinkedIn

Google+

Operating SystemsWhite Papers & Webcasts

See more White Papers | Webcasts

Answers - Powered by ITworld

ITworld Answers helps you solve problems and share expertise. Ask a question or take a crack at answering the new questions below.

Join us:
Facebook

Twitter

Pinterest

Tumblr

LinkedIn

Google+

Ask a Question
randomness