To Gain Knowledge and to become a one, who all wants to become

Dreams are not those which are seen during sleep ,but Dreams are those which do not let you sleep,so see the dreams
and work hard to make them true.

Sunday, April 25, 2010

What is Network Security ??

Network security is the process of preventing and detecting unauthorized use of your computer. Prevention measures help you to stop unauthorized users (also known as “intruders”) from accessing any part of your computer system. Detection helps you to determine whether or not someone attempted to break into your system, if they were successful, and what they may have done.

Why should I care about network security?

We use computers for everything from banking and investing to shopping and communicating with others through email or chat programs. Although you may not consider your communications “top secret,” you probably do not want strangers reading your email, using your computer to attack other systems, sending forged email from your computer, or examining personal information stored on your computer (such as financial statements).

Who would want to break into my computer at home?

Intruders (also referred to as hackers, attackers, or crackers) may not care about your identity. Often they want to gain control of your computer so they can use it to launch attacks on other computer systems.

Having control of your computer gives them the ability to hide their true location as they launch attacks, often against high-profile computer systems such as government or financial systems. Even if you have a computer connected to the Internet only to play the latest games or to send email to friends and family, your computer may be a target.

Intruders may be able to watch all your actions on the computer, or cause damage to your computer by reformatting your hard drive or changing your data.

How easy is it to break into my computer?

Unfortunately, intruders are always discovering new vulnerabilities (informally called “holes”) to exploit in computer software. The complexity of software makes it increasingly difficult to thoroughly
test the security of computer systems.

When holes are discovered, computer vendors will usually develop patches to address the problem(s). However, it is up to you, the user, to obtain and install the patches, or correctly configure the software to operate more securely. Most of the incident reports of computer break-ins received at the CERT/CC could have been prevented if system administrators and users kept their computers up-to-date with patches and security fixes.

Also, some software applications have default settings that allow other users to access your computer unless you change the settings to be more secure. Examples include chat programs that let outsiders execute commands on your computer or web browsers that could allow someone to place harmful programs on your computer that run when you click on them.

Technology

This section provides a basic introduction to the technologies that underlie the Internet. It was written with the novice end-user in mind and is not intended to be a comprehensive survey of all
Internet-based technologies. Subsections provide a short overview of each topic. This section is a basic primer on the relevant technologies. For those who desire a deeper understanding of the concepts covered here, we include links to additional information.

What does broadband mean?

“Broadband” is the general term used to refer to high-speed network connections. In this context, Internet connections via cable modem and Digital Subscriber Line (DSL) are frequently referred to as broadband Internet connections. “Bandwidth” is the term used to describe the relative speed of a network connection — for example, most current dial-up modems can support a bandwidth of 56 kbps (thousand bits per second). There is no set bandwidth threshold required for a connection to be referred to as “broadband”, but it is typical for connections in excess of 1 Megabit per second (Mbps) to be
so named.

What is cable modem access?

A cable modem allows a single computer (or network of computers) to connect to the Internet via the cable TV network. The cable modem usually has an Ethernet LAN (Local Area Network) connection to the computer, and is capable of speeds in excess of 5 Mbps.

Typical speeds tend to be lower than the maximum, however, since cable providers turn entire neighborhoods into LANs which share the same bandwidth. Because of this “shared-medium” topology, cable modem users may experience somewhat slower network access during periods of peak demand, and may be more susceptible to risks such as packet sniffing and unprotected windows shares than users with other types of connectivity. (See the “Network security risks to home users” section of this document.)

What is DSL access?

Digital Subscriber Line (DSL) Internet connectivity, unlike cable modem-based service, provides the user with dedicated bandwidth. However, the maximum bandwidth available to DSL users is
usually lower than the maximum cable modem rate because of differences in their respective network technologies. Also, the “dedicated bandwidth” is only dedicated between your home and the DSL providers central office — the providers offer little or no guarantee of bandwidth all the way across the Internet.

DSL access is not as susceptible to packet sniffing as cable modem access, but many of the other security risks we will cover apply to both DSL and cable modem access. (See the “Computer security risks to home users” section of this document.)

How are broadband services different from traditional
dial-up services?

Traditional dial-up Internet services are sometimes referred to as “dial-on-demand” services. That is, your computer only connects to the Internet when it has something to send, such as email or a
request to load a web page. Once there is no more data to be sent, or after a certain amount of idle time, the computer disconnects the call. Also, in most cases each call connects to a pool of modems at the ISP, and since the modem IP addresses are dynamically assigned, your computer is usually assigned a different IP address on each call. As a result, it is more difficult (not impossible, just difficult) for an attacker to take advantage of vulnerable network services to take control of your computer.

Broadband services are referred to as “always-on” services because there is no call setup when your computer has something to send. The computer is always on the network, ready to send or receive
data through its network interface card (NIC). Since the connection is always up, your computer IP address will change less frequently (if at all), thus making it more of a fixed target for attack.

What is more, many broadband service providers use well-known IP addresses for home users. So while an attacker may not be able to single out your specific computer as belonging to you, they may at least be able to know that your service providers broadband customers are within a certain address range, thereby making your computer a more likely target than it might have been otherwise.

The table below shows a brief comparison of traditional dial-up and broadband services.
Dial-up Broadband
Connection type Dial on demand Always on
IP address Changes on each call Static or infrequently changing
Relative connection speed Low High
Remote control potential Computer must be dialed in to control remotely Computer is always connected, so remote control can occur anytime
ISP-provided security Little or none Little or none

Table 1: Comparison of Dial-up and Broadband Services

How is broadband access different from the network I use at work?

Corporate and government networks are typically protected by many layers of security, ranging from network firewalls to encryption. In addition, they usually have support staff who maintain the security and availability of these network connections.

Although your ISP is responsible for maintaining the services they provide to you, you probably will not have dedicated staff on hand to manage and operate your home network. You are ultimately responsible for your own computers. As a result, it is up to you to take reasonable precautions to secure your computers from accidental or intentional misuse.

What is a protocol?

A protocol is a well-defined specification that allows computers to communicate across a network. In a way, protocols define the “grammar” that computers can use to “talk” to each other.

What is IP?

IP stands for “Internet Protocol”. It can be thought of as the common language of computers on the Internet. There are a number of detailed descriptions of IP given elsewhere, so we wont cover it in
detail in this document. However, it is important to know a few things about IP in order to understand how to secure your computer. Here we will cover IP addresses, static vs. dynamic addressing, NAT,
and TCP and UDP Ports.

An overview of TCP/IP can be found in the TCP/IP Frequently Asked
Questions (FAQ) at

