Date post: | 05-Apr-2018 |
Category: |
Documents |
Upload: | dalton-marquez |
View: | 215 times |
Download: | 0 times |
of 16
7/31/2019 Introduction to Linux Networking.docx
1/16
Top of Form
Introduction to Linux NetworkingOne of the common questions I hear is "How do I network Linux to my Windows computer?".
After counting slowly to ten and taking some deep breaths, I then proceed to ask my interlocuterjust what they want to do, since the verb "to network" really doesn't mean much to me other thansales-people exchanging business cards at breakfast meetings.
You see, "networking" covers a multitude of sins. The Microsoft Windows networking
documentation tends to lump everything together and confuse the traditional TCP/IP 'socket'applications with the Microsoft Windows Networking applications, which use a NetBIOS
interface. Consequently, people tend to speak of "networking" machines without being specific
about whether they are referring to file-sharing, email, web services or other protocols. This israther like dialling a phone number and expecting to have a meaningful conversation with the fax
machine at the other end.
In the Linux world, we prefer to be quite specific about the protocols and applications we use. Let'sstart by describing the different layers of the network protocol stack:
TCP/IP is a four-layer stack, unlike the ISO/OSI seven layer stack.
The bottom layer - the physical layer - consists of the network card and associated device driver,
most often Ethernet but also Token Ring, PPP (for dial-up connections) and many others.
The next layer - the network layer - implements the Internet Protocol, which is the basis of allInternet communications, along with some related protocols such as ICMP.
Layer three - the transport layer - consists of the TCP, UDP and similar protocols. No
configuration is normally required here.
Layer four - the application layer - consists of all the various application clients and servers, suchas Samba (file & print server), Apache (web server) and many others, several of which can easily
7/31/2019 Introduction to Linux Networking.docx
2/16
justify an entire book on their basic configuration. The most important of these applications is the
Domain Name Service, which many other applications depend upon.
In this article, I'll consider configuration of the lower two layers and of DNS. The step-by-step
instructions given here rely upon the GUI configuration tools commonly provided with Linux
distributions these days, but in the main article, I'll describe the configuration files and what really
happens 'under the covers'.
Network Card Configuration
First of all, you should know the type of network card in your machine. If you have previouslyinstalled Windows on the machine, use the Windows Control Panel to identify the card and note
the IRQ and I/O port resources it uses.
Device drivers - including network card drivers - can be compiled into the kernel, but morecommonly, are provided as separate modules. These can be found in /lib/modules//kernel/drivers/net. This directory contains the bulk of Ethernet card drivers, and there
are separate subdirectories for Appletalk, Token Ring, PCMCIA, wireless and other morespecialised drivers. Generally speaking, the installation program for your Linux distribution will
almost always detect the network card and configure the system to load the appropriate driver.
You can load a driver module with the command "modprobe ". You can optionally
specify parameters such as the IRQ or IO port (generally necessary for old ISA cards), for
example:
modprobe ne irq=5 io=0x300
If you are completely in the dark about the type of network card you have, and don't want to
remove the lid and read the labels, there is still a way out. You can try to load all network card
drivers with the command
modprobe -t drivers/net *
This will try to load all network card drivers, and you may have to watch carefully to see if one
loads. Afterwards, give the lsmod command to see if your network card driver is resident in
memory. This section of lsmod output shows the 8139too driver (and the mii module, which ituses) is resident:
lockd 55296 1 (autoclean) [nfsd]sunrpc 73876 1 (autoclean) [nfsd lockd]autofs 11172 0 (autoclean) (unused)8139too 16160 1mii 2248 0 [8139too]ide-cd 30144 0 (autoclean)cdrom 31936 0 (autoclean) [ide-cd]st 28852 0 (unused)
On Red Hat and similar distributions, the module configuration is stored in the file/etc/modules.conf. Here is an extract, showing the relevant lines:
alias eth0 8139tooalias eth1 ne2k-pci
This file could also contain options statements, like the example given below for Lycoris.
7/31/2019 Introduction to Linux Networking.docx
3/16
For Lycoris Desktop/LX, the module configuration is generally handled a slightly different way:
The file /etc/modules/default contains a list of modules - including the network card drivers - to be
loaded ay boot time and the directory /etc/modules/options may contain a file for each module thatrequires command line options, one option per line.
For example, in configuring Lycoris Desktop/LX on one machine, I found that the installer had
failed to identify and configure the network card - an elderly Intel EtherExpress Pro. No problem -I know that the required driver module is called eepro.o, and that the card was configured to use
IRQ 5 and I/O port 0x300. So I simply edited the file /etc/modules/default, which lists the modules
loaded at system start-up, and added the eepro driver as the first line:
eeproide-floppysr_modide-scsisound#@@ Automatically generated driver list -- don't edit up to the next @@ - lineusb-uhciemu10k1
emu10k1-gp#@@ End of automatically generated driver listparport_lowlevel
Then I added a text file called eepro in the /etc/modules directory, and in it, I put the options for
the eepro driver module, one per line:
irq=5io=0x300
I could also have added a line in /etc/modules.conf, of the form:
options eepro irq=5 io=0x300
In fact, I could also have used an alias statement to load the eepro module, just like in Red Hat.
Whichever technique your system uses, once you have the correct network card driver modulesloaded, you can turn your attention to configuring the next layer of the protocol stack.
IP Configuration
While Linux can support a variety of network protocols, such as Novell Netware IPX and
Appletalk protocols, the vast majority of systems use TCP/IP. IP configuration will require you to
know the IP address of the machine being configured, the netmask for the network it is on, and the
default route or gateway which leads to the outside world. You should also know the hostname ofyour machine, as well as the domain it is part of (note that DNS domains have little or nothing to
do with Windows NT domains). For example, the machine I am typing this on is called "freya",
and it is in the "cullen.lesbell.com.au" domain. Concatenate these two (with an additional dot), andyou get the fully-qualified domain name (FQDN) of the machine: "freya.cullen.lesbell.com.au".
You will generally also need to know the IP address of one or more domain name servers (DNS's)
- either your own, on your network, or perhaps those supplied by your ISP.
Setting the IP Address, Netmask and Default Route
As you probably know, UNIX/Linux systems are configured by a hierarchy of scripts when theystart up, and these scripts use other, short, scripts to set the values of variables as they run. Each
7/31/2019 Introduction to Linux Networking.docx
4/16
interface is configured by a file in /etc/sysconfig/network-scripts - for example, the eth0 interface
is configured by the file "ifcfg-eth0", while a wireless card interface might be configured by
/etc/sysconfig/network-scripts/ifcfg-wlan0. Here's an example:
DEVICE=eth0BOOTPROTO=staticBROADCAST=192.168.168.255IPADDR=192.168.168.8NETMASK=255.255.255.0NETWORK=192.168.168.0ONBOOT=yes
You can edit this file as required to change any of these options, or you can use a GUI if youprefer. (On Red Hat 8.0, use the command "redhat-config-network" while on Red Hat 7.3 and
earlier, use "netconfig").
The hostname is set from the file /etc/sysconfig/network. Here's an example:
NETWORKING=yesGATEWAY=192.168.168.252
GATEWAYDEV=""HOSTNAME=asgard.cullen.lesbell.com.au
The default gateway can be set by a "GATEWAY=" statement in either /etc/sysconfig/networkor /etc/sysconfig/network-scripts/ifcfg-ifname - in the latter case, each interface can have a specific
default route that applies if the interface is up, but not if it is down.
Here's the /etc/sysconfig/network script from a Lycoris Desktop/LX system:
NETWORKING=yesHOSTNAME=baldur.cullen.lesbell.com.auIF_LIST='lo eth tr sl ppp'
while here's the /etc/sysconfig/network-scripts/ifcfg-eth0 file:
#!/bin/sh#>>>Device type: ethernet#>>>Variable declarations:DEVICE=eth0IPADDR=192.168.168.10NETMASK=255.255.255.0NETWORK=192.168.168.0BROADCAST=192.168.168.255GATEWAY=192.168.168.252ONBOOT=yes#>>>End variable declarationsBASIC=no
In both cases, you can see it is very similar to a Red Hat system.
Configuring DNS
DNS configuration is also done similarly under the covers. The first point is that, for simple cases,
you don't need a DNS at all. If you just have a few machines in a SoHo network, you can enter
their IP addresses, FQDN's and hostnames (or aliases) into the file /etc/hosts:
# Do not remove the following line, or various programs# that require network functionality will fail.
7/31/2019 Introduction to Linux Networking.docx
5/16
127.0.0.1 localhost.localdomain localhost192.168.168.8 asgard.cullen.lesbell.com.au asgard192.168.168.10 baldur.cullen.lesbell.com.au baldur
Each line consists of an IP address, the fully qualified domain name of the corrseponding machine,
and the hostname or alias, with the first two lines referring to the local machine itself. You can add
as many machines into this file as you like, but before too long, maintaining the hosts file on all ofthem becomes a pain and at that point, setting up a DNS starts to seem worth the effort.
Even if you don't have your own DNS, you will certainly want to refer to your ISP's DNS, so thatyou can refer to outside hosts by name, rather than IP address. I dread to think what would happen
if you were forced to remember 203.18.241.23, rather than www.pcuser.com.au.
The file that sets up the DNS client (technically called the resolver) on your machine is/etc/resolv.conf. It will contain one or more nameserver entries, which specify the IP addresses of
the domain name servers you will use for lookups, and either a domain entry or a search entry. A
domain entry just names the domain that this machine is in, while a search entry can specify a list
of domains to be searched whenever you specify just a hostname and not a FQDN. For example,
with this setup in /etc/resolv.conf:search cullen.lesbell.com.au lesbell.com.aunameserver 192.168.168.1nameserver 192.168.168.252
I can sit at freya.cullen.lesbell.com.au, point my browser to "http :// www" and have it find
www.lesbell.com.au (after it figures out there's no www.cullen.lesbell.com.au, that is). And if the
nameserver on 192.168.168.1 doesn't respond, after a timeout my machine will fall back to using192.168.168.252.
There you have it - once the basics of the underlying TCP/IP networking are set up, it makes it alot easier to configure the services - like email, web server, etc, - that sit on top.
Step By Step:Network Configuration for Lycoris Desktop/LX
Step 1: Configure the network interface:
http://www/http://www/http://www/http://www/7/31/2019 Introduction to Linux Networking.docx
6/16
Open the Control Center, navigate to "Internet and Network" and click on "Network Interfaces".
You will need to supply the root pasword when prompted. Check that the interface you want to
configure appears in the list - if it doesn't refer to the main article and attempt to load and configurethe correct driver module. If your network has a DHCP server, then simply click on "Dynamic
Addresses with DHCP"; otherwise, select "Manual" and fill in the IP address of this host, the
netmask of the network, and the IP address of the default gateway. The "Broadcast" address fieldshould be auto-completed, based on the values you enter for the IP address and netmask. Check
that the interface is enabled, the default route is enabled, and save your work.
Step 2. Configure the hostname:
7/31/2019 Introduction to Linux Networking.docx
7/16
Click on "Hostname and DNS", and ensure the "General" tab has been selected. IF required, enter
the hostname in the first field, and then the domain in the "default domain" field. If you are not part
of a registered domain, I suggest concocting a name in the ".pvt" top-level domain, as this doesn'texist and can't cause any clashes. If you are not running NIS (and I bet you're not) you should
move "NIS/YP" to the bottom of the "services" list.
Step 3. Configure DNS:
7/31/2019 Introduction to Linux Networking.docx
8/16
Click on the DNS tab. For each DNS, either on your corporate network or supplied by your ISP,
enter it into the "Name Servers" field and press "Save". You can adjust the order in which the
DNS's will be consulted with the up and down arrow buttons. If you want to search any otherdomains (this can save you having to type anything other than the basic hostnames), then add them
in the "Search Domains" list in the same way.
Step 4. Configure the hosts file:
7/31/2019 Introduction to Linux Networking.docx
9/16
Finally, if you have any other local machines which you want to access by name, but you don't
have a DNS, then click on the "Hosts" tab and enter them, clicking on "Save" for each one. Then
click on "OK".
Network Configuration for Red Hat 8.0
Step 1. Configure the network:
7/31/2019 Introduction to Linux Networking.docx
10/16
Click on the red hat, "System Settings", "Network", then type in the root password. In the
"Network Configuration" dialog, you will see a list of interfaces. Select the one that you want toconfigure, and click on "Edit...", or to add one, click on "Add..."
Step 2. If adding a device, select the device type:
7/31/2019 Introduction to Linux Networking.docx
11/16
As you can see, Red Hat 8.0 supports a huge variety of types of network connections. If you areinstalling a wireless card, you might know that they mostly appear under "Ethernet Adapters", but
you should choose "Wireless Connection" so that you have the opportunity to set the SSID,
Channel, WEP key, etc.
Step 3. If adding a device, specify the type:
7/31/2019 Introduction to Linux Networking.docx
12/16
You should also specify the name of the device, along with any resources, if these are not auto-detected.
Step 4. If editing the interface, configure the interface:
7/31/2019 Introduction to Linux Networking.docx
13/16
Either select DHCP or static configuration. For the latter, enter the IP address, subnet mask and
default gateway address. Make sure that "Activate device when computer starts" is checked, and
click on "OK".
Step 5. Configure the hosts file:
7/31/2019 Introduction to Linux Networking.docx
14/16
If you have other local machines which you want to access by name, but you don't have a local
DNS, then click on the "Hosts" tab and enter them by clicking on "Add..." for each one, filling inthe IP address and hostname, along with any short-form aliases, and clicking on "OK".
Step 6. Configure the hostname and DNS lookups:
7/31/2019 Introduction to Linux Networking.docx
15/16
Click on the "DNS" tab, and enter the local machine's hostname, then enter the IP address of each
DNS, either those on your corporate network or those supplied by your ISP. You can also add anyother domains you want to be searched at this point. Finally, click on "Close" to save your work.
References and Further Reading
For more information on wireless networking with Linux, clickhere.
For more information on debugging network configuration problems, clickhere.
Tech Terms:
IP Address: IP V4 addresses are 32 bits in length, and are usually written in "dotted quad"
notation: each of the four bytes is written down in decimal, with dots between them, such as
207.46.249.27 or 129.42.19.99. On an intranet, we often use "private internet addresses", which
often start with 192.168. - for example, 192.168.0.254.Subnet Mask: Part of any address represents a network, and part identifies a specific host (actually,
an interface) on that network. The question is, which part is the network, and which part is thehost? This question is answered by the Subnet Mask: written out in binary, it consists of 1's for
those positions which are part of the network address, and 0's for those positions that are part of the
host address. For example:
11111111111111111111111100000000
http://www.lesbell.com.au/Home.nsf/b8ec57204f60dfcb4a2568c60014ed0f/4ad6e47c5fd8e44dca256e39002567c5?OpenDocumenthttp://www.lesbell.com.au/Home.nsf/b8ec57204f60dfcb4a2568c60014ed0f/ac6983ac71a95aebca256f3800170b4f?OpenDocumenthttp://www.lesbell.com.au/Home.nsf/b8ec57204f60dfcb4a2568c60014ed0f/ac6983ac71a95aebca256f3800170b4f?OpenDocumenthttp://www.lesbell.com.au/Home.nsf/b8ec57204f60dfcb4a2568c60014ed0f/4ad6e47c5fd8e44dca256e39002567c5?OpenDocumenthttp://www.lesbell.com.au/Home.nsf/b8ec57204f60dfcb4a2568c60014ed0f/ac6983ac71a95aebca256f3800170b4f?OpenDocument7/31/2019 Introduction to Linux Networking.docx
16/16
which means that the first three bytes identify the network, and the last byte identifies the host.
This could more easily be written in dotted quad notation as "255.255.255.0". Since modern
Internet addressing requires that subnet masks have to consist of a contiguous string of one'sfollowed by a contiguous string of zeros, the shortest way to write a network address together with
the associated subnet mask is as the IP address of the network, a slash and the number of ones in
the subnet mask - for example, 192.168.0.0/24.Default Router (or Default Gateway): In IP routing, each host and router needs to know the IP
address of at least one gateway on the same network which can forward datagrams to distant
destinations. In the simplest and commonest case, there is only one gateway leading out of anetwork, and so all the hosts on that network forward outgoing datagrams to that default gateway,
which takes care of things from there.
Domain Name Server (DNS): A domain name server is a software service or daemon whichmaintains a directory of host names and IP addresses. Given a hostname, it can supply the IP
address - rather like looking up a telephone directory - but it can also do the reverse, converting IP
addresses into hostnames. If a DNS does not know the answer to a query, it can usually consultother DNS's until gets an answer. Most corporate networks have one or more DNS's, while home
users generally consult their Internet Service Provider's DNS's.
Hostname: The name of a machine. For example: "frodo", "wookie", etc.
Fully-Qualified Domain Name: The globally unique name of a machine in a specific domain. For
example: "frodo.rivendell.middle-earth.net", "wookie.millenium-falcon.com".
If you have found this information valuable, please consider donating to the Red Cross
appeal for the victims of the Christchurch earthquake, by clicking here:
http :// www .redcross .org .nz /donate
Page last updated: 04/Jan/2005 Back to Home Copyright 1987-2010 Les Bell and Associates Pty Ltd. All rights
reserved. webmaster @ lesbell .com .au
...........................Bottom of Form
http://www.lesbell.com.au/mailto:[email protected]://www.lesbell.com.au/http://www.lesbell.com.au/http://www.lesbell.com.au/mailto:[email protected]:[email protected]:[email protected]:[email protected]:[email protected]:[email protected]:[email protected]