Tuesday, December 8, 2009

unix networking

You need to know all the steps needed to configure IP addresses on a NIC card. Web site shopping cart applications frequently need an additional IP address dedicated to them. You also might need to add a secondary NIC interface to your server to handle data backups. Last but not least, you might just want to play around with the server to test your skills.
This section shows you how to do the most common server IP activities with the least amount of headaches.

Determining Your IP Address

Most modern PCs come with an Ethernet port. When Linux is installed, this device is called eth0. You can determine the IP address of this device with the ifconfig command.

[root@bigboy tmp]# ifconfig -a
 
eth0 Link encap:Ethernet HWaddr 00:08:C7:10:74:A8
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Interrupt:11 Base address:0x1820
 
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:787 errors:0 dropped:0 overruns:0 frame:0
TX packets:787 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:82644 (80.7 Kb) TX bytes:82644 (80.7 Kb)
 
wlan0 Link encap:Ethernet HWaddr 00:06:25:09:6A:B5
inet addr:192.168.1.100 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:47379 errors:0 dropped:0 overruns:0 frame:0
TX packets:107900 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:4676853 (4.4 Mb) TX bytes:43209032 (41.2 Mb)
Interrupt:11 Memory:c887a000-c887b000
 
wlan0:0 Link encap:Ethernet HWaddr 00:06:25:09:6A:B5
inet addr:192.168.1.99 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:11 Memory:c887a000-c887b000
[root@bigboy tmp]#

In this example, eth0 has no IP address because this box is using wireless interface wlan0 as its main NIC. Interface wlan0 has an IP address of 192.168.1.100 and a subnet mask of 255.255.255.0
You can see that this command gives good information on the interrupts, or PCI bus ID, used by each card. On very rare occasions you might find that your NIC card doesn't work because it shares both an interrupt and memory access address with some other device. You can look at the contents of the /proc/interrupts file to get a listing of all the interrupt IRQs used by your system. In the example below we can see that there are no conflicts with each IRQ from 0 to 15 having only a single entry. Devices eth0 and eth1 use interrupts 10 and 5, respectively:

[root@bigboy tmp]# cat /proc/interrupts
             CPU0
   0:  2707402473          XT-PIC  timer
   1:          67          XT-PIC  i8042
   2:           0          XT-PIC  cascade
   5:      411342          XT-PIC  eth1
   8:           1          XT-PIC  rtc
  10:     1898752          XT-PIC  eth0
  11:           0          XT-PIC  uhci_hcd
  12:          58          XT-PIC  i8042
  14:     5075806          XT-PIC  ide0
  15:         506          XT-PIC  ide1
NMI:           0
ERR:          43
[root@bigboy tmp]#
If there are conflicts, you might need to refer to the manual for the offending device to try to determine ways to either use another interrupt or memory I/O location.

Changing Your IP Address

If you wanted, you could give this eth0 interface an IP address using the ifconfig command.

[root@bigboy tmp]# ifconfig eth0 10.0.0.1 netmask 255.255.255.0 up
The "up" at the end of the command activates the interface. To make this permanent each time you boot up you'll have to add this command in your /etc/rc.local file which is run at the end of every reboot.
Fedora Linux also makes life a little easier with interface configuration files located in the /etc/sysconfig/network-scripts directory. Interface eth0 has a file called ifcfg-eth0, eth1 uses ifcfg-eth1, and so on. You can place your IP address information in these files, which are then used to auto-configure your NICs when Linux boots. See Figure 3-1 for two samples of interface eth0. One assumes the interface has a fixed IP address, and the other assumes it requires an IP address assignment using DHCP.

unix

UNIX was originally developed circa 1969 in AT&T Bell Labs. Key developers: Dennis Richie and Ken Thompson.

Development was coupled to the invention of the C programming language, which allowed UNIX to be semi-portable to different hardware. (11,000 lines of portable C and 1000 lines of machine dependent assembler in those early days)

As discussed below, UNIX includes a kernel and a number of small components and utilities built to work with the kernel.

Circa 1974 the source was made available to selected Universities, including the U of T and especially Berkeley. This led to different "flavors" of UNIX. The code remained property of AT&T and the Universities signed non-disclosure agreements.

In about 1979 various commericial vendors began to adopt UNIX under license from AT&T. The number of flavors increased (System V, BSD, HP-UX, Solaris, IRIX, etc.).

In 1984 Richard Stallman drove the beginnings of the Open Source movement with the foundation of GNU. (GNU stands for "Gnu is Not Unix."). Later this became the Free Software Foundation. They began introduce open source products to work under UNIX.
m
One of their first and biggest successes was developing a C compiler, gcc, that was superior to any commercially available ones.

Virtually all of the proprietary utilities, shells, etc. that are associated with UNIX have now been re-written by GNU as Open Source.

In 1991 21 year old Linus Torvalds wanted to buy a UNIX for his own computer but couldn't afford it. So he began writing a UNIX-like operating system called Linux. He made it Open Source.

With the Linux kernel and all of the GNU utilities available as Open Source, the GNU/Linux computing environment is at least as rich and powerful as the proprietary UNIX one.

Below we will occasionally refer to "UNIX/Linux," implying that UNIX and Linux are synonyms. From the standpoint of a user this is largely true. We should more properly refer to "UNIX-GNU/Linux" to give proper credit to GNU for their important role in the Linux computing environment.



Under the terms of the GPL, any person may obtain and change the code covered under the license, but must make those changes available at no charge to the world.
m
The terms of the license means, for example, that a commercial vendor of GNU/Linux, such as Red Hat, must make their distribution available at no charge.