http://www.faqs.org/faqs/internet/tcp-ip/tcp-ip-faq/part1/

and

http://www.faqs.org/faqs/internet/tcp-ip/tcp-ip-faq/part2

What is an IP address?

IP addresses are analogous to telephone numbers, when you want to call someone on the telephone, you must first know their telephone number. Similarly, when a computer on the Internet needs to send data to another computer, it must first know its IP address. IP addresses are typically shown as four numbers separated by decimal points, or dots. For example, 10.24.254.3 and 192.168.62.231
are IP addresses.

If you need to make a telephone call but you only know the persons name, you can look them up in the telephone directory (or call directory services) to get their telephone number. On the Internet, that directory is called the Domain Name System, or DNS for short. If you know the name of a server, say www.google.com, and you type this into your web browser, your computer will then go ask its DNS server what the numeric IP address is that is associated with that name.

Every computer on the Internet has an IP address associated with it that uniquely identifies it. However, that address may change over time, especially if the computer is

dialing into an Internet Service Provider (ISP)

connected behind a network firewall

connected to a broadband service using dynamic IP addressing.

What are static and dynamic addressing?

Static IP addressing occurs when an ISP permanently assigns one or more IP addresses for each user. These addresses do not change over time. However, if a static address is assigned but not in use, it is effectively wasted. Since ISPs have a limited number of addresses allocated to them, they sometimes need to make more efficient use of their addresses.

Dynamic IP addressing allows the ISP to efficiently utilize their address space. Using dynamic IP addressing, the IP addresses of individual user computers may change over time. If a dynamic address is
not in use, it can be automatically reassigned to another computer as needed.

What is NAT?

Network Address Translation (NAT) provides a way to hide the IP addresses of a private network from the Internet while still allowing computers on that network to access the Internet. NAT can be used in many different ways, but one method frequently used by home users is called “masquerading”.

Using NAT masquerading, one or more devices on a LAN can be made to appear as a single IP address to the outside Internet. This allows for multiple computers in a home network to use a single cable modem or DSL connection without requiring the ISP to provide more than one IP address to the user. Using this method, the ISP-assigned IP address can be either static or dynamic. Most network firewalls support NAT masquerading.

What are TCP and UDP Ports?

TCP (Transmission Control Protocol) and UDP (User Datagram Protocol) are both protocols that use IP. Whereas IP allows two computers to talk to each other across the Internet, TCP and
UDP allow individual applications (also known as “services”) on those computers to talk to each other.

In the same way that a telephone number or physical mail box might be associated with more than one person, a computer might have multiple applications (e.g. email, file services, web services) running on the same IP address. Ports allow a computer to differentiate services such as email data from web data. A port is simply a number associated with each application that uniquely identifies that
service on that computer. Both TCP and UDP use ports to identify services. Some common port numbers are 80 for web (HTTP), 25 for email (SMTP), and 53 for Dmain Name System (DNS).

What is a firewall?

The Firewalls FAQ at http://www.faqs.org/faqs/firewalls-faq defines a firewall as “a system or group of systems that enforces an access control policy between two networks.” In the context of home networks, a firewall typically takes one of two forms:

Software firewall – specialized software running on an individual computer, or

Network firewall – a dedicated device designed to protect one or more computers.

Both types of firewall allow the user to define access policies for inbound connections to the computers they are protecting. Many also provide the ability to control what services (ports) the protected
computers are able to access on the Internet (outbound access). Most firewalls intended for home use come with pre-configured security policies from which the user chooses, and some allow the user to
customize these policies for their specific needs.

What does antivirus software do?

There are a variety of antivirus software packages that operate in many different ways, depending on how the vendor chose to implement their software. What they have in common, though, is that they all look for patterns in the files or memory of your computer that indicate the possible presence of a known virus. Antivirus packages know what to look for through the use of virus profiles (sometimes called “signatures”) provided by the vendor.

New viruses are discovered daily. The effectiveness of antivirus software is dependent on having the latest virus profiles installed on your computer so that it can look for recently discovered viruses. It is important to keep these profiles up to date.

Network security risks to home users

What is at risk?

Information security is concerned with three main areas:

Confidentiality – information should be available only to those who rightfully
have access to it

Integrity — information should be modified only by those who are authorized
to do so

Availability — information should be accessible to those who need it when
they need it

These concepts apply to home Internet users just as much as they would to any corporate or government network. You probably wouldn’t let a stranger look through your important documents. In the same way, you may want to keep the tasks you perform on your computer confidential, whether its tracking your investments or sending email messages to family and friends. Also, you should have some assurance that the information you enter into your computer remains intact and is available when you need it.

Some security risks arise from the possibility of intentional misuse of your computer by intruders via the Internet. Others are risks that you would face even if you werent connected to the
Internet (e.g. hard disk failures, theft, power outages). The bad news is that you probably cannot plan for every possible risk. The good news is that you can take some simple steps to reduce the chance
that youll be affected by the most common threats — and some of those steps help with both the intentional and accidental risks you’re likely to face.

Before we get to what you can do to protect your computer or home network, lets take a closer look at some of these risks.

Intentional misuse of your computer

The most common methods used by intruders to gain control of home computers are briefly described below.

Trojan horse programs

Back door and remote administration programs

Denial of service

Being an intermediary for another attack

Unprotected Windows shares

Mobile code (Java, JavaScript, and ActiveX)

Cross-site scripting

Email spoofing

Email-borne viruses

Hidden file extensions

Chat clients

Packet sniffing

Trojan horse programs

Trojan horse programs are a common way for intruders to trick you (sometimes referred to as "social engineering") into installing "back door" programs. These can allow intruders easy access to your computer without your knowledge, change your system configurations, or infect your computer with a computer virus.

Back door and remote administration programs

On Windows computers, three tools commonly used by intruders to gain remote access to your computer are BackOrifice, Netbus, and SubSeven. These back door or remote administration programs, once installed, allow other people to access and control your computer.

Denial of service

Another form of attack is called a denial-of-service (DoS) attack. This type of attack causes your computer to crash or to become so busy processing data that you are unable to use it. In most cases, the latest patches will prevent the attack.

It is important to note that in addition to being the target of a DoS attack, it is possible for your computer to be used as a participant in a denial-of-service attack on another system.

Being an intermediary for another attack

Intruders will frequently use compromised computers as launching pads for attacking other systems. An example of this is how distributed denial-of-service (DDoS) tools are used. The intruders install an “agent” (frequently through a Trojan horse program) that runs on the compromised computer awaiting further instructions. Then, when a number of agents are running on different computers, a single “handler” can instruct all of them to launch a denial-of-service attack on another system. Thus, the end target of the attack is not your own computer, but someone elses — your computer is just a convenient tool in a larger attack.

