Things you need to set up a network in UNIX

Or

Important Commands and Definitions

The ifconfig command is used to set up a network interface.
The eth0 interface is the first ethernet card detected.  The second is eth1 and so on.
The interface lo is the loopback interface, and will be used to talk to yourself.
Note these interfaces do NOT show up in /dev.
The route command can be used to tell the kernel which interface to send packets out, given a particular target IP number.
The netstat command will tell you the status of any network connections.
The ping command will attempt to contact a host an receive a reply.  This will test basic network connectivity.
The ifconfig command with no options will also offer some network status information, as will /proc/net/*.
The nslookup command will translate between IP numbers and hostnames.  The  dig command will tell you more but the answer is harder to read.  Dig is considered more modern.
The hostname command checks and sets your host's name.
The special name localhost with IP number 127.0.0.1 refers to your current computer.
DHCP is a way of configuring your network card automatically by searching for and downloading from a dhcp server.  With DHCP everything is much easier.  When possible chose DHCP.
The tcpdump command lets you see traffic as it goes past your computer's network card.

Setting up the Ethernet Card Device Driver

Maybe the kernel already has detected the ethernet card.  If so, you should see output similar to below when the kernel boots up.  Alternatively, you can check the boot up messages with the command 'dmesg' or the file /var/log/messages.
NE*000 ethercard probe at 0x300: 00 c0 f0 27 3f 8d
eth0: NE2000 found at 0x300, using IRQ 3
Check to see if the card has a working device driver.  use the command 'ifconfig eth0 up' If you get no error, the card is working.  If you get an error, you probably need to recompile the kernel.  You can first try and insert the module by hand.  For an ne-2000 card you might do  'insmod 8320.o; insmod ne.0 irq=3 port=0x300' for various values of 'irq' and 'port'.  One way to guess the resources used by the network card is to cat /proc/ioports and /proc/interrupts.  Any resources used by something else is probably not used by the network card, and can therefore be eliminated from consideration.  Another is to put the card into a Windows machine, and let windows autodetect it.

If there is a resource conflict you need to resolve it.  Older cards can be changed by dip switches.  Newer cards need a utility, normally available only under Windows.

Some cards can be autodeteced by Linux, like the Intel EtherPro 100.  If you're a sysadmin buying new hardware, buy one of these.

When your done with the step, the blinky lights should blink.

Using DHCP

Using DHCP is the easiest and best way of setting up networking.  To use DHCP there must be a DHCP server on your local network.  NMU has such a server.
To set up dhcp, you must have the ethenet card working.   After that, just edit the /etc/sysconfig/network-scripts/ifcfg-eth0 to include the proto line as shown below.
DEVICE="eth0"
ONBOOT="yes"
IPADDR="198.110.193.9"
NETMASK="255.255.255.0"
BOOTPROTO="dhcp"

Setting up the Ethernet Card Address

To set up the ethernet card you will need to know your netmask.  Your netmask is used to tell if a given IP address is on the given network.  You netmask is dependent on the class of your network.  A Class C network has a netmask of 255.255.255.0, a Class B network has a netmask of 255.255.0.0.  Custom subnets have different netmasks.

You can then configure your card by hand with a command like
ifconfig eth0 netmask 255.255.255.0 198.110.193.101 up

You can make these settings permenant by editing /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0
IPADDR=198.110.193.9
NETMASK=255.255.255.0
NETWORK=198.110.193.0
BROADCAST=198.110.193.255
ONBOOT=yes

Checking Ethernet Card Status

You can check the ethernet card at this point to make sure it's working by restarting the network and then trying to ping a machine GIVEN ITS IP NUMBER and ASSUMING ITS ON THE LOCAL NET.  Other functionality is not yet set up.  Try a command like
   /etc/rc.d/init.d/network restart
ping 198.110.193.9

If everything is fine, move on.  If not, there are several possibilities.

Configuring a Gateway

You can check gateway configuration with the 'route' command.  You can add a gateway by hand with the 'route add command, like this.
route add default gw 198.110.193.3

Check the correctness of this by pinging some host BY IP NUMBER that is NOT on the same network.  A suggestion is 204.71.200.68.  It should succeed.

Make the changes permanent by editing the script /etc/sysconfig/network.

NETWORKING=yes
FORWARD_IPV4=false
HOSTNAME=localhost.localdomain
GATEWAY=198.110.193.3
GATEWAYDEV=eth0
This might fail for several reasons.

Getting Your Own Hostname

If you use DHCP then this is automatically done for you.  You can skip the rest of this section.

If you have a fixed IP number then there are two steps to this.  Giving yourself a name and telling the world of the name.

Edit your hostname by changing the file /etc/HOSTNAME, and then typing 'hostname --file /etc/HOSTNAME'.  Example, 'googee.nmu.edu'.  Note that you give the full name, including domain portion.  Please understand that setting your hostname in /etc/HOSTNAME does NOT effect anyone except yourself.  It doesn't change the name the outside world uses to reach you.

You tell others your name by adding yourself to someone else's DNS database.  That's done by your network administrator.

Configuring the Domain Name Service

There are two mechanisms to translate hostnames to IP numbers.  They are the DNS system the the file /etc/hosts. 
search acs.nmu.edu nmu.edu
nameserver 198.110.193.10
You can check DNS by pinging some host by NAME, which should work.  Another good test is to type nslookup www.yahoo.com.
You can check others know your name by typing 'nslookup myname.org'.  If your not running a server, then it does not matter if this is correct or not.

The /etc/hosts Database

The file /etc/hosts contains a list of hosts known to your computer.  There are several reasons you might or might not put a host in this database.  In general hosts are NOT listed there, even commonly used hosts.  Normally only the 'localhost' is listed.

Reasons to list

Reasons not to
The file /etc/hosts -- a bad example
127.0.0.1                          localhost.localdomain localhost googee.nmu.edu googee
# Map all references from Yahoo to Excite
198.3.98.99                     www.yahoo.com yahoo
# Map the word excite to www.excite.com
198.3.98.99                      www.excite.com excite