Download Module 12 - SaigonTech

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

IEEE 1355 wikipedia , lookup

Internet protocol suite wikipedia , lookup

AppleTalk wikipedia , lookup

Deep packet inspection wikipedia , lookup

Distributed firewall wikipedia , lookup

Piggybacking (Internet access) wikipedia , lookup

Computer network wikipedia , lookup

Recursive InterNetwork Architecture (RINA) wikipedia , lookup

Wake-on-LAN wikipedia , lookup

Network tap wikipedia , lookup

List of wireless community networks by region wikipedia , lookup

Airborne Networking wikipedia , lookup

Cracking of wireless networks wikipedia , lookup

Zero-configuration networking wikipedia , lookup

Transcript
Module 12
Introduction to UNIX
Networking
UNIX Operating System I
Objectives
•
•
•
•
•
•
Identify basic networking concepts,
including how a network works.
Identify the purpose and characteristics
of network services configuration files
Edit basic network services
configuration files
Configure basic network settings.
Run and interpret ifconfig.
Use network diagnostic tools
UNIX Operating System I
Basic Functions of Network Hardware
•
•
Network hardware is designed to
allow two or more computers to
communicate with one another.
Most networks rely upon wires or
cables to transmit data between
machines as electrical impulses, but
some devices use radio waves or
even light to do the job.
UNIX Operating System I
Types of Network Hardware
•
Ethernet
– Ethernet is the most common type of network
hardware on local networks today.
– It comes in several varieties ranging from the
old 10Base-2 and 10Base-5 to 10Base-T and
100Base-T to the cuttingedge 1000Base-T and
1000Base-SX.
– In all these cases, the number preceding the
“Base” indicates the technology’s speed in
megabits per second (Mbps).
– Plans are underway to develop another ten-fold
speed increase.
UNIX Operating System I
Types of Network Hardware
•
Token Ring
– At one time an important competitor to
Ethernet, IBM’s Token Ring technology
is rapidly falling behind.
– The fastest type of Token Ring clocks in
at just 16Mbps.
– Just as important, it’s costlier than
Ethernet and has less in the way of
hardware support.
UNIX Operating System I
Types of Network Hardware
•
FDDI
– Fiber Distributed Data Interface (FDDI)
is a networking technology that’s
comparable to 100Base-T Ethernet in
speed.
– FDDI uses fiber optic cables, but a
variant known as CDDI works over
copper cables similar to those of
100Base-T.
UNIX Operating System I
Network Packets
•
Modern networks operate on discrete
chunks of data known as packets.
– Suppose you want to send a 100KB file from
one computer to another.
– Rather than send the file in one burst of data,
you break it down into smaller chunks.
– You might send 100 packets of 1KB each.
– This way, if there’s an error sending one packet,
you can resend just that one packet, rather than
the entire file.
UNIX Operating System I
Network Packets
•
•
Typically, each packet includes an
envelope, which includes the sender
address, the recipient address; and a
payload, which is the data intended for
transmission.
When the recipient system receives
packets, it must hold onto them and
reassemble them in the correct order to recreate the complete data stream.
UNIX Operating System I
Network Protocol Stacks
•
•
The packing and unpacking of
network data is frequently described
in terms of a protocol stack.
Understanding how the pieces of
such a stack fit together can help you
understand networking as a whole,
including the various network
protocols used by Linux.
UNIX Operating System I
What Is a Protocol Stack?
•
A protocol stack is a set of software that
converts and encapsulates data between
layers of abstraction.
– For instance, the stack can take the commands
of e-mail transfer protocols, and the e-mail
messages that are transferred, and package
them into packets.
– Another layer of the stack can take these
packets and repackage them into Ethernet
frames.
UNIX Operating System I
The OSI Model
•
•
•
A common model used for describing
protocol stacks generically is the
Open System Interconnection (OSI)
model.
This model breaks networking tasks
down into seven layers, from the
Application layer to the Physical layer.
Each layer in between these does
some task related to the packaging of
data for transport or its unpacking.
UNIX Operating System I
The OSI Model
UNIX Operating System I
TCP/IP vs OSI Model
UNIX Operating System I
Basic Network Terminology
•
•
•
•
•
•
•
Hub
Switch
Full-duplex
Half-duplex
Bridge
Router
Gateway
UNIX Operating System I
Bridge
•
Bridge
– a network device that connects two or more
networks at the Data Link layer.
– Forwards frames from one network to another.
UNIX Operating System I
Router
•
Router
– a network device that connects two or more networks at
the Network layer.
– A router forwards packets between networks making
decisions about what network should receive each
packet.
UNIX Operating System I
Gateway
•
Gateway
– a network device that does some data conversion at layers higher than
the Network layer.
– Gateways are often used to provide connection between different
applications or different network layers.
– The picture below shows a gateway that provides for the secure
connection of two networks using an insecure network:
UNIX Operating System I
Types of Network Addresses
•
•
Hardware Addresses
IP Addresses
– IP address
– Broadcast address
– network mask (subnet mask or netmask)
UNIX Operating System I
Network Ports
•
Contacting a specific computer is important, but
one additional type of addressing is still left: The
sender must have an address for a specific
program on the remote system.
– For instance, suppose you’re using a Web browser.
– The Web server computer may be running more servers
than just a Web server - it might also be running an email server or an FTP server.
•
•
Another number beyond the IP address allows you
to address traffic to a specific program.
This number is a network port number, and every
program that accesses a TCP/IP network does so
through one or more ports.
UNIX Operating System I
Basic Network Configuration
•
Clients and Servers
– one important distinction is the one
between clients and servers.
– A client is a program that initiates a
network connection to exchange data.
– A server listens for such connections
and responds to them.
UNIX Operating System I
DHCP Configuration
•
•
•
One of the easiest ways to configure a
computer to use a TCP/IP network is to use
the Dynamic Host Configuration Protocol
(DHCP).
There are three DHCP clients in common
use on Linux: pump, dhclient, and dhcpcd.
Red Hat Linux sets this option in a file
called /etc/sysconfig/network-scripts/ifcfgeth0
– If the BOOTPROTO variable is set to
BOOTPROTO="dhcp"
– the system will use DHCP.
UNIX Operating System I
Static IP Address Configuration
•
•
If a network lacks a DHCP server, you must
provide basic network configuration options
manually.
There are several specific items that are
required:
– IP address
• The IPADDR item in /etc/sysconfig/networkscripts/ifcfg-eth0 contains the IP address.
– Network mask
• The NETMASK item in /etc/sysconfig/networkscripts/ifcfg-eth0 contains the network mask.
UNIX Operating System I
Static IP Address Configuration
•
There are several specific items that are
required (continue):
– Gateway address
• You can manually set the gateway via the route
command, or
• set it in /etc/sysconfig/network-scripts/ifcfg-eth0 (the
GATEWAY item) or /etc/sysconfig/network (also the
GATEWAY item).
– DNS settings
• In order for Linux to use DNS to translate between IP
addresses and hostnames, you need to specify at
least one DNS server in the /etc/resolv.conf file.
• Use the keyword nameserver in the /etc/resolv.conf
file
nameserver IPADDRESS_OF_DNS
UNIX Operating System I
Other Network Configuration Files
•
•
•
/etc/hosts
/etc/host.conf
/etc/sysconfig/network
UNIX Operating System I
the ifconfig program
•
To view interface configuration, issue
the following command:
# ifconfig or $ ifconfig eth0
UNIX Operating System I
the ifconfig program
•
Basic use of ifconfig to bring up a network
interface:
# ifconfig interface up addr netmask mask
– For instance, the following command brings up
eth0 (the first Ethernet card) using the address
192.168.100.18 and the netmask
255.255.255.0:
# ifconfig eth0 up 192.168.100.18 netmask
255.255.255.0
– This command links the specified IP address to
the card so that the computer will respond to
the address and claim to be that address when
sending data.
UNIX Operating System I
the ifconfig program
•
After executed the ifconfig program, use
ifconfig eth0 to view the interface
configuration
UNIX Operating System I
Routing
•
To see your routing table, you might
use the route program:
# route
UNIX Operating System I
Set Default Gateway
•
To set up a route for traffic beyond
your current network. For that, you
need to use the route command:
# route add default gw
192.168.100.254
UNIX Operating System I
Set Default Gateway
•
•
•
This shows that data destined for 192.168.100.0 (that is, any
computer with an IP address between 192.168.100.1 and
192.168.100.254) goes directly over eth0.
The 127.0.0.0 network is a special interface that “loops back” to the
originating computer. Linux uses this for some internal networking
purposes.
The last line shows the default route - everything that doesn’t match
any other entry in the routing table.
– This line specifies the default route’s gateway system as
192.168.100.254.
– If it’s missing or misconfigured, some or all traffic destined for external
networks, such as the Internet, won’t make it beyond your local network
segment.
UNIX Operating System I
Network Diagnostic Tools
•
•
Network configuration is a complex topic,
and unfortunately, things don’t always work
as planned.
Fortunately, there are a few commands you
can use to help diagnose a problem.
– ping
– netstat
– route
UNIX Operating System I
ping
•
•
•
•
ping is the simplest network diagnostic tool.
This command sends a simple packet to the system (via IP address
or hostname) and waits for a reply.
In Linux, ping continues sending packets once every second or so
until you interrupt it with a Ctrl+C keystroke.
Here’s an example of its output:
UNIX Operating System I
netstat
•
netstat is a multi-network tools because it can be used in
place of several others, depending upon the parameters
it is passed. It can also return information that’s not
easily obtained in other ways.
–
–
–
–
•
•
Interface information
Routing information
Program use
Open ports
netstat is a very powerful tool, and its options and output
aren’t entirely consistent from one distribution to another.
You may want to peruse its man page and experiment
with it to learn what it can do.
UNIX Operating System I
netstat – Interface information
•
Pass netstat the --interface or -i
parameter to obtain information on
your network interfaces similar to
what ifconfig returns.
[root@redhat9 root]# netstat -i
Kernel Interface table
Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0 1500 0
113
0
0
0
75
0
0
0 BMRU
lo
16436 0
18
0
0
0
18
0
0
0 LRU
UNIX Operating System I
netstat – Routing information
•
You can use the --route or -r parameter to
obtain a routing table listing similar to what
the route command displays.
UNIX Operating System I
netstat – Program use
•
•
Some versions of netstat support the --program or –p
parameters, which attempt to provide information on
the programs that are using network connections.
This attempt isn’t always successful, but it often is, so
you can see what programs are making outside
connections.
UNIX Operating System I
netstat – Open ports
•
When used with various other parameters,
or without any parameters at all, netstat
returns information on open ports and the
systems to which they connect.
UNIX Operating System I