Unprotected Windows shares

Unprotected Windows networking shares can be exploited by intruders in an automated way to place tools on large numbers of Windows-based computers attached to the Internet. Because site security on the Internet is interdependent, a compromised computer not only creates problems for the computers owner, but it is also a threat to other sites on the Internet. The greater immediate risk to the Internet community is the potentially large number of computers attached to the Internet with unprotected Windows networking shares combined with distributed attack tools.

Another threat includes malicious and destructive code, such as viruses or worms, which leverage unprotected Windows networking shares to propagate.

There is great potential for the emergence of other intruder tools that leverage unprotected Windows networking shares on a widespread basis.

Mobile code (Java/JavaScript/ActiveX)

There have been reports of problems with “mobile code” (e.g. Java, JavaScript, and ActiveX). These are programming languages that let web developers write code that is executed by your web browser. Although the code is generally useful, it can be used by intruders to gather information (such as which web sites you visit) or to run malicious code on your computer. It is possible to disable Java, JavaScript, and ActiveX in your web browser. We recommend that you do so if you are browsing web sites that you are not familiar with or do not trust.

Also be aware of the risks involved in the use of mobile code within email programs. Many email programs use the same code as web browsers to display HTML. Thus, vulnerabilities that affect Java,
JavaScript, and ActiveX are often applicable to email as well as web pages.

Cross-site scripting

A malicious web developer may attach a script to something sent to a web site, such as a URL, an element in a form, or a database inquiry. Later, when the web site responds to you, the malicious
script is transferred to your browser.

You can potentially expose your web browser to malicious scripts by

following links in web pages, email messages, or newsgroup postings without knowing what they link to

using interactive forms on an untrustworthy site

viewing online discussion groups, forums, or other dynamically generated pages where users can post text containing HTML tags

Email spoofing

Email spoofing is when an email message appears to have originated from one source when it actually was sent from another source. Email spoofing is often an attempt to trick the user into making a damaging statement or releasing sensitive information (such as passwords).

Spoofed email can range from harmless pranks to social engineering ploys. Examples of the latter include

email claiming to be from a system administrator requesting users to change their passwords to a specified string and threatening to suspend their account if they do not comply

email claiming to be from a person in authority requesting users to send them a copy of a password file or other sensitive information

Note that while service providers may occasionally request that you change your password, they usually will not specify what you should change it to. Also, most legitimate service providers would never ask you to send them any password information via email. If you suspect that you may have received a spoofed email from someone with malicious intent, you should contact your service providers support personnel immediately.

Email borne viruses

Viruses and other types of malicious code are often spread as attachments to email messages. Before opening any attachments, be sure you know the source of the attachment. It is not enough that the mail originated from an address you recognize. The Melissa virus spread precisely because it originated from a familiar address. Also, malicious code might be distributed in amusing or enticing programs.

Never run a program unless you know it to be authored by a person or company that you trust. Also, do not send programs of unknown origin to your friends or coworkers simply because they are amusing –they might contain a Trojan horse program.

Hidden file extensions

Windows operating systems contain an option to “Hide file extensions for known file types”. The option is enabled by default, but a user may choose to disable this option in order to have file
extensions displayed by Windows. Multiple email-borne viruses are known to exploit hidden file extensions. The first major attack that took advantage of a hidden file extension was the VBS/LoveLetter worm which contained an email attachment named “LOVE-LETTER-FOR-YOU.TXT.vbs”. Other malicious programs have since incorporated similar naming schemes. Examples include

Downloader (MySis.avi.exe or QuickFlick.mpg.exe)

VBS/Timofonica (TIMOFONICA.TXT.vbs)

VBS/CoolNote (COOL_NOTEPAD_DEMO.TXT.vbs)

VBS/OnTheFly (AnnaKournikova.jpg.vbs)

The files attached to the email messages sent by these viruses may appear to be harmless text (.txt), MPEG (.mpg), AVI (.avi) or other file types when in fact the file is a malicious script or executable
(.vbs or .exe, for example).

Chat clients

Internet chat applications, such as instant messaging applications and Internet Relay Chat (IRC) networks, provide a mechanism for information to be transmitted bi-directionally between computers on the Internet. Chat clients provide groups of individuals with the means to exchange dialog, web URLs, and in many cases, files of any type.

Because many chat clients allow for the exchange of executable code, they present risks similar to those of email clients. As with email clients, care should be taken to limit the chat clients ability to execute downloaded files. As always, you should be wary of exchanging files with unknown parties.

Packet sniffing

A packet sniffer is a program that captures data from information packets as they travel over the network. That data may include user names, passwords, and proprietary information that travels over the network in clear text. With perhaps hundreds or thousands of passwords captured by the packet sniffer, intruders can launch widespread attacks on systems. Installing a packet sniffer does not necessarily require administrator-level access.

Relative to DSL and traditional dial-up users, cable modem users have a higher risk of exposure to packet sniffers since entire neighborhoods of cable modem users are effectively part of the same
LAN. A packet sniffer installed on any cable modem users computer in a neighborhood may be able to capture data transmitted by any other cable modem in the same neighborhood.

Accidents and other risks

In addition to the risks associated with connecting your computer to the Internet, there are a number of risks that apply even if the computer has no network connections at all. Most of these risks are well-known, so we will not go into much detail in this document, but it is important to note that the common practices associated with reducing these risks may also help reduce susceptibility to the network-based risks discussed above.

Disk failure

Recall that availability is one of the three key elements of information security. Although all stored data can become unavailable — if the media its stored on is physically damaged, destroyed, or
lost — data stored on hard disks is at higher risk due to the mechanical nature of the device. Hard disk crashes are a common cause of data loss on personal computers. Regular system backups are the
only effective remedy.

Power failure and surges

Power problems (surges, blackouts, and brown-outs) can cause physical damage to a computer, inducing a hard disk crash or otherwise harming the electronic components of the computer. Common mitigation methods include using surge suppressors and uninterruptible power supplies (UPS).

Physical Theft

Physical theft of a computer, of course, results in the loss of confidentiality and availability, and (assuming the computer is ever recovered) makes the integrity of the data stored on the disk suspect.
Regular system backups (with the backups stored somewhere away from the computer) allow for recovery of the data, but backups alone cannot address confidentiality. Cryptographic tools are available that can encrypt data stored on a computers hard disk. The CERT/CC encourages the use of these tools if the computer contains sensitive data or is at high risk of theft (e.g. laptops or other portable computers).

Home Users Protection Methods

The CERT/CC recommends the following practices to home users:

Consult your system support personnel if you work from home

Use virus protection software

Use a Network Security firewall

Do not open unknown email attachments

Do not run programs of unknown origin

Disable hidden filename extensions

Keep all applications (including your operating system) patched

Turn off your computer or disconnect from the network when not in use

Disable Java, JavaScript, and ActiveX if possible

Disable scripting features in email programs

Make regular backups of critical data

Make a boot disk in case your computer is damaged or compromised

Further discussion on each of these points is given below.
Network Security Recommendations

Consult your system support personnel if you work
from home

If you use your broadband access to connect to your employers network via a Virtual Private Network (VPN) or other means, your employer may have policies or procedures relating to the security of
your home network. Be sure to consult with your employers support personnel, as appropriate, before following any of the steps outlined in this document.

Use virus protection software

Use anti-virus software on all Internet-connected computers. Be sure to keep your anti-virus software up-to-date. Many anti-virus packages support automatic updates of virus definitions. We recommend the use of these automatic updates when available.

Use a Network Security firewall

We strongly recommend the use of some type of firewall product, such as a network appliance or a personal firewall software package. Intruders are constantly scanning home user systems for known
vulnerabilities. Network firewalls (whether software or hardware-based) can provide some degree of protection against these attacks. However, no firewall can detect or stop all attacks, so its not sufficient to install a firewall and then ignore all other security measures.

do not open unknown email attachments

Before opening any email attachments, be sure you know the source of the attachment. It is not enough that the mail originated from an address you recognize. The Melissa virus spread precisely because it originated from a familiar address. Malicious code might be distributed in amusing or enticing programs.

If you must open an attachment before you can verify the source, we suggest the following procedure:

be sure your virus definitions are up-to-date (see “Use virus protection software” above)

save the file to your hard disk

scan the file using your antivirus software

open the file

For additional protection, you can disconnect your computers network connection before opening the file.

Following these steps will reduce, but not wholly eliminate, the chance that any malicious code contained in the attachment might spread from your computer to others.

do not run programs of unknown origin

Never run a program unless you know it to be authored by a person or company that you trust. Also, do not send programs of unknown origin to your friends or coworkers simply because they are amusing — they might contain a Trojan horse program.

Disable hidden filename extensions

Windows operating systems contain an option to “Hide file extensions for known file types”. The option is enabled by default, but you can disable this option in order to have file extensions displayed by Windows. After disabling this option, there are still some file extensions that, by default, will continue to remain hidden.

There is a registry value which, if set, will cause Windows to hide certain file extensions regardless of user configuration choices elsewhere in the operating system. The “NeverShowExt” registry value is used to hide the extensions for basic Windows file types. For example, the “.LNK” extension associated with Windows shortcuts remains hidden even after a user has turned off the option to hide extensions.

Keep all applications, including your operating system, patched

Vendors will usually release patches for their software when a vulnerability has been discovered. Most product documentation offers a method to get updates and patches. You should be able to obtain
updates from the vendors web site. Read the manuals or browse the vendors web site for more information.

Some applications will automatically check for available updates, and many vendors offer automatic notification of updates via a mailing list. Look on your vendors web site for information about automatic notification. If no mailing list or other automated notification mechanism is offered you may need to check periodically for updates.

Turn off your computer or disconnect from the network when not in use

Turn off your computer or disconnect its Ethernet interface when you are not using it. An intruder cannot attack your computer if it is powered off or otherwise completely disconnected from the network.

Disable Java, JavaScript, and ActiveX if possible

Be aware of the risks involved in the use of “mobile code” such as ActiveX, Java, and JavaScript. A malicious web developer may attach a script to something sent to a web site, such as a URL, an element in a form, or a database inquiry. Later, when the web site responds to you, the malicious script is transferred to your browser.

The most significant impact of this vulnerability can be avoided by disabling all scripting languages. Turning off these options will keep you from being vulnerable to malicious scripts. However, it will
limit the interaction you can have with some web sites.

Many legitimate sites use scripts running within the browser to add useful features. Disabling scripting may degrade the functionality of these sites.

Disable scripting features in email programs

Because many email programs use the same code as web browsers to display HTML, vulnerabilities that affect ActiveX, Java, and JavaScript are often applicable to email as well as web pages. Therefore, in addition to disabling scripting features in web browsers (see “Disable Java, JavaScript, and ActiveX if possible”, above), we recommend that users also disable these features in their email programs.

Make regular backups of critical data

Keep a copy of important files on removable media such as ZIP disks or recordable CD-ROM disks (CD-R or CD-RW disks). Use software backup tools if available, and store the backup disks somewhere away from the computer.

Make a boot disk in case your computer is damaged or compromised

To aid in recovering from a security breach or hard disk failure, create a boot disk on a floppy disk which will help when recovering a computer after such an event has occurred. Remember, however, you must create this disk before you have a security event.

Friday, April 23, 2010

Squid Authentication

Linux is growing. It is now used in many everyday gadgets and is no longer just for systems administrators. This site covers topics needed for Linux software certification exams, such as the Red Hat Certified Engineer (RHCE), Ubuntu Certified Professional (UCP), and many computer training courses.

The data center section outlines the rationale for either hosting your website in a server room or using a purpose built colocation facility and run by a third party. It also covers how to migrate your existing servers from one data center to another with many of the required check lists. The introductory Cisco VPN and firewall networking sections should be interesting too. Most of the site's topics are available for purchase as PDF documents.
From Linux Home Networking
Jump to: navigation, search
Contents
[hide]

* 1 Sponsors
* 2 Introduction
* 3 Download and Install The Squid Package
* 4 Starting Squid
* 5 The /etc/squid/squid.conf File
o 5.1 The Visible Host Name
o 5.2 Access Control Lists
o 5.3 Restricting Web Access By Time
o 5.4 Restricting Access to specific Web sites
o 5.5 Restricting Web Access By IP Address
o 5.6 Password Authentication Using NCSA
* 6 Forcing Users To Use Your Squid Server
o 6.1 Making Your Squid Server Transparent To Users
+ 6.1.1 Squid Transparent Proxy Configuration
+ 6.1.2 Configuring iptables to Support the Squid Transparent Proxy
o 6.2 Manually Configuring Web Browsers To Use Your Squid Server
* 7 Squid Disk Usage
* 8 Troubleshooting Squid
* 9 Conclusion

Sponsors

Introduction

