CMSC 691X, Summer 1999
Chapter 14. TCP/IP and Routing
Set up a network
Prepared by Yiqing Ren
Introduce:
-
Plan the physical and logical structure of the network
-
Assign IP addresses
-
Install the network hardware
-
Set up each host to configure network interfaces at boot time
-
Set up routing daemons and static routes
Systems are smart todistinguish whether they are connected to a network
or not.
boot sequence very different for networked and non-networked cases.
Designing and installing a physical network will discuss in Chapter
15. Network Hardware.
This Section talk about non-hardware network setup topic:
-
IP address
-
ifconfig command
-
route command
-
routed daemon
-
gated daemon
Obtaining and Assigning Internet Addresses
-
IP addresses
-
must be unique
-
assigned by InterNIC Registration Services
-
how to get IP address
-
InterNIC guaranteed unique
-
subdivide address space assigned to you
-
subnet address
-
responsible for assigning a host number to each machine on your network.
-
Addresses are assigned to network interface, not machines.
-
if machine more than one interface, it will more than one address
-
mapping the address and machine's name into the /etc/hosts file, or DNS.
-
allow user to refer it by hostname
-
for example:
-
130.85.100.125 everest.cs.umbc.edu everest.cs everest
127.0.0.1
localhost loopback
class B address, on the 100 subnet known name as everest.cs.pdx.edu
-
disadvantage: /etc/hosts file must be replicated on every
machine.
-
Chapter 18 Sharing System Files will discuss it.
-
DNS is also a good method to manage the mapping, it allows users to refer
machines by their hostnames.
-
Chapter 16 will describe it more detail
ifconfig: configure Network Interfaces
ifconfig is used to enable or disable a network interface
or to configure network interface parameters. ifconfig
must
be used at boot time to define the network address of each interface
present on a machine; it may also be used at a later time to redefine an
interface's address or other operating parameters.
-
ifconfig command:
-
ifconfig [-v] interface | -a [family] [ dest_addr ] [ up ] [ down
] option [ netmask mask ] [ metric n ] [broadcast]
-
interface identifies the hardware interface could be find
with command netstat -i
-
Name Mtu Network
Address
Ipkts Ierrs Opkts Oerrs Coll
ec0 1500 130.85.100 everest.cs.umbc.
42385380 42 37721674 257 17000333
clifford.cs.umbc.
lo0 32992 loopback
localhost.umbc. 42676431 0 42676431
0 0
-
family argument tell which protocal layer you want to configure
with, in real life, it always deal with IP configuration, so set family
to inet
-
default value is inet for some systems, except HP-UX and
BSDI require rexplicitly value
-
address parameter
-
two format: traditional Internet dot notation
-
or hostname: discovered by looking up the name in /etc/hosts
or DNS
-
recommend the number address
-
loopback interface is ususlly called lo0, it is fictitious hardware, through
which packets bound for the local host can be routed to itself
-
ifconfig other parameter
-
-a
Apply the commands to all interfaces in the system.
-
-ad Apply the commands
to all ``down'' interfaces in the system.
-au Apply the
commands to all ``up'' interfaces in the system.
-
arp Enable the
use of the Address Resolution Protocol in mapping between
network level addresses and link level
addresses( Ethernet). This is currently implementent for mapping
between TCP/IP addresses and Ethernet addresses.
-
-arp Disable the use
of the Address Resolution Protocol.
-
auto-revarp Use the Reverse Address Resolution
Protocol (RARP) to automatically translate Ethernet
address to IP address for this interface.
-
metric n
Set the routing metric of the interface to n, default 0.
metrics 16 means infinite routing.
-
netmask mask The option sets the subnet
mask for the interface. The mask contains 1's for the
bit positions in the 32-bit address which are to be used
for the network and subnet parts, and 0's for the
host part.
A `+' (plus sign) is given for the netmask value, the mask is
looked up in the netmasks database using the interface network number as
the key.
-
broadcast addr The option sets the IP broadcast
address for the interface. The default broadcast address is the address
with a host part of all 1's.
A + (plus sign) given for the broadcast value causes the
broadcast address to be reset to a default appropriate based on netmask
and so on.
-
ifconfig -a netmask + broadcast + and
ifconfig -a broadcast + netmask +
may result in different values for
the interfaces' broadcast addresses.arguments of ifconfig are
interpreted left
to right
route: Configure Static Routes
A example of Routing tables
Internet:
Destination
Gateway
Netmask Flags
Refs Use Interface
default
130.85.100.1
UGS 19 129178
ec0
127.0.0.1
127.0.0.1
UH 10
46635 lo0
130.85.100
link#1
0xffffff00 UC
0 0
ec0
130.85.100.125 127.0.0.1
UGHS 1 1934
lo0
130.85.101
130.85.100.150 0xffffff00
UG 0
2306 ec0
224
link#1
0xf0000000 UCS
0 0
ec0
255.255.255.255 130.85.100.255
UGHS 0
0
ec0
G Gateway address. Destination requires
forwarding by intermediary
H Host entry (net otherwise)
U route is up, usable
S Manually added route
C Generate new routes on use
-
route - manually manipulate the routing tables, define static routes.
-
Routing is performed at IP layer. when a packet for other host arrived
the router
-
compare the destination IP address with the routes in the routing table
-
if IP match, forward the packet to the 'next gateway' assicated with the
route
-
if host is a directly-connected network with the route, the 'next gateway'
is the host interface, the packet is directly to its destination. ifconfig
add it when configure an interface
-
otherwise, if a default route exist, forward the packet to that gateway,
if not , the router return an ICMP back to sender
-
route command
-
example:
-
route add host 127.0.0.1 0 #for loopback
route add default 128.138.242.1 1 #
gateway
-
add Add a route.
-
flush Remove all 'gateway' routes.
-
delete Delete a specific route.
-
change Change aspects of a route (such as its gateway).
-
get Lookup
and display the route for a destination.
-
net and host The optional modifiers net
and host force the destination to be interpreted as a network
or a host.. Otherwise, if the destination has a ``local address part''
of INADDR_ANY , or if the destination is the symbolic name of a network,
then the route is assumed to be to a network; otherwise, it is presumed
to be a route to a host.
For example, 128.32 is interpreted as
-host 128.0.0.32 ;
128.32.130 is interpreted as -host 128.32.0.130;
-net
128.32 is interpreted as
128.32.0.0; ( means net )
and -net 128.32.130
is interpreted as 128.32.130.0. (
means net )
routed: The Standard Routing Daemon
routed was a standard UNIX routing daemon
-
it is simplicity
-
it is gradually replaced by gated daemon
-
routed only support RIP
-
RIP is a simple interior routing protocol.
-
every 30 seconds, routing server check the network information of routes
that it know
-
then update routing table
-
routed includes two modes
-
server mode (-s)
-
quite mode (-q)
-
both modes listen for broadcast, but only server mode distribute their
own information
-
By dafault, the (-q) quite mode run with one interface, the (-s) server
mode run with several interface
-
routed -t
-
no require configuration if no gateway to Internet or other AS ( autonomous
systems )
-
single gateway, just run routed with -g flag ( -g: global )
-
more gateways, describe them in file /etc/gateways, the routed will reference
it when starts up.
-
gateways file defines entries like route command
-
gateways file also defines gateway as active or passive
-
active gateways will be cancled if no speak RIP
-
passive gateways will still exist
gated: A better Routing Daemon
-
gated support different protocol
-
Interior Routing Protocol: RIP, OSPF
-
Exterior Routing Protocol: EGP, BGP
-
Old Protocol: HELLO
-
with gated you can use multiple protocol at same time, and gated can translate
routing metrics between them
Example Systems supported routing daemons
System
|
routed?
|
gated?
|
gated protocols
|
Solaris
|
Yes
|
No
|
|
HP-UX
|
No
|
Yes
|
HELLO, RIP, EGP, BGP
|
IRIX
|
Yes
|
Yes
|
HELLO, RIP, EGP
|
SunOS
|
Yes
|
No
|
|
OSF/1
|
Yes
|
Yes
|
HELLO, RIP, EGP
|
BSDI
|
Yes
|
Yes
|
HELLO, RIP, EGP, BGP
|
A example of configure file:
RIP yes ( yes means to be a RIP serevr mode if there is more
than one interface, otherwise a passive listener -- quite mode)
EGP no
HELLO no
defaultgateway 128.138.243.120 rip passive. This line sets the
default route for the local machine.
Boot-time Network Configuration
-
Old systems, the network was configured by editing /etc/rc and directly
changing the ifconfig and route commands.
-
The newer scripts reuse configuration information from other system files
or define they own configuration files.