networking and printing
Transcript of networking and printing
-
8/14/2019 networking and printing
1/15
10/29/20
Networking
Net212
How would we network Linux?
TCP/IP is one option
What is TCP/IP and what are some ways to connectcomputers with it?
-
8/14/2019 networking and printing
2/15
10/29/20
TCP/IP (Transport Control Protocol)
Each computer has a phone number, (otherwise knownas an Internet Protocol (IP) Address )
Pc A reaches pc B by specifying its IP address
10.1.1.1 10.1.1.2
____ ____
| pc A| | pc B |
------ -------
I want to talk to 10.1.1.2 (pc B)
TCP/IP
Pc B finds sends to Pc A by specifying its address
10.1.1.1 10.1.1.2
____ ____
| pc A| | pc B |
------ -------
I want to talk to 10.1.1.1 (pc A)
What are some important addresses in
TCP/IP?
-
8/14/2019 networking and printing
3/15
10/29/20
Important TCP/IP addresses
Host address (IP address ofPc A and Pc B)
Subnet mask
Gateway DNS (Domain Name Service)
IP Addresses
Broken down into four octets (8 bits each)
Pc As IP 10.1.1.1
. . .
The values go from 0 255 for each octet.
Subnet masks
How do we get them?
-
8/14/2019 networking and printing
4/15
10/29/20
Classful networking
Look at the first octet to determine the subnet mask.
Class A 1 126 255.0.0.0Class B 127 191 255.255.0.0
Class C 192 - 223 255.255.255.0
What are the subnet masks for these?
10.1.1.1
10.1.1.2
192.168.0.1
168.1.92.100
Subnet mask examples
10.1.1.1 255.0.0.0
10.1.1.2 255.0.0.0
192.168.0.1 255.255.255.0
168.1.92.100 255.255.0.0
Why are subnet masks important?
-
8/14/2019 networking and printing
5/15
10/29/20
Importance of subnet masks
They divide an IP address into two parts: host andnetwork
Example: What is the host id and network id of 10.1.1.1?
Network ID -> 10
Host ID -> 1.1.1
How did I get that? Use Bitwise operations or just compare the subnet mask with the IP address
Class A: Network ID is first octet; Host ID is last three
10.1.1.1 255.0.0.0
/ \
10 1.1.1
Class B: Network ID is first two octets; Host ID is last two
169.1.67.10 255.255.0.0
/ \
169.1 67.10
Class C: Network ID is the first three octets; Host ID is last one
192.168.0.1 255.255.255.0
/ \
192.168.0 1
Bitwise ANDTo get the network ID use bitwise AND
Example: 10.1.1.1 255.0.0.0
1) Convert IP address to binary 00001010.00000001.00000001.00000001
11111111.00000000.00000000.00000000
3) Compare the numbers in the same column If you have 0 and 0, it is 0
If you have 0 and 1, it is 0
If you have 1 and 1, it is 1
00001010.00000000.00000000.00000000
4) Convert the result to decimal 10.0.0.0
-
8/14/2019 networking and printing
6/15
10/29/20
Bitwise XOR (Exclusive OR)Use XOR to get the Host ID
Example: 10.1.1.1 255.0.0.0
1) Convert IP address to binary 00001010.00000001.00000001.00000001
2) Convert Subnet mask to binary 11111111.00000000.00000000.00000000
3) Compare the numbers in the same column If you have 0 and 0 , it is 0
If you have 0 and 1 (subnet mask is 1), it is 0; otherwise it is 1
If you have 1 and 1 , it is 0
00001010.00000000.00000000.00000000
4) Convert the result to decimal 0.1.1.1
What is a gateway?
Allows you communicate with other networks! Gateways perform routing operations
Pc A and Pc B can communicate because they are on the samenetwork.
10.1.1.1 10.1.1.2
____ ____
| pc A| | pc B |
------ -------
Network = 10.0.0.0
Gateway example
PC A wants to communicate with PC C, but its on anothernetwork 11.0.0.0
10.1.1.1 10.1.1.2 ____ ____
| pc A| | pc B |------ -------| -------> |GW| 10.1.1.254
----- |____ || pc C | < ----------- 11.5.5.10
-
8/14/2019 networking and printing
7/15
10/29/20
What about DNS?
We like to avoid IP addresses when possible.
DNS maps names to IP addresses
We specify names instead of an IP
Examples:
PcA 10.1.1.1
PcB 10.1.1.2
PcC 11.5.5.10
GW 10.1.1.254
netstat
Program to see information about your network
netstat r(view routing table for Pc A)
10.0.0.0 10.1.1.254 255.0.0.0 U 0 0 0 eth0
TCP/IP portsPorts are like phone extensions on your computer.
In order to reach a certain application, you specify its extension (port)
Common port numbers:
FTP 20,21
SSH 22
Telnet 23
SMTP 25
DNS 53
TFTP 69
HTTP 80
POP3 110
IMAP3 220
-
8/14/2019 networking and printing
8/15
10/29/20
/etc/services
Check out your port mappings
less /etc/services
#service-name port/protocol aliases
ssh 22/tcp
ssh 22/udp
telnet 23/tcp
telnet 23/udp
Ports example
PC A wants to ssh to PC B, so it dials Bs extension
It also has to have a extension in the process
ssh 10.1.1.2
10.1.1.1 10.1.1.2
____ ____ PC A port = 32771
| pc A| | pc B | PC B port = 22
------ -------
ssh 32771 sshd 22
More on ports
They are the way applications communicate togetherover the network
Each server and client has a port
Client ports with each use , but server ports are always thesame
-
8/14/2019 networking and printing
9/15
10/29/20
See your active ports!
netstat ap | less
Proto Recv-Q Send-Q Local Address Foreign Address StatePID/Program Name
tcp 0 0 *.ssh *:* LISTEN 1809/sshd
tcp 0 0 pcb:ssh pca:filenet-rmi ESTABLISHED 2274/1
/sbin/ifconfig
Use this program to list information about your networkadapter
It can also configure it
/sbin/ifconfig print info about network adapters
eth0 Link encap: ethernet Hwaddr 00:20:78:07:6C:DD
inet addr: 10.1.1.1 Bcast:10.255.255.255 Mask:255.0.0.0
.
Configuring eth0
eth0 is your first network adapter (and probably youronly one)
Set up PC A 10.1.1.1 255.0.0.0
/sbin/ifconfig eth0 10.1.1.1 netmask 255.0.0.0
Syntax:
ifconfig interface ip_address netmasksubnet_mask
-
8/14/2019 networking and printing
10/15
-
8/14/2019 networking and printing
11/15
10/29/20
Printing
Linux uses a printing daemon called CUPS (CommonUnix Printing System)
It responds to a number of utilities configuration files The configuration files are in /etc/cups
/etc/printcap file with the name of your queues
How to printUse the lpr command; stands for line print
lprthe_file
lpr myfile
Wil l acce t i es
ls l | lpr
Specify another queue
lpr Pqueue the_file
lpr Php4000 myfile
See a queues status
See the status of all queueslpstat a
epson360 accepting requests since Jan 01 00:00
See the status of files sent to the default queue
lpqepson360 is ready and printing
Rank Owner Job File(s) Total Size
1ststudent 440 (stdin) 1000 bytes
2nd root 441 myfile 1021 bytes
See whether a queue is down/usr/sbin/lpc status your_queue_here
-
8/14/2019 networking and printing
12/15
10/29/20
Removing jobs
Remove all jobs
lprm
Remove jobs for a user
lprm user_name
lprm student
Root can delete anyones job. A regular account can onlydelete his/her own jobs
How the printing works
Printing is controlled by cupsd
Only root can print to the printer device file (/dev/lp0)directly, so everyone uses cups system.
1) rint to using pror p anot er printingprogram)
2) If you using printer features set up the job using CUPScalls
3) CUPS receives the job and stores it in /var/spool/cups
4) If the job is not text it processed through a filter, so the
printer can understand it
Postscript and PPDs
Usually print jobs are postscript files, which are giganticprograms that tell the printer how to print a file
They are generated for each non-plaintext print file
PPD (postscript printer definition) files describe theprinters features, so a CUPS-aware application can takeadvantage of them
Non-postscript printers can be printed to as well, sinceghostscript helps CUPS convert postscript into theprinters native language.
-
8/14/2019 networking and printing
13/15
10/29/20
Printer definitions
The default driver database is pretty extensive.
You can extend it by updating CUPS from these packages:
Foomatic
GIMP Print
ESP Print Pro
NFS (Network File System) Sharing
Like SMB (server message block) on Windows
It is a file sharing subsystem specified by SunMicrosystems and standardized by IEEE
Allows you to use files on remote machines as if theywere local.
NFS Servers
It is a file server that exports folders from its localfilesystem to the outside
An adminstrator configures folders to shares (exports)inside /etc/exports
10.1.1.1 10.1.1.2
____ ____
| pc A| | pc B | NFS Client: mounting /exports/data
------ -------
NFS Server: exporting /exports/data
-
8/14/2019 networking and printing
14/15
10/29/20
NFS services
Client willl use RPC (remote procedure call) to connectto the server for an export
You should start portmap, lockd, and statd before mountinga NFS volumes. Do so as root.
portmap directs a remote machine to the RPCfunction call its looking for
lockd/statd provides file locking mechanisms (protectagainst multiple people trying to access a file)
Connecting a client to NFS
1. Make sure statd and portmap are started. Use/usr/sbin/rpcinfo p to check
Start them (as root): /sbin/portmap; /sbin/rpc.statd
2. Check that you can see the servers mounts showmount e pca
/exports/data (everyone)
3. Create a mount folder mkdir /mnt/data
4. Mount the export mount server_name:/path/to/export /mnt/point
mount pca:/exports/data /mnt/data
Other NFS client commands
Check that it was mounted
mount
pca:/exports/data on /mnt/data type nfs (rw,addr=10.1.1.1)
umount /mnt/point
umount /mnt/data
-
8/14/2019 networking and printing
15/15
10/29/20
More NFS configurations
Use fstab ... Add this entry
pca:/exports/data /mnt/data nfs defaults
Now you can mount it like so: mountca:/ex orts/data
You can also configure automount to mount an NFSvolume on demand