Two important goals of many small businesses are to:

* Reduce Internet bandwidth charges
* Limit access to the Web to only authorized users.

The Squid web caching proxy server can achieve both these goals fairly easily.

Users configure their web browsers to use the Squid proxy server instead of going to the web directly. The Squid server then checks its web cache for the web information requested by the user. It will return any matching information that finds in its cache, and if not, it will go to the web to find it on behalf of the user. Once it finds the information, it will populate its cache with it and also forward it to the user's web browser.

As you can see, this reduces the amount of data accessed from the web. Another advantage is that you can configure your firewall to only accept HTTP web traffic from the Squid server and no one else. Squid can then be configured to request usernames and passwords for each user that users its services. This provides simple access control to the Internet.
Download and Install The Squid Package

Most RedHat Linux software products are available in the RPM format. Downloading and installing RPMs isn't hard. If you need a refresher, Chapter 6, "Installing Linux Software", provides details. It is best to use the latest version of Squid.
Starting Squid

Use the chkconfig configure Squid to start at boot::

[root@bigboy tmp]# chkconfig squid on

Use the service command to start, stop, and restart Squid after booting:

[root@bigboy tmp]# service squid start
[root@bigboy tmp]# service squid stop
[root@bigboy tmp]# service squid restart

You can test whether the Squid process is running with the pgrep command:

[root@bigboy tmp]# pgrep squid

You should get a response of plain old process ID numbers.
The /etc/squid/squid.conf File

The main Squid configuration file is squid.conf, and, like most Linux applications, Squid needs to be restarted for changes to the configuration file can take effect.
The Visible Host Name

Squid will fail to start if you don't give your server a hostname. You can set this with the visible_hostname parameter. Here, the hostname is set to the real name of the server bigboy.

visible_hostname bigboy



(c) Peter Harrison
he Internet with access control lists (ACLs). Each ACL line defines a particular type of activity, such as an access time or source network, they are then linked to an http_access statement that tells Squid whether or not to deny or allow traffic that matches the ACL.

Squid matches each Web access request it receives by checking the http_access list from top to bottom. If it finds a match, it enforces the allow or deny statement and stops reading further. You have to be careful not to place a deny statement in the list that blocks a similar allow statement below it. The final http_access statement denies everything, so it is best to place new http_access statements above it

Note: The very last http_access statement in the squid.conf file denies all access. You therefore have to add your specific permit statements above this line. In the chapter's examples, I've suggested that you place your statements at the top of the http_access list for the sake of manageability, but you can put them anywhere in the section above that last line.

Squid has a minimum required set of ACL statements in the ACCESS_CONTROL section of the squid.conf file. It is best to put new customized entries right after this list to make the file easier to read.
Restricting Web Access By Time

You can create access control lists with time parameters. For example, you can allow only business hour access from the home network, while always restricting access to host 192.168.1.23.

#
# Add this to the bottom of the ACL section of squid.conf
#
acl home_network src 192.168.1.0/24
acl business_hours time M T W H F 9:00-17:00
acl RestrictedHost src 192.168.1.23

#
# Add this at the top of the http_access section of squid.conf
#
http_access deny RestrictedHost
http_access allow home_network business_hours

Or, you can allow morning access only:

#
# Add this to the bottom of the ACL section of squid.conf
#
acl mornings time 08:00-12:00

#
# Add this at the top of the http_access section of squid.conf
#
http_access allow mornings

Restricting Access to specific Web sites

Squid is also capable of reading files containing lists of web sites and/or domains for use in ACLs. In this example we create to lists in files named /usr/local/etc/allowed-sites.squid and /usr/local/etc/restricted-sites.squid.

# File: /usr/local/etc/allowed-sites.squid
www.openfree.org
linuxhomenetworking.com

# File: /usr/local/etc/restricted-sites.squid
www.porn.com
illegal.com

These can then be used to always block the restricted sites and permit the allowed sites during working hours. This can be illustrated by expanding our previous example slightly.

#
# Add this to the bottom of the ACL section of squid.conf
#
acl home_network src 192.168.1.0/24
acl business_hours time M T W H F 9:00-17:00
acl GoodSites dstdomain "/usr/local/etc/allowed-sites.squid"
acl BadSites dstdomain "/usr/local/etc/restricted-sites.squid"

#
# Add this at the top of the http_access section of squid.conf
#
http_access deny BadSites
http_access allow home_network business_hours GoodSites

Restricting Web Access By IP Address

You can create an access control list that restricts Web access to users on certain networks. In this case, it's an ACL that defines a home network of 192.168.1.0.

#
# Add this to the bottom of the ACL section of squid.conf
#
acl home_network src 192.168.1.0/255.255.255.0

You also have to add a corresponding http_access statement that allows traffic that matches the ACL:

#
# Add this at the top of the http_access section of squid.conf
#
http_access allow home_network

Password Authentication Using NCSA

You can configure Squid to prompt users for a username and password. Squid comes with a program called ncsa_auth that reads any NCSA-compliant encrypted password file. You can use the htpasswd program that comes installed with Apache to create your passwords. Here is how it's done:

1) Create the password file. The name of the password file should be /etc/squid/squid_passwd, and you need to make sure that it's universally readable.

[root@bigboy tmp]# touch /etc/squid/squid_passwd
[root@bigboy tmp]# chmod o+r /etc/squid/squid_passwd

2) Use the htpasswd program to add users to the password file. You can add users at anytime without having to restart Squid. In this case, you add a username called www:

[root@bigboy tmp]# htpasswd /etc/squid/squid_passwd www
New password:
Re-type new password:
Adding password for user www
[root@bigboy tmp]#

3) Find your ncsa_auth file using the locate command.

[root@bigboy tmp]# locate ncsa_auth
/usr/lib/squid/ncsa_auth
[root@bigboy tmp]#

4) Edit squid.conf; specifically, you need to define the authentication program in squid.conf, which is in this case ncsa_auth. Next, create an ACL named ncsa_users with the REQUIRED keyword that forces Squid to use the NCSA auth_param method you defined previously. Finally, create an http_access entry that allows traffic that matches the ncsa_users ACL entry. Here's a simple user authentication example; the order of the statements is important:

#
# Add this to the auth_param section of squid.conf
#
auth_param basic program /usr/lib/squid/ncsa_auth /etc/squid/squid_passwd

#
# Add this to the bottom of the ACL section of squid.conf
#
acl ncsa_users proxy_auth REQUIRED

#
# Add this at the top of the http_access section of squid.conf
#
http_access allow ncsa_users

