by Guido Socher
About the author:
Guido is a long time Linux fan. All his computers in the house are integrated into a network.
Networking becomes more and more popular. Your old 486 can perfectly work as file-server or run IP-Masquerading to give the whole family Internet access from different computers at the same time. This article will provide you with the basic overview to start a home network. It will explain the vocabulary which you need to understand literature and other articles on networking. The focus of the article is a small scale home network.
|Pin||Name||Description for 10baseT|
|Note:||TX & RX are
swapped on Hub's.
Note: you need special pliers to connect the RJ-45 connector to the cable.
The mapping between the pins on the RJ-45 connector and the Twisted Pair wires is standardized. There are several standards and they use slightly different colors. Valid pin assignments are:
|Wire pair number||Connector pins||standard 1||standard 2||standard 3||standard 4|
Cabling is really only relevant if you want to run 20 or more meters of cable through the whole house. If you want to connect just a few computers in the same room then you can get cheap ready made cables with connectors. These are typically available with a length between 1 and 10 meters.
|Pin No||Pin No|
|1 connected||to 3|
|2 connected||to 6|
|3 connected||to 1|
|4 connected||to 5 (100baseT4)|
|5 connected||to 4 (100baseT4)|
|6 connected||to 2|
|7 connected||to 8 (100baseT4)|
|8 connected||to 7 (100baseT4)|
|9 connected||to 9 (100baseT4)|
My personal experience is that the cheapest cards are the best.
The more expensive ones do usually not give you any additional
features. ISA PNP cards may cause trouble. Most cards which are
sold as ISA PNP cards come with a DOS floppy disk and software
where you can change the flash ROM settings of that card and
configure it to not use PNP. You can set a fixed interrupt and IO address.
(Note: if you have
a PNP bios then you must also tell it to disable PNP for this interrupt).
The standard IO address is normally io=0x300. You can see which
address and interrupts are already used by typing:
cat /proc/interrupts /proc/ioports | more
(Note: These are the interrupts and addresses which are really used by a driver at the moment.)
If you bought such an ISA PNP card then you will probably find that the DOS floppy disk is not of much use for a Linux only user. You or a friend might have an old boot-able dos floppy somewhere. Copy the program that came with the network card to that floppy. Boot from it and change the setting of the network card. The settings are stored in flash Rom so, you just do this once after you installed the hardware and then never again.
The cheapest cards are usually NE2000 cards and cost today about
$15 (or 15 Euro). These are well supported
under Linux. NE2000 cards are available as ISA or PCI bus cards.
The ISA bus cards need the kernel modules "ne" and "8390". You can either let the driver probe for it or provide IRQ and IO at the command line. Loading of kernel module without auto-probing can be done as follows:
insmod ne irq=10 io=0x300
With a PCI card you don't usually have any trouble with interrupts and IO addresses but they are a bit more expensive. The kernel modules for the NE2000 PCI cards are called ne2k-pci and 8390.
> /sbin/ifconfig -a lo Link encap:Local Loopback inet addr:127.0.0.1 Bcast:127.255.255.255 Mask:255.0.0.0 UP BROADCAST LOOPBACK RUNNING MTU:3584 Metric:1 RX packets:1664 errors:0 dropped:0 overruns:0 TX packets:1664 errors:0 dropped:0 overruns:0 eth0 Link encap:10Mbps Ethernet HWaddr 00:80:AD:71:52:19 inet addr:10.0.0.1 Bcast:10.255.255.255 Mask:255.0.0.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:5993 errors:0 dropped:0 overruns:0 TX packets:4073 errors:0 dropped:0 overruns:0 Interrupt:5 Base address:0x300 dummy0 Link encap:10Mbps Ethernet HWaddr 00:00:00:00:00:00 inet addr:10.0.0.1 Bcast:10.255.255.255 Mask:255.0.0.0 UP BROADCAST RUNNING NOARP MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 TX packets:0 errors:0 dropped:0 overruns:0 ppp0 Link encap:Point-Point Protocol inet addr:18.104.22.168 P-t-P:22.214.171.124 Mask:255.255.255.0 UP POINTOPOINT RUNNING MTU:552 Metric:1 RX packets:7 errors:0 dropped:0 overruns:0 TX packets:8 errors:0 dropped:0 overruns:0As you can see there are 4 network interfaces in the above example.
Parallel port IP is a possibility to use the parallel port as network interface. The kernel configuration parameter is called CONFIG_PLIP and you should preferably configure it as module. PLIP is a cheap possibility to connect your Laptap to another computer and via this computer to your home network. You need to buy a parallel port cable with 2 male connectors also known as LapLink cable. If you want to build the cable your self then the wiring is:
You need to decide which addresses to use for your network. Normally you will get one IP addresses assigned form your Internet service provider when you "go online". This IP addresses is more or less automatically assigned to the ppp interface. You do normally not have to worry about it. What you need to decide now is what addresses to assign to the other interfaces of your private network (e.g eth0 and plip1 interface). A number of addresses are reserved for private use. This addresses are not routed in the Internet and can not cause you any trouble when you re-use them. Their ranges are:
|255.0.0.0||10.0.0.0 - 10.255.255.255|
|255.255.0.0||172.16.0.0 - 172.31.255.255|
|255.255.255.0||192.168.0.0 - 192.168.255.255|
Most distributions come these days with pretty graphical user interfaces (GUIs) to configure networking (e.g yast or netcfg). You can use them if you want. Refer to the user manual of your Linux distribution on how to use them. This article shall not focus on a specific distribution. It explains therefore the underlying configuration files that will somehow magically be modified if you use the GUIs from your distribution. This gives you also the possibility to verify what the configuration GUIs did.
For a small home network it does not make much sense to have DNS server running. Instead you can just enter the names of the machines in a file called /etc/hosts Example:
# ipaddr. fullname alias 127.0.0.1 localhost 192.168.0.1 obelix.mynet obelix 192.168.0.2 asterix.mynet asterix 192.168.0.3 idefix.mynet idefixTogether with the file /etc/hosts goes a file called /etc/host.conf where you say how to resolve names. You should use the following in this file:
# /etc/host.conf order hosts bind # Allow multiple addrs multi on
The file /etc/resolv.conf says where to resolve anything that can not be found in /etc/hosts. You need to ask your ISP for the ip address of his DNS server. You should enter more than one DNS server if possible. If the first DNS server is slow or down then the next will be asked. The syntax is:
#/etc/resolv.conf #nameserver ipaddr. nameserver 123.456.789.1 # alternative DNS server: nameserver 123.456.111.9
/etc/HOSTNAME or (/etc/sysconfig/network for redhat) is a file where many distributions configure
the name of the local machine. But in reality the host name of a machine
is set via the command hostname. What happens in these distributions
is that during startup (e.g /etc/rc.d/rc.sysinit) the file /etc/HOSTNAME
is read and then its content is feed to the command hostname.
Which file is exactly used depends really on the peculiarities of your
specific installation. It should however now be easy for you
to investigate this since you know that you should grep for hostname.
Example how to set the hostname:
/etc/hosts.allow this is a configuration file for a security
system called tcp wrapper.
All you need to know, is that you should
add the ip-addresses of all the machines in your local network, excluding
the machine where this file is located, behind the keyword ALL:.
Example: obelix has 2 network interfaces that go to other hosts in your local net. The interface with the ip address 192.168.0.2 goes to asterix and the interface with the ip address 192.168.0.3 goes to idefix. In this case you write:
# hosts.allow # See tcpd(8) and hosts_access(5) for a description ALL: 192.168.0.2 192.168.0.3If you run a NFS server on obelix then you need also to add the line
portmap: 192.168.0.2 192.168.0.3Network File System (NFS) gives you the possibility to access files on other host as if they were locally on the disk.
/etc/hosts.deny is also for the tcp wrapper it should never be changed and should always look as follows:
portmap: ALL ALL: ALL
/etc/hosts.equiv allows local users to log into other machines (e.g with rsh) without password. You may decide if you want this. The syntax is: On full name (as in /etc/hosts) of a trusted host per line. E.g
The /etc/hosts.lpd file is important if you would like to enable network printing services via lpd. How to configure network printing is another story but this file must be present on the machine where you run the lp-daemon and it must list the names of all the machines that are allowed to print. The syntax is the same as hosts.equiv. The network printer configuration it self is best done with the system admin tools from your distribution (e.g yast in suse and printtool in redhat). The Printing-HOWTO from the Linux Documenation project describes how to set it up if you do not want to use the system admin tools from your distribution.
The file /etc/service.switch is used by sendmail. On the hosts inside your network (the ones that do not have a direct Internet connection) you write:
hosts files aliases filesYou configure then your sendmail on these hosts to forward all mail to the machine that has the modem and you use this one as a mailhost.
Sendmail reads at startup a configuration file called /etc/sendmail.cf and this file is quite difficult to read. The sendmail sources use therefore a macro language called m4 to generate the sendmail.cf out of a macro file. To do this you need the m4 macro processor (probably already installed on your system) and a part of the sendmail sources. Redhat Linux installs also these sources to /usr/lib/sendmail-cf other distributions may not come with it but you can always unpack the sendmail sources. Documentation on how the sendmail configuration works can be obtained from www.sendmail.org.
A central mail host is called mail-hub. The idea is that all the different machines in your network forward just their mail to this hub and the hub stores the mail. You then access it via NFS or pop/imap. A m4 file to do exactly that looks as follows:
#divert(-1) include(`../m4/cf.m4') VERSIONID(`mc file for asterix, A HOST INSIDE THE PRIVATE NETWORK') undefine(`UUCP_RELAY') undefine(`BITNET_RELAY') OSTYPE(`linux') # put here your outside mail domain. E.g if your user id is # joe and your mail address email@example.com then you write: MASQUERADE_AS(linuxnet.somewhere.org) # Do not show these internal hostnames to the outside world: MASQUERADE_DOMAIN(asterix.mynet) MASQUERADE_DOMAIN(asterix) MASQUERADE_DOMAIN(localdomain) MASQUERADE_DOMAIN(localhost) FEATURE(masquerade_envelope) #the /etc/passwd entry: mail:*:8:12:mail:/var/spool/mail: define(`confDEF_USER_ID',``8:12'') # the centail mail hub is obelix, Note dot at the end define(`MAIL_HUB', `obelix.mynet.')dnl define(`confHOSTS_FILE',/etc/hosts)dnl MAILER(smtp)dnl MAILER(local)dnlTo generate the sendmail.cf file form the above sendmail.mc file you go into the cf directory of the sources (redhat /usr/lib/sendmail-cf/cf) and put the sendmail.mc there. Then you run m4 sendmail.mc > /etc/sendmail.cf
Please note: to just get networking running you will not need sendmail at all and you can send and receive mail with netscape without bothering about sendmail. Sendmail is probably something for the more advances Linux users.
A bit more difficult is the configuration of your mailhost. It must deliver local mail and forward external mail. External mail can e.g be forwarded via smtp (Simple Mail Transfer Protocol) in which case you should read the sendmail documentation ( www.sendmail.org) about "define(`SMART_HOST', smtp:provider.mail.host)dnl". For outgoing mail via smtp you need also on your mailhost computer a /etc/service.switch that enables DNS lookup:
hosts files dns aliases filesYou can also use UUCP and other methods. It really depends on what your Internet provider offers.
IP Masquerading is the Linux term and most other people call it Network Address Translation. This is a very valuable thing for a small home network. It gives you the possibility to access the Internet from any of your local machines although only one machine is known in the Internet. This one machine is probably connected via modem/PPP and has a valid Internet wide routed ip-address assigned dynamically (or statically) to its ppp0 interface. With IP-Masquerading several people on different computers in your home network can access the Internet at the same time. LinuxFocus will have a separate article on how to setup IP-Masquerading. I recommend also reading the howto on IP-Masquerade. For the moment I will just explain how it works in principle.
To understand how IP-Masquerade works you must understand how a TCP
connection is set up. When you connect to a host on the Internet with
your web-browser then you connect to the ip address of that machine and
the web server application. The application (e.g a web server) is selected
by something called port number. The port numbers are pre-defined.
Port 80 is the port number for the web server application. Thus if you
type www.linuxfocus.org in your netscape then it knows that it must
connect to the IP address 126.96.36.199 (= www.linuxfocus.org) and port 80.
For a full tcp connection where data can be send and received, pairs of IP address and port numbers are needed. That is 188.8.131.52 and 80 plus your own ip address and a local port number to which the web server can reply. The local port number is usually allocated at random. E.g:
www at www.linuxfocus.org: your.machine.at.your.isp: IP=184.108.40.206 Port=80 ----- IP=123.123.456.1 Port=4123If you start a second netscape window and setup an other connection to www.linuxfocus.org then a new local port number is choosen:
www at www.linuxfocus.org: your.machine.at.your.isp: IP=220.127.116.11 Port=80 ----- IP=123.123.456.1 Port=4123 IP=18.104.22.168 Port=80 ----- IP=123.123.456.1 Port=4541 Note: twice port 80 is not correct but we just say so to make the example simpler.When a TCP packet comes back from the web server then it knows to which netscape window to go because of the difference in the port number on your machine. In the case of a private network behind your.machine.at.your.isp the situation is:
www at www.linuxfocus.org --- your.machine.at.your.isp --- privatehost1.mynet | +- privatehost2.mynetNone of the IP addresses of interfaces from privatehost1.mynet are known in the Internet. Therefore it is impossible to send an IP-packet from the Internet back to privatehost1.mynet. No router in the Internet would know where to send it to. However your.machine.at.your.isp has an IP addresses which is known in the Internet and as we saw above, different connections can be told apart by their port-numbers.
Problems with interrupts are not specific to networking. They can occur anytime you add new hardware to your computer. Unfortunately the PC hardware does only allow for 16 interrupts and most of them are already in use. It is possible to share interrupts between two PCI cards at the expense of some CPU power. It is not possible to share interrupts between ISA bus cards. If you have a PNP Bios and insert a ISA bus card with fixed IRQ into your computer then you must first go into the BIOS setup and reserve that IRQ otherwise the BIOS may try to assign the IRQ to other hardware and that will not work.
Under Linux you can see how often certain hardware has already generated an interrupt by using the command cat /proc/interrupts. Hardware which is not used will not generate any interrupts.
The following is a list of the pre-defined IRQs. You can only use them for other purposes if you do not use the hardware component assigned to it. E.g if you use SCSI drives instead of IDE then you can use IRQ 14/15 for other things.
|2||cascade (programmable IRQ controller)|
|5||free, usually sound card|
|7||parallel port, but under linux printers will not generate any iterrrupt|
|8||real time clock|
|12||ps2 mouse (/dev/psaux)|
After so much theory I would like to discuss a little example network with you. Why do people build home networks? Here some ideas:
|192.168.0.1||eth0 on Workstation 1|
|192.168.0.2||eth0 on Workstation 2|
>ping 192.168.0.2 PING 192.168.0.2 (192.168.0.2): 56 data bytes 64 bytes from 192.168.0.2: icmp_seq=0 ttl=64 time=0.9 ms 64 bytes from 192.168.0.2: icmp_seq=1 ttl=64 time=0.8 ms 64 bytes from 192.168.0.2: icmp_seq=2 ttl=64 time=0.9 ms --- ping statistics --- 3 packets transmitted, 3 packets received, 0% packet loss round-trip min/avg/max = 0.8/0.8/0.9 msYou stop this with crtl-c. Take also a look at the command cat /proc/interrupts where you should see your network card or PLIP in the case of the Laptop connection. A cat /proc/ioports should show your new hardware and the command netstat -i shows how many IP packets were sent to which interface.
Basically your network is there but nothing really cool works. Now you must edit the different configuration files (use also the nice graphical tools that are available with the various distributions). Finally you setup IP-Maskerade and NFS. Now your network is fully functional.
I hope that this gave you a good overview. Don't be disappointed if I did not
tell you exactly how to really configure the software part. There will be
separate articles covering ifconfig/route/netstat, IP-Maskerade, PPP setup,
network printing with lpd
and NFS. This article was supposed to give a good overview to make it easier
to understand other articles on networking.
ps: LinuxFocus is always happy to receive articles on networking. Not all articles are written yet and this is just the start of a series. Let us know if you are an experienced user and would like to write an article.
Webpages maintained by the LinuxFocus Editor team
© Guido Socher, FDL
Click here to report a fault or send a comment to LinuxFocus
2001-01-27, generated by lfparser version 2.8