27 – Networking and the Internet
December 5, 2009 – 10:17 pmPlease note… This information no longer exists at the referenced locations. This is only a copy of what was available in 2003.
Basic Linux Training™
Networking and the Internet
Henry White
Table of Contents
This can be a confusing topic, so take your time with this lesson. Everything you need to make your connection to the Internet is in the HOWTOs and mini-HOWTOS, but almost all the information will be new to the hypothetical ‘average’ DOS/Windows user, so it’s easy to misinterpret. The presentation here is simply to clarify and elaborate what is in those documents and in your textbook.
Quite frankly, this and X are the two ‘dragons’ for many users – new and well-seasoned veterans alike. Getting ppp and X to work on someone else’s machine is really what qualifies you for ‘instant hero’ status
- read the documentation before you start or you might be in over your head real fast
- keep a written record of what you’re doing, and I mean down to each keystroke – especially when you’re dealing with ppp and X, the simplest typo is all it takes to frustrate your efforts – and they’re often hard to spot, because you subconsciously correct the typo knowing what you intended; so often a second, more objective set of eyes will spot these right away (all the more reason to take advantage of the mailing list and IRC sessions)
If you’ve got your connection through Linux working, you still need to read this lesson – hopefully you will be able to get enough background information to help others who are close but not quite there yet. And with the capabilities of Linux, you may want to set up a LAN at home with some of those cast-offs unusable with the latest versions of Windows. (A couple of free machines, NIC cards, and cables and you’re ready for less than US$100!)
Networking with TCP/IP
The current implementation of TCP/IP and related protocols for Linux is called “NET-3″, which also supports SLIP (Serial Line Internet Protocol) and PPP (Point-to-Point Protocol) allowing you to have dialup Internet access using a modem over a standard telephone line. (See Net-HOWTO for all the details. A related document, Ethernet HOWTO, describes configuration of various Ethernet card drivers for Linux; obviously, you won’t need this if you do not have an ethernet card.)
TCP/IP is a suite of protocols which defines how machines should communicate with each other over a network – as well as internally with other layers of the protocol suite. To work, this mean TCP/IP is independent of platform and operating system.
On a TCP/IP network, each machine is assigned an IP address which is a 32-bit number to identify each machine. The IP address can be defined as a hexadecimal value (which is what the machine uses) although you will generally see it in decimal notation as a dotted quad (i.e., a series of four groups of numbers (0 through 255) separated by dots or periods).
Using my ISP (verizon.net) as an example (206.124.65.253), the IP address is divided into 2 parts:
- the network address – 206.124.65
- the host address – 253
(In addition, each host may be subdivided into a subnetwork address. A large company, for example, might have thousands of machines connected together in departmental subnets where each subnet is maintained independently. I mention that in passing only; as a user you don’t have to understand all these intricacies. Still one of the best (and free) sources for the essentials is the Network Administrator’s Guide that is part of the Linux Documentation Project.)
Processes communicating through TCP/IP generally specify the destination machine’s IP address as well as a port address which is a 16-bit number that specifies a particular service or application (such as ssh or ftp) on the destination machine.
Every device that connects to the Internet must have its own, unique IP number. These are assigned centrally by a designated authority for each country. Due to the increased number of machines on the Internet, a dynamic scheme has been developed for dialup connections that provides an IP on the fly to your machine when it first establishes connection. This means that you will have a different IP address every time you connect to the remote PPP dialup service. This is the most common method for most (not all) ISPs.
The other method is to use a static IP, which is almost exclusively for machines connected directly to the Internet, although some ISPs do assign static IP addresses to ADSL accounts.
Your Network Configuration
The following information applies primarily to Ethernet connections. If you’re planning to use SLIP or PPP, read this section to understand the concepts, and follow the more specific instructions in the HOWTOs that deal with SLIP and PPP.
First, it is assumed that you have a Linux system that has the basic clients installed such as telnet and ftp, system administration commands such as ifconfig and route (usually found in /etc), and networking configuration files (such as /etc/hosts). The other Linux-related networking documents described above explain how to go about installing the Linux networking software.
It is also assumed that your kernel has been configured and compiled with TCP/IP support enabled. To enable networking, you must answer yes to the appropriate questions during the make config step, and rebuild the kernel, or add this as a module (if your existing kernel has that extremely handy feature enabled).
Almost all the distributions ship with ppp support in the boot kernel, so you probably can run the precompiled kernel without rebuilding. However, what confuses many people when they do rebuild their kernel is that ppp is turned off in the default kernel configuration, so watch out for that.
Once this has been done, you must modify a number of configuration files used by NET-3. For the most part this is a simple procedure. Unfortunately, however, there is wide disagreement between Linux distributions as to where the various TCP/IP configuration files and support programs should go. Most of the time, they can be found in /etc, but in other cases they may be found in /usr/etc, /usr/etc/inet, or other ‘bizarre’ locations. In the worst case, you’ll have to use the find command to locate the files on your system. Also note that not all distributions keep the NET-3 configuration files and software in the same location–they may be spread across several directories.
Before you can configure TCP/IP, you need to determine the following information about your network setup. In most cases, your local network administrator can provide you with this information.
- IP address: This is the unique machine address in dotted-decimal format. An example is 206.124.65.253. Your network admins will provide you with this number.If you’re only configuring loopback mode (i.e. no SLIP, no Ethernet card, just TCP/IP connections to your own machine) then your IP address is 127.0.0.1.
- Network mask (netmask): This is a dotted quad, similar to the IP address, which determines which portion of the IP address specifies the subnetwork number, and which portion specifies the host on that subnet. (If you’re shaky on these TCP/IP networking terms, I suggest reading some introductory material on network administration. The network mask is a pattern of bits, which when overlayed onto an address on your network, will tell you which subnet that address lives on. This is very important for routing, and if you find, for example, that you can happily talk to people outside your network, but not to some people within your network, there is a good chance that you have an incorrect mask specified.Your network administrators will have chosen the netmask when the network was designed, and therefore they should be able to supply you with the correct mask to use. Most networks are class C subnetworks which use 255.255.255.0 as their netmask. Class B networks use 255.255.0.0. The NET-3 code will automatically select a mask that assumes no subnetting as a default if you do not specify one.
This applies as well to the loopback port. Since the loopback port’s address is always 127.0.0.1, the netmask for this port is always 255.0.0.0. You can either specify this explicitly or rely on the default mask.
- Network address: This is your IP address masked bitwise-ANDed the netmask. For example, if your netmask is 255.255.255.0, and your IP address is 206.124.65.253, your network address is 206.124.65.0. With a netmask of 255.255.0.0, this would be 206.124.0.0.If you’re only using loopback, you don’t have a network address.
- Broadcast address: The broadcast address is used to broadcast packets to every machine on your subnet. Therefore, if the host number of machines on your subnet is given by the last byte of the IP address (netmask 255.255.255.0), your broadcast address will be your network address with 0.0.0.255.For example, if your IP address is 206.124.65.253, and your netmask is 255.255.255.0, your broadcast address is 206.124.65.255.
Note that for historical reasons, some networks are setup to use the network address as the broadcast address, if you have any doubt, check with your network administrators. (In many cases, it will suffice to duplicate the network configuration of other machines on your subnet, substituting your own IP address, of course.)
If you’re only using loopback, you don’t have a broadcast address.
- Gateway address: This is the address of the machine which is your gateway to the outside world (i.e. machines not on your subnet). In many cases the gateway machine has an IP address identical to yours but with a “.1” as its host address; e.g., if your IP address is 206.124.65.253, your gateway might be 206.124.65.1. Your network admins will provide you with the IP address of your gateway.In fact, you may have multiple gateways. A gateway is simply a machine that lives on two different networks (has IP addresses on different subnets), and routes packets between them. Many networks have a single gateway to “the outside world” (the network directly adjacent to your own), but in some cases you will have multiple gateways–one for each adjacent network.
If you’re only using loopback, you don’t have a gateway address. The same is true if your network is isolated from all others.
- Name server address: Most machines on the net have a name server which translates host names into IP addresses for them. Your network admins will tell you the address of your name server. You can also run a server on your own machine by running named, in which case the name server address is 127.0.0.1. Unless you absolutely must run your own name server, I suggest using the one provided to you on the network (if any). Configuration of named is another issue altogether; your priority at this point is to get you talking to the network. You can deal with name resolution issues later.If you’re only using loopback, you don’t have a name server address.
Your IP address is usually determined in one of two ways:
- (a) you have a static IP address, which is the same every time you connect to the network, or
- (b) you have a dynamic IP address, which is allocated from a pool of available addresses when you connect to the server.
NET-3 supports full routing, multiple routes, subnetworking (at this stage on byte boundaries only), the whole nine yards. The above describes most basic TCP/IP configurations. Yours may be quite different: when in doubt, consult your local network gurus and check out the man pages for route and ifconfig. Configuring TCP/IP networks is very much beyond the scope of this lesson; the above should be enough to get most people started.
The Networking rc Files
rc files are systemwide configuration scripts executed at boot time by init, which start up all of the basic system daemons (such as sendmail, cron, etc.) and configure things such as the network parameters, system host name, and so on. rc files are usually found in the directory /etc/rc.d but on some systems may be in /etc. In general Slackware distributions use the files rc.inet1, etc. in /etc/rc.d whereas the RedHat distributions use a series of directories.
Here, I’m going to describe the rc files used to configure TCP/IP. There are two of them:
- rc.inet1 – used to configure the basic network parameters (such as IP addresses and routing information); and
- rc.inet2 – fires up the TCP/IP daemons (telnetd, ftpd, and so forth).
Many systems combine these two files into one, usually called rc.inet or rc.net. The names given to your rc files doesn’t matter, as long as they perform the correct functions and are executed at boot time by init. To ensure this, you may need to edit /etc/inittab and uncomment lines to execute the appropriate rc file(s). In the worst case you will have to create the rc.inet1 and rc.inet2 files from scratch and add entries for them to /etc/inittab. (Almost always this has been been taken care of during the initial installation. Just be aware of what is going on, and where the files are located.)
rc.inet1 configures the basic network interface. This includes your IP and network address, and the routing table information for your network. The routing tables are used to route outgoing (and incoming) network datagrams to other machines. On most simple configurations, you have three routes:
- One for sending packets to your own machine,
- another for sending packets to other machines on your network, and
- another for sending packets to machines outside of your network (through the gateway machine).
Two programs are used to configure these parameters: ifconfig and route. Both of these are usually found in /etc.
ifconfig is used for configuring the network device interface with the parameters that it requires to function, such as the IP address, network mask, broadcast address and the like. route is used to create and modify entries in the routing table.
For most configurations, an rc.inet1 file that looks like the following should work. You will, of course, have to edit this for your own system. Do not use the sample IP and network addresses listed here for your own system; they correspond to an actual machine on the Internet.
rc.inet2 starts up various servers used by the TCP/IP suite. The most important of these is inetd. inetd sits in the background and listens to various network ports. When a machine tries to make a connection to a certain port (for example, the incoming telnet port), inetd forks off a copy of the appropriate daemon for that port (in the case of the telnet port, inetd starts in.telnetd). This is simpler than running many separate, standalone daemons (e.g., individual copies of telnetd, ftpd, and so forth)–inetd starts up the daemons only when they are needed.
Syslogd is the system logging daemon–it accumulates log messages from various applications and stores them into log files based on the configuration information in /etc/syslogd.conf. routed is a server used to maintain dynamic routing information. When your system attempts to send packets to another network, it may require additional routing table entries in order to do so. routed takes care of manipulating the routing table without the need for user intervention.
When attempting to setup TCP/IP on your system, it’s usually best to start with a minimal configuration and add more complex pieces (such as NFS) when you have things working.
Among the various additional servers that you may want to start in rc.inet2 is named. named is a name server–it is responsible for translating (local) IP addresses to names, and vice versa. If you don’t have a name server elsewhere on the network, or want to provide local machine names to other machines in your domain, it may be necessary to run named. (For most configurations it is not necessary, however.) Named configuration is somewhat complex and requires planning.
The /etc/hosts file
/etc/hosts contains a list of IP addresses and the host names that they correspond to. In general, /etc/hosts only contains entries for your local machine, and perhaps other important machines (such as your name server or gateway). Your local name server will provide address-to-name mappings for other machines on the network, transparently.
If you’re only using loopback, the only line in /etc/hosts should be for 127.0.0.1, with both localhost and your host name after it.
The /etc/networks file
/etc/networks file lists the names and addresses of your own, and other, networks. It is used by the route command, and allows you to specify a network by name, should you so desire.
Every network you wish to add a route to using the route command (generally called from rc.inet1) must have an entry in /etc/networks.
The /etc/host.conf file
This file is used to specify how your system will resolve host names.
The /etc/resolv.conf file
This file configures the name resolver, specifying the address of your name server (if any) and your domain name. Your domain name is your fully-qualified host name (if you’re a registered machine on the Internet, for example), with the host name chopped off. For example,
- home1.gte.net – the fully qualified host name
- gte.net – domain name
You can specify more than one name server–each must have a nameserver line of its own in resolv.conf.
You should set your system host name with the hostname command. This is usually called from /etc/rc or /etc/rc.local; simply search your system rc files to determine where it is invoked.
Note that the hostname executable may not be found in /bin on your system.
You can use the netstat command to display your routing tables; this is usually the source of the most trouble. The netstat man page describes the exact syntax of this command in detail. In order to test network connectivity, use a client such as telnet to connect to machines both on your local subnetwork and external networks. This will help to narrow down the source of the problem. (For example, if you’re unable to connect to local machines, but can connect to machines on other networks, more than likely there is a problem with your netmask and routing table configuration). You can also invoke the route command directly (as root) to play with the entries in your routing table. (You can also test network connectivity by specifying IP addresses directly, instead of host names. If that works, then you know your basic network setup is (more than likely) correct, and the problem lies in your specification of the name server address.)
Assignments
Define and add these to your glossary:
Utilities & Commands
- Netscape
- archie
- finger
- ftp
- gopher
- pine
- ping
- rcp
- rcpinfo
- rlogin
- rsh
- rwho
- talk
- telnet
- xftp
- xgopher
Files & Directories
- /etc/hosts
- /etc/resolv.conf
Terms & Concepts
- 100BaseT
- 10Base2
- 10BaseT
- BIND
- DNS
- Ethernet
- FDDI
- IP address
- ISO
- Internet
- NFS
- NIS
- NNTP
- PPP
- SLIP
- TCP/IP
- USENET
- UUCP
- W3C
- bot
- broadcast
- client/server
- daemons
- dataless
- diskless
- dotted quad
- fully qualified domain
- gateway
- hostname
- hypermedia
- hypertext
- intranet
- links
- local area network (LAN)
- localhost
- packet
- parallel port
- point-to-point
- protocol
- resolver
- router
- search engine
- sendmail
- serial line
- spider
- thinnet
- token ring
- token
- transfer rate
- web crawler
- wide area network (WAN)
- world wide web
Online: (optional)
- http://www.tldp.org/HOWTO/Networking-Overview-HOWTO.html – Linux Networking Overview HOWTO
- http://www.tldp.org/HOWTO/Net-HOWTO/index.html – Net-HOWTO
- http://www.tldp.org/HOWTO/mini/Home-Network-mini-HOWTO.html – Home Network mini-HOWTO
- http://www.linas.org/ – Linas VEPSTAS Home Page
It is highly recommended that you use a version of the Linux kernel and the appropriate PPP version that are known to be stable together.
As mentioned previously, roughly half of the LDP HOWTOs and mini-HOWTOs are related to networking.
For your PPP connection you should also read:
- the documentation that comes with the PPP package;
- the pppd and chat man pages; (use man chat and man pppd to explore these)
- the Linux Network Administration Guide (NAG) (also available in an older version in paperback from O’Reilly and Associates);
- Linux kernel documentation installed in /usr/src/linux/Documentation when you install the Linux source code;
- The excellent Unix/Linux books published by O’Reilly and Associates (http://www.ora.com/) and Addison-Wesley & Benjamin Cummings (http://www.aw.com).
- The PPP-FAQ maintained by Al Longyear, available from (ftp://metalab.unc.edu/pub/Linux/docs/faqs. This contains a great deal of useful information in question/answer format that is very useful when working out why PPP is not working (properly).
Copyright © 1997-2003 Henry White. All Rights Reserved.
Reproduction or redistribution without prior written consent is strictly prohibited. Address comments and inquiries to info@basiclinux.net.
Sorry, comments for this entry are closed at this time.