5) This requires password authentication and allows access only during business hours. Once again, the order of the statements is important:

#
# Add this to the auth_param section of squid.conf
#
auth_param basic program /usr/lib/squid/ncsa_auth /etc/squid/squid_passwd

#
# Add this to the bottom of the ACL section of squid.conf
#
acl ncsa_users proxy_auth REQUIRED
acl business_hours time M T W H F 9:00-17:00

#
# Add this at the top of the http_access section of squid.conf
#
http_access allow ncsa_users business_hours

Remember to restart Squid for the changes to take effect.
Forcing Users To Use Your Squid Server

If you are using access controls on Squid, you may also want to configure your firewall to allow only HTTP Internet access to only the Squid server. This forces your users to browse the Web through the Squid proxy.
Making Your Squid Server Transparent To Users

It is possible to limit HTTP Internet access to only the Squid server without having to modify the browser settings on your client PCs. This called a transparent proxy configuration. It is usually achieved by configuring a firewall between the client PCs and the Internet to redirect all HTTP (TCP port 80) traffic to the Squid server on TCP port 3128, which is the Squid server's default TCP port.
Squid Transparent Proxy Configuration

Your first step will be to modify your squid.conf to create a transparent proxy. The procedure is different depending on your version of Squid.

Prior to version 2.6: In older versions of Squid, transparent proxy was achieved through the use of the httpd_accel options which were originally developed for http acceleration. In these cases, the configuration syntax would be as follows:

httpd_accel_host virtual
httpd_accel_port 80
httpd_accel_with_proxy on
httpd_accel_uses_host_header on

Version 2.6 and Beyond: Newer versions of Squid simply require you to add the word "transparent" to the default "http_port 3128" statement. In this example, Squid not only listens on TCP port 3128 for proxy connections, but will also do so in transparent mode.

http_port 3128 transparent

Configuring iptables to Support the Squid Transparent Proxy

The examples below are based on the discussion of Linux iptables in Chapter 14, "Linux Firewalls Using iptables". Additional commands may be necessary for you particular network topology.

In both cases below, the firewall is connected to the Internet on interface eth0 and to the home network on interface eth1. The firewall is also the default gateway for the home network and handles network address translation on all the network's traffic to the Internet.

Only the Squid server has access to the Internet on port 80 (HTTP), because all HTTP traffic, except that coming from the Squid server, is redirected.

If the Squid server and firewall are the same server, all HTTP traffic from the home network is redirected to the firewall itself on the Squid port of 3128 and then only the firewall itself is allowed to access the Internet on port 80.

iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 \
-j REDIRECT --to-port 3128
iptables -A INPUT -j ACCEPT -m state \
--state NEW,ESTABLISHED,RELATED -i eth1 -p tcp \
--dport 3128
iptables -A OUTPUT -j ACCEPT -m state \
--state NEW,ESTABLISHED,RELATED -o eth0 -p tcp \
--dport 80
iptables -A INPUT -j ACCEPT -m state \
--state ESTABLISHED,RELATED -i eth0 -p tcp \
--sport 80
iptables -A OUTPUT -j ACCEPT -m state \
--state ESTABLISHED,RELATED -o eth1 -p tcp \
--sport 80

Note: This example is specific to HTTP traffic. You won't be able to adapt this example to support HTTPS web browsing on TCP port 443, as that protocol specifically doesn't allow the insertion of a "man in the middle" server for security purposes. One solution is to add IP masquerading statements for port 443, or any other important traffic, immediately after the code snippet. This will allow non HTTP traffic to access the Internet without being cached by Squid.

If the Squid server and firewall are different servers, the statements are different. You need to set up iptables so that all connections to the Web, not originating from the Squid server, are actually converted into three connections; one from the Web browser client to the firewall and another from the firewall to the Squid server, which triggers the Squid server to make its own connection to the Web to service the request. The Squid server then gets the data and replies to the firewall which then relays this information to the Web browser client. The iptables program does all this using these NAT statements:

iptables -t nat -A PREROUTING -i eth1 -s ! 192.168.1.100 \
-p tcp --dport 80 -j DNAT --to 192.168.1.100:3128
iptables -t nat -A POSTROUTING -o eth1 -s 192.168.1.0/24 \
-d 192.168.1.100 -j SNAT --to 192.168.1.1
iptables -A FORWARD -s 192.168.1.0/24 -d 192.168.1.100 \
-i eth1 -o eth1 -m state
--state NEW,ESTABLISHED,RELATED \
-p tcp --dport 3128 -j ACCEPT
iptables -A FORWARD -d 192.168.1.0/24 -s 192.168.1.100 \
-i eth1 -o eth1 -m state --state ESTABLISHED,RELATED \
-p tcp --sport 3128 -j ACCEPT

In the first statement all HTTP traffic from the home network except from the Squid server at IP address 192.168.1.100 is redirected to the Squid server on port 3128 using destination NAT. The second statement makes this redirected traffic also undergo source NAT to make it appear as if it is coming from the firewall itself. The FORWARD statements are used to ensure the traffic is allowed to flow to the Squid server after the NAT process is complete. The unusual feature is that the NAT all takes place on one interface; that of the home network (eth1).

You will additionally have to make sure your firewall has rules to allow your Squid server to access the Internet on HTTP TCP port 80 as covered in Chapter 14, "Linux Firewalls Using iptables".
Manually Configuring Web Browsers To Use Your Squid Server

If you don't have a firewall that supports redirection, then you need to configure your firewall to only accept HTTP Internet access from the Squid server, as well as configure your PC browser's proxy server settings manually to use the Squid server. The method you use depends on your browser.

For example, to make these changes using Internet Explorer

1. Click on the "Tools" item on the menu bar of the browser.
2. Click on "Internet Options"
3. Click on "Connections"
4. Click on "LAN Settings"
5. Configure with the address and TCP port (3128 default) used by your Squid server.

Here's how to make the same changes using Mozilla or Firefox.

1. Click on the "Edit" item on the browser's menu bar.
2. Click on "Preferences"
3. Click on "Advanced"
4. Click on "Proxies"
5. Configure with the address and TCP port (3128 default) used by your Squid server under "Manual Proxy Configuration"

Squid Disk Usage

Squid uses the /var/spool/squid directory to store its cache files. High usage squid servers need a large amount of disk space in the /var partition to get optimum performance.

Every webpage and image accessed via the Squid server is logged in the /var/log/squid/access.log file. This can get quite large on high usage servers. Fortunately, the logrotate program automatically purges this file.
Troubleshooting Squid

Squid logs both informational and error messages to files in the /var/log/squid/ directory. It is best to review these files first whenever you have difficulties.The squid.out file can be especially useful as it contains Squids' system errors.

Another source of errors could be unintended statements in the squid.conf file that cause no errors; mistakes in the configuration of hours of access and permitted networks that were forgotten to be added are just two possibilities.

By default, Squid operates on port 3128, so if you are having connectivity problems, you'll need to follow the troubleshooting steps in Chapter 4, "Simple Network Troubleshooting", to help rectify them.

Note: Some of Squid's capabilities go beyond the scope of this book, but you should be aware of them. For example, for performance reasons, you can configure child Squid servers on which certain types of content are exclusively cached. Also, you can restrict the amount of disk space and bandwidth Squid uses.
Conclusion

Tools such as Squid are popular with many company mangers. By caching images and files on a server shared by all, Internet bandwidth charges can be reduced.

Squid's password authentication feature is well liked because it allows only authorized users to access the Internet as a means of reducing usage fees and distractions in the office. Unfortunately, an Internet access password is usually not viewed as a major security concern by most users who are often willing to share it with their colleagues. Although it is beyond the scope of this book, you should consider automatically tying the Squid password to the user's regular login password. This will make them think twice about giving their passwords away. Internet access is one thing, letting your friends have full access to your e-mail and computer files is quite another.

HOWTO Configure Linux `sendmail' Client with Comcast ISP and Authentication

This page describes how to configure sending and receiving mail with Comcast ISP provider. Note, that the same configuration still applies to any corporate network or other ISP providers as well.

* Configuring outgoing mail
* Configuring incoming mail
* Configuring Evolution client
* Useful links

It doesn't matter much if your machine uses dial-up PPP connection or has static address on internal network hidden behind firewall. The decisive factor is that in both cases, your ISP provider runs mail server for you. With these assumptions in mind, I have to do the following to make things work for me:
Configuring outgoing mail with sendmail

Configuring sendmail can be painfull.

1. Install sendmail configuration files

# yum -y install sendmail-cf

Configuration files are stored in /usr/share/sendmail-cf/cf.

2. Create sendmail database files

We are going to create or edit five database files:

* genericsdomain
* genericstable
* trusted-users
* local-host-names
* access

2.1 Find you host's Fully-Qualified Domain Name (FQDN)

For sendmail to work properly, you need to know your FQDN of your host:

# cd /etc/mail
# hostname -f

dollar.3rdshift.com

2.2 Create genericsdomain file

Now create /etc/mail/genericsdomain to hold your fully qualified host name.

# cd /etc/mail
# hostname -f > genericsdomain

# cat /etc/mail/genericsdomain

dollar.3rdshift.com

2.3 Create genericstable file

Now create /etc/mail/genericstable and add the following line to translate local e-mail address to the target ISP-assigned sender e-mail address:

vlg@dollar.3rdShift.com 3rdshift@comcast.net

2.4 Mark your account as trusted user

Add your account to /etc/mail/trusted-users file:

# trusted-users - users that can send mail as others without a warning
# apache, mailman, majordomo, uucp, are good candidates

vlg


2.5 List all aliases of your host

Edit /etc/mail/local-host-names file and add FQDN of your host.

# local-host-names - include all aliases for your machine here.

localhost
dollar.3rdshift.com

2.6 Create authentication database file

To fight the spam, comcast has blocked port 22 and, instead, requires mail client programs to connect to port 587 and authenticate themselves.

The first thing is to find out if you have the correct username and password that will work with comcast. That can be verified out rather easily:

* Go to encode.html. This JavaScript executes locally on your machine (you can examine the page source yourself) and you can use it to convert your username and password to base64.
* ... TBD ...

Find canonical name of the comcast SMTP service:

# nslookup smtp.comcast.net

Server: 216.231.41.2
Address: 216.231.41.2#53

Non-authoritative answer:
smtp.comcast.net canonical name = smtp.g.comcast.net.
Name: smtp.g.comcast.net
Address: 76.96.62.117

The canonical name happens to be smtp.g.comcast.net.

To find out if your version of sendmail has built in authentication protocol(s):

# /usr/sbin/sendmail.sendmail -d0.1 -bt < /dev/null

Version 8.14.2
Compiled with: DNSMAP HESIOD HES_GETMAILHOST LDAPMAP LOG MAP_REGEX
MATCHGECOS MILTER MIME7TO8 MIME8TO7 NAMED_BIND NETINET NETINET6
NETUNIX NEWDB NIS PIPELINING SASLv2 SCANF SOCKETMAP STARTTLS
TCPWRAPPERS USERDB USE_LDAP_INIT

============ SYSTEM IDENTITY (after readcf) ============
(short domain name) $w = dollar
(canonical domain name) $j = dollar.3rdshift.com
(subdomain name) $m = 3rdshift.com
(node name) $k = dollar.3rdShift.com
========================================================

Clearly, SASLv2 protocol is built in

Now, edit /etc/mail/access file and add AuthInfo entries:

# By default we allow relaying from localhost...

Connect:localhost.localdomain RELAY
Connect:localhost RELAY
Connect:127.0.0.1 RELAY

AuthInfo:smtp.g.comcast.net "U:3rdshift[AT]comcast.net" "I:3rdshift[AT]comcast.net" "P:YourPasswordHere"
AuthInfo:smtp.g.comcast.net:587 "U:3rdshift[AT]comcast.net" "I:3rdshift[AT]comcast.net" "P:YourPasswordHere"


Both 'U' (user) and 'I' (id) should hold your e-mail address. Don't forget to replace "[AT]" with '@'. Read more about it AUTH related part of sendmail manual.

Make sure access file can be read only by a trusted user:


# chmod 600 /etc/mail/access

Now, we are ready to modify /etc/mail/sendmail.mc configuration file.
3. Edit sendmail.mc file

To create your *.mc configuration file, use comcast sendmail template, sendmail.mc.comcast, as a starting point.

$ su
# cd /etc/mail
# wget http://pbxinaflash.net/source/sendmail/sendmail.mc.comcast
# cp sendmail.mc.comcast sendmail.mc

Open sendmail.mc in the editor and make following modifications:

define(`SMART_HOST',`smtp.g.comcast.net')dnl
define(`RELAY_MAILER_ARGS', `TCP $h 587')dnl

define(`confPRIVACY_FLAGS', `authwarnings,novrfy,noexpn,restrictqrun')dnl
define(`confAUTH_OPTIONS', `A')dnl

define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
FEATURE(`authinfo',`hash /etc/mail/access')dnl

FEATURE(`access_db', `hash -T -o /etc/mail/access.db')dnl

MASQUERADE_AS(`comcast.net')dnl
FEATURE(`allmasquerade')dnl
FEATURE(`masquerade_envelope')dnl

FEATURE(genericstable, `hash -o /etc/mail/genericstable')dnl
GENERICS_DOMAIN_FILE(`/etc/mail/genericsdomain')dnl

3.1 Explanation

define(`SMART_HOST',`mail.mydomain.com')dnl

tells sendmail to relay all of the outgoing mail to my ISP's mail server.

MASQUERADE_AS(mydomain.com)dnl
FEATURE(`allmasquerade')dnl
FEATURE(`masquerade_envelope')dnl

tells sendmail to masquerade From: to domain mydomain.com. sendmail will convert my initial address `vlg[AT]dollar.3rdshift.com' to `vlg[AT]comcast.net'.

The last pair of lines

FEATURE(genericstable, `hash -o /etc/mail/genericstable')dnl
GENERICS_DOMAIN_FILE(`/etc/mail/genericsdomain')dnl

completes the e-mail address translation. It will transform `vlg[AT]comcast.net' into `3rdshift[AT]comcast.net'.
4. Compile and install sendmail configuration file

To generate all database files and configuration file:

# cd /etc/mail
# make clean
# make

make utility will compile all ".db" files from their sources and convert sendmail.mc into sendmail.cf file.
5. Restart sendmail service

# /sbin/service sendmail restart

You should see no errors in /var/log/maillog. Try to send an e-mail out and verify its delivery. If authentication with Comcast should fail, sendmail will deliver denial reply from comcast to the 'root' user. Login as 'root' and examine the reply for further assistance.
[Up]
Configuring incoming mail with fetchmail
1. Create configuration profile

For starters, fetchmailconf configuration tool will do most of the job. It is useful in autodetecting the protocol type your used by your ISP's mail server. The resultant configuration file ~/.fetchmailrc should have 0600 permissions and will look similar to this:

set logfile "/home/vlg/Mail/fetchmail.log"
#set syslog
set postmaster "vlg"
set bouncemail
set properties ""
set daemon 5

poll sz-pop.mail.comcast.net with proto POP3 and options no dns uidl
user 3rdshift there with password MyPassword is vlg
here options fetchall
antispam 571 550 501 554

Apparently, fetchall option is very important. Otherwise, not all messages will be delivered to your local machine with POP3 server. Also, it should come last in the line. Otherwise, default values for other options that follows might be assumed.

For PPP dial-up networks it might be wiser to start it when connection is established and bring it down when connection is torn apart. The commans for staring is:

fetchmail -d 180

This will run fetchmail as a daemon process, polling mail server every 3 minutes.
To stop fetchmail:

fetchmail -q

To run fetchmail from cron job, schedule the following command with crontab -e :

0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,54,57 0-23 * * * fetchmail
-d0 -s -t 30 -f /home/vlg/.fetchmailrc > /dev/null 2>&1

That is to say: Run fetchmail polling every 3 minutes around the clock, with [-t 30] connection timeout of 30 seconds to ISP's mail server, [-s] in silent mode, [-d0] not as a daemon, [-f fname] using my configuration file.

That's pretty much it. Enjoy reading your mail!
[Up]
Configure Evolution

Configure Evolution for local delivery:

* Identitiy:

1. Email address: 3rdshfit-AT-comcast-dot-net
2. Make this my default account: Yes

* Receiving mail:

1. Server type: Local delivery
2. Configuration: /var/spool/mail/vlg

* Receiving options:

1. Checking for New Mail: Yes (every 10 minutes)

* Sending Mail:

1. Server Type: sendmail

* Timezone

1. Selection: America/New York

[Up]
Usefull links

There are tons of those, but very few I found are down to the point:

* Comcast-specific sendmail setup
* Sendmail home page
* Fetchmail home page
* The Linux Electronic Mail Administrator HOWTO
* Official Mutt e-mail reader home page
* mutt-users mailing list archive
* Evolution mail client

File Compression and Archiving with Gzip, Zip, and Tar


File Compression and Archiving with Gzip, Zip, and Tar

Compressing with Gzip and Zip

Compressed files use less disk space and download faster than large, uncompressed files. You can compress Linux files with the open-source compression tool Gzip or with Zip, which is recognized by most operating systems.
By convention, compressed files are given the extension .gz. The command Gzip creates a compressed file ending with .gz; Gunzip extracts the compressed files and removes the .gz file.
To compress a file, at a shell prompt, type the following command:
gzip filename.ext
The file will be compressed and saved as filename.ext.gz.
To expand a compressed file, type:
gunzip filename.ext.gz
The filename.ext.gz is deleted and replaced with filename.ext.
If you exchange files with non-Linux users, you may want to use zip to avoid compatibility problems. Red Hat Linux can easily open zip or gzip files, but non-Linux operating systems may have problems with gzip files.
To compress a file with zip, type the following:
zip -r filename.zip files
In this example, filename represents the file you are creating and files represents the files you want to put in the new file:
To extract the contents of a zip file, type:
unzip filename.zip
You can zip or gzip multiple files at the same time. List the files with a space between each one.
gzip filename.gz file1 file2 file3 /user/work/school 
The above command will compress file1, file2, file3, and the contents of the /user/work/school directory and put them in filename.gz.

Archiving with Tar

Tar files place several files or the contents of a directory or directories in one file. This is a good way to create backups and archives. Usually, tar files end with the .tar extension.
To create a tar file, type:
tar -cvf filename.tar files/directories
In this example, filename.tar represents the file you are creating and files/directories represents the files or directories you want to put in the new file.
You can use absolute or relative pathnames for these files and directories Separate the names of files and directories with a space.
The following input would create a tar file using absolute pathnames:
 tar -cvf foo.tar /home/mine/work /home/mine/school       
The above command would place all the files in the /work subdirectory and the /school subdirectory in a new file called foo.tar in the current working directory.
The command tar -cvf foo.tar file1.txt file2.txt file3.txt would place file1.txt, file2.txt and file3.txt in a new file called foo.tar.
To list the contents of a tar file, type:
tar -tvf foo.tar
To extract the contents of a tar file, type:
tar -xvf foo.tar
This command does not remove the .tar file, but it places copies of the .tar contents in the current working directory.
The tar command does not compress files automatically. You can compress tar files with:
tar -czvf foo.tar
Compressed tar files are conventionally given the extension .tgz and are compressed with gzip.
To expand a compressed tar file type:
tar -xzvf foo.tgz