mail server report

115
A REPORT ON MAIL SERVER Submitted by: Navjot Singh 1137836 DEPARTMENT OF ELECTRONICS AND COMMUNICATION BABA FARID COLLEGE OF ENGINEERING &TECH. Muktsar Road, Bathinda-151001, Punjab (INDIA) (Approved by AICTE, New Delhi and Affiliated to Punjab Technical University, Jalandhar) June, 2015

Upload: navjot-insan

Post on 14-Aug-2015

70 views

Category:

Software


1 download

Tags:

TRANSCRIPT

Page 1: Mail server report

A REPORT ON

MAIL SERVER

Submitted by:

Navjot Singh

1137836

DEPARTMENT OF ELECTRONICS AND COMMUNICATION

BABA FARID COLLEGE OF ENGINEERING &TECH.Muktsar Road, Bathinda-151001, Punjab (INDIA)

(Approved by AICTE, New Delhi and Affiliated to Punjab Technical University, Jalandhar)

June, 2015

Page 2: Mail server report

A REPORT ON

MAIL SERVER

SUBMITTED IN PARTIAL FULFILLMENT FOR AWARD DEGREE OF

BACHELOR OF TECHNOLOGY

IN

ELECTRONICS AND COMMUNICATION ENGINEERING

BYNAVJOT SINGH

(1137836)

UNDER THE GUIDANCE OF

ER. HARDEEP SINGH, HOD ECE DEPT.ER. SWARNJEET SINGH, ATPO ECE DEPT.

DEPARTMENT OF ELECTRONICS AND COMMUNICATION

BABA FARID COLLEGE OF ENGINEERING &TECH.Muktsar Road, Bathinda-151001, Punjab (INDIA)

(Approved by AICTE, New Delhi and Affiliated to Punjab Technical University, Jalandhar)

Page 3: Mail server report

Contents

S.No. Title Page No.

Certificate v

Abstract vi

Acknowledgement viii

List of Figures x

Chapter 1 Introduction to mail server 1

1.1 Introduction 1

1.2

1.2.1

1.2.2

Requirements

Hardware Requirements

Software Requirements

2

2

2

1.3 Methodology 2

1.4 The features implemented in project 3

Chapter 2 Protocols used in mail server 4

2.1 IMAP 4

2.2 POP3 5

2.3 SMTP 6

2.4 IP 7

Chapter 3 How to install Ubuntu 8

3.1 What is Ubuntu 8

3.2 Installation of Ubuntu 8

Chapter 4 IP addressing 15

4.1 What is IP address 15

4.2

4.3

4.3.1

4.3.2

4.3.3

Format of an IP address

Types of IP addressing

Temporary IP address assignment

Dynamic IP address assignment

Static IP address assignment

15

15

15

17

18

Chapter 5 DNS server 19

5.1 Overview 19

Page 4: Mail server report

5.2 BIND as a nameserver 20

5.3

5.4

5.4.1

5.4.2

5.4.3

5.4.4

5.5

5.6

5.6.1

5.6.2

5.6.3

5.6.4

Installation of Bind package

Configurations

Overview of configurations

Caching Nameserver

Primary Nameserver

Secondary Nameserver

Common record types

Testing

resolv.conf file

hosts file

dig

ping

20

20

20

21

21

24

26

26

26

27

27

27

Chapter 6 Dynamic Host Configuration Protocol 29

6.1 DHCP 29

6.1.1 Manual allocation(MAC address) 29

6.1.2

6.2

6.3

Automatic allocation

Installation

Configurations

30

30

31

Chapter 7 Mail Transfer Agent 32

7.1 Overview 32

7.2 Installation 33

7.3

7.4

7.4.1

7.4.2

Configurations

Components

Component structure

Receiving a mail

33

34

34

34

Chapter 8 Mail Delivery Agent 36

Page 5: Mail server report

8.1 Overview 36

8.2 Dovecot as MDA 36

8.3

8.3.1

8.3.2

8.3.3

8.4

Configurations

Choice of protocols

Choice of mailboxes

Setting up maildir

Testing

36

36

37

38

38

Chapter 9 Webmail Client 40

9.1 Introduction 40

9.2 Preparation 40

9.3

9.3.1

9.3.2

9.4

Installation & Configurations

Installation

Squirrelmail configuration

Apache configuration

40

40

40

42

Chapter 10 Apache Server 43

10.1 Introduction 43

10.2 Types of virtual host 44

10.2.1

10.2.2

10.3

10.4

IP-based virtual host

Name-based virtual host

Setting up virtual host

Addition of squirrelmail to virtual host

44

44

45

51

Chapter 11 Codes and configurations of project 52

11.1 Installation of Packages 52

11.2 Configurations 52

11.2.1

11.2.2

Static IP address assignment

DNS server

52

53

Page 6: Mail server report

11.2.3

11.2.4

Postfix configuration

Dovecot configuration

57

64

11.2.5

11.2.6

11.2.7

11.2.8

11.3

References

Adding users

Apache configuration

DHCP server configuration

Squirrelmail configuration

Login to mail server

65

65

68

69

69

71

Page 7: Mail server report

Certificate

Certified that this project/training report entitled “Mail Server” submitted

by Navjot Singh (1137836), student of ECE-8th SEM, Baba Farid College of

Engineering & Technology, Bathinda in the partial fulfillment of the

requirement for the award of Bachelors of Technology (Electronics and

Communication Engineering) Degree of PTU, Jalandhar, is a record of

students own study carried under my supervision & guidance.

This report has not been submitted to any other university or institution for

the award of any degree.

Mr. Anmol Chanana

Technical Head

Page 8: Mail server report

Abstarct

This system facilitates mailing among users of an Intranet. Now-a-days

organizations are growing fast and are increasing in size also. So these

organizations are divided into departments. In the fast growing world the

information is needed as fast as possible. This can be accomplished by

passing the information quickly. Quick passing of mails is not possible in

manual systems. This is because the information is passed through persons

of one department to another department. This leads to the inconsistency

and delay in delivering information. So we need a system which is both

quick and accurate. This can be achieved by developing a web-based &

Linux-based Intranet Mailing System.

EXISTING SYSTEM

Present System is manually providing services to employees of departments

of an Organization. Employees have to go departments to know some

particular information. Sometimes information is passed by manually

between departments. This manual system will take time to pass the

information and sometimes it causes loss of information also. There by

causing loss of employee time also. Thus the present system stated is time

taking, insecure and costly.

PROPOSED SYSTEM

As organization grows in size in terms of departments and functionalities, it

requires a quick and efficient system to achieve instant communication b/w

employees of same department or b/w departments. The proposed system

Page 9: Mail server report

“Mail Server” serves organization’s needs in a consistent and transparent

manner. It should cater the needs of information sharing. It allows the users

to exchange their views thru mails and send electronic files through

attachments. It should have all traditional things such as sent items, inbox,

drafts etc. The users are allows to send mails to multiple users using to, cc

and bcc too. Thus the system fulfil spontaneous needs of the organization.

SCOPE OF THE SYSTEM

The proposed system scope is limited to Intranet only. It can be enhanced to

be a global communication medium for multinational companies. We can

also implement internationalization to support user interface in

various/local languages.

Page 10: Mail server report

Acknowledgement

Way of excellence and discipline is the real spirit of achieving a goal.

I wouldn’t be able to complete this task without the encouragement,

motivation, cooperation and help provided to me by various personalities.

I express my foremost and my deepest gratitude to my dissertation

guide Er. Hardeep Singh, HOD E.C.E Department of BFCET Deon

(Bathinda), for his valuable guidance, support and motivation throughout

this work. He provided his technical knowledge, enthusiastic support &

encouragement & was of invaluable assistance in my work.

I am also thankful to all the staff members of the Electronics &

Communication Engineering Department and management of college for

their full cooperation and help. The technical guidance and constant

encouragement made it possible to tied over the numerous problems, which

so ever came up during the study.

The most important gratitude to, my parents who supported and encouraged

my work and constantly provided us with their love and their suggestions.

Navjot Singh (1137836)ECE-8th SEM

Page 11: Mail server report

List of Figures

2.1 IPv4 IP addressing 7

3.1

3.2

3.3

3.4

3.5

3.6

Ubuntu Installation step I

Ubuntu Installation step II

Ubuntu Installation step III

Ubuntu Installation step IV

Ubuntu Installation step V

Ubuntu Installation step VI

9

10

11

12

12

13

3.7 Ubuntu Installation step VII 14

3.8

7.1

7.2

7.3

10.1

10.2

10.3

10.4

11.1

11.2

11.3

11.4

11.5

11.6

11.7

11.8

11.9

11.10

11.11

11.12

11.13

Ubuntu Installation step VIII

Working of postfix

Component structure

Mail flow

Apache server

IP-based virtual host

Name-based virtual host

Output page

Bind9 restart output

Postfix configuration step I

Postfix configuration step II

Postfix configuration step III

Postfix configuration step IV

Postfix configuration step V

Postfix configuration step VI

Postfix configuration step VII

Postfix configuration step VIII

Postfix configuration step IX

Postfix configuration step X

Postfix configuration Output

Dovecot restart output

14

31

33

34

44

45

46

51

57

58

59

59

60

60

61

61

62

62

63

63

64

Page 12: Mail server report

11.14

11.15

11.16

Virtual host page

Login page

Inbox page

67

69

69

Page 13: Mail server report

Chapter 1. Introduction to mail server

1.1. Introduction

The mail server on Intranet is designed to provide a communication channel inside an

organization between different clients (Organization staff) on the network. A project

specific intranet uses a database server to store mails, information and the organizational

information such as user's details including the personal information. This flexible

approach allows geographically remote project teams to access timely, consistent and

accurate information without expensive typesetting, printing, distribution and mailing

charges.

Examples of mail server are Gmail, yahoo mail, hotmail etc.

In an organisation, users will likely access their mail remotely from their desktops. The

main purpose of mail server on intranet is to make communication possible between

different employees of company/organization. The user can access this mailing system

for sending the information to other users of the same organization. He she will also be

provided with login and logout services, service of checking into the mails through the

inbox, sending the mails using compose service, checking the sent mails list, creating and

deleting the folders in association to the user involved in the communication. User is also

provided with the flexibility of maintaining the address book in the mailing system

through which he can store the details of his contacts. Users of the Mail System are also

provided with the chance to change the password of his account through the options

service designed but change password service will be done at server computer. User will

be able to change password only through server computer as users/accounts are always

made on server computer.

This system is to be designed with user flexible screens through which user can navigate

through the mailing system and access the above services for the basic purpose of

communication.

The mail server works in conjunction with other programs to make up what is sometimes

referred to as a messaging system. A messaging system includes all the applications

necessary to keep e-mail moving as it should. When you send an e-mail message, your e-

mail program, such as Outlook, Thunderbird or Eudora, forwards the message to your

mail server, which in turn forwards it either to another mail server or to a holding area on

Page 14: Mail server report

the same server called a message store to be forwarded later. As a rule, the system

uses SMTP (Simple Mail Transfer Protocol) or ESMTP (extended SMTP) for sending e-

mail, and either POP3 (Post Office Protocol 3) or IMAP (Internet Message Access

Protocol) for receiving e-mail.

1.2. Requirements

1.2.1. Hardware Requirements

700 MHz processor (about Intel Celeron or better)

512 MB RAM (system memory)

5 GB of hard-drive space (or USB stick, memory card or external drive but see

LiveCD for an alternative approach)

VGA capable of 1024x768 screen resolution

Either a CD/DVD drive or a USB port for the installer media.

1.2.2. Software Requirements

Ubuntu 14.04 LTS Desktop operating system.

Bind 9

Postfix (MTA)

Dovecot (MDA)

Squirrelmail (Webmail)

Thunderbird (Mail client)

1.3. Methodology

Firstly, we need a system with ubuntu 14.04 LTS operating system installed on it and

internet connectivity for installing packages. The system on which this mailing server

will be installed that will be server computer and the all computers of users connected to

it will be served as clients.

All the user accounts will be created on server computer using commands of Ubuntu.

Every user will be provided with his/her mail account for their login purpose.

Then we have to study for terminologies and packages used for developing a mail server.

For developing mail server, we have to make a DNS i.e. DOMAIN NAME SYSTEM like

mail.example.net. To make DNS server, we have to use bind9 package.

Page 15: Mail server report

Webmail/squirrelmail permits you and your email users to view their email via their web

browser from anywhere in the network. So, to access e-mail account, we have to use

webmail/squirrelmail. To use webmail, we have to setup a MTA (Mail Transfer Agent)

i.e. Postfix, a MDA (Mail Delivery Agent) i.e. Dovecot and a web server like apache.

DHCP server has to make to automatically assign ip addresses to users’ computers and ip

address of server computer has to be made static as if it is dynamic then domain, DNS

will not work and to make it working, we have to change ip address in DNS every time

we start computer.

1.4. The features implemented in the project

User personal accounts, containing:

Personal address book

Stored e-mail accounts (POP3 accounts and sending identities)

Reading mail:

Read messages in any language – the message is automatically recoded into

Unicode

Plain text and HTML message content-type support

Multipart message support

Attached files extraction

Composing and sending messages:

Composition of a text message

Attachment of files to the message

Sending the message using preferred SMTP service with preferred identity

Replying and forwarding the messages.

Address book:

Address book editing – edit, add, delete contacts

Selecting the address directly into address fields from the address book.

Page 16: Mail server report

Chapter 2. Protocols used in mail server

Protocols are some set of rules which are to be followed while using network concepts.

There are some protocols which are to be used while building a mail server. These are:

2.1. IMAP

Internet Message Access Protocol (IMAP) is a protocol for e-mail retrieval and storage

developed by Mark Crispin in 1986 at Stanford University as an alternative to POP.

IMAP uses port 143, and IMAP over SSL (IMAPS) uses port 993. IMAP, unlike POP,

specifically allows multiple clients simultaneously connected to the same mailbox, and

through flags stored on the server, different clients accessing the same mailbox at the

same or different times can detect state changes made by other clients.

Internet Message Access Protocol (IMAP) servers let you work with e-mail messages

without downloading them to your computer first. You can preview, delete, and organize

messages directly on the e-mail server, and copies are stored on the server until you

choose to delete them. IMAP is commonly used for business e-mail accounts.

The Internet Message Access Protocol (commonly known as IMAP) is an Application

Layer Internet protocol that allows an e-mail client to access e-mail on a remote mail

server. The current version, IMAP version 4 revision 1 (IMAP4rev1), is defined by RFC

3501. An IMAP server typically listens on well-known port 143. IMAP

over SSL (IMAPS) is assigned well-known port number 993.

IMAP supports both on-line and off-line modes of operation. E-mail clients using IMAP

generally leave messages on the server until the user explicitly deletes them. This and

other characteristics of IMAP operation allow multiple clients to manage the same

mailbox. Most e-mail clients support IMAP in addition to Post Office Protocol (POP) to

retrieve messages; however, fewer e-mail services support IMAP. IMAP offers access to

the mail storage. Clients may store local copies of the messages, but these are considered

to be a temporary cache.

Incoming e-mail messages are sent to an e-mail server that stores messages in the

recipient's e-mail box. The user retrieves the messages with an e-mail client that uses one

of a number of e-mail retrieval protocols. Some clients and servers preferentially use

vendor-specific, proprietary protocols, but most support SMTP for sending e-mail and

Page 17: Mail server report

POP and IMAP for retrieving e-mail, allowing interoperability with other servers and

clients. For example, Microsoft's Outlook client uses MAPI, a Microsoft proprietary

protocol to communicate with a Microsoft Exchange Server. IBM's Notes client works in

a similar fashion when communicating with a Domino server. All of these products also

support POP, IMAP, and outgoing SMTP. Support for the Internet standard, protocols

allow many e-mail clients such as Pegasus Mail or Mozilla Thunderbird to access these

servers, and allows the clients to be used with other servers.

2.2. POP3

Post Office Protocol 3 (POP3) servers hold incoming e-mail messages until you check

your e-mail, at which point they're transferred to your computer. POP3 is the most

common account type for personal e-mail. Messages are typically deleted from the server

when you check your e-mail.

In computing, the Post Office Protocol (POP) is an application-layer Internet

standard protocol used by local e-mail clients to retrieve e-mail from a remote server over

a TCP/IP connection. POP has been developed through several versions, with version 3

(POP3) being the current standard.

Virtually all modern e-mail clients and servers support POP3, and it along

with IMAP (Internet Message Access Protocol) are the two most

prevalent Internet standard protocols for e-mail retrieval, with many webmail service

providers such as Gmail, Outlook.com and Yahoo! Mail also providing support for either

IMAP or POP3 to allow mail to be downloaded.

POP supports simple download-and-delete requirements for access to remote mailboxes

(termed maildrop in the POP RFC's). Although most POP clients have an option to leave

mail on server after download, e-mail clients using POP generally connect, retrieve all

messages, store them on the user's PC as new messages, delete them from the server, and

then disconnect. Other protocols, notably IMAP, (Internet Message Access Protocol)

provide more complete and complex remote access to typical mailbox operations. In the

late 1990s and early 2000s, fewer Internet Service Providers (ISPs) supported IMAP due

to the storage space that was required on the ISP's hardware. Contemporary e-mail clients

supported POP, then over time popular mail client software added IMAP support.

Page 18: Mail server report

A POP3 server listens on well-known port 110. Encrypted communication for POP3 is

either requested after protocol initiation, using the STLS command, if supported, or by

POP3S, which connects to the server using Transport Layer Security (TLS) or Secure

Sockets Layer (SSL) on well-known TCP port 995.

Available messages to the client are fixed when a POP session opens the maildrop, and

are identified by message-number local to that session or, optionally, by a unique

identifier assigned to the message by the POP server. This unique identifier is permanent

and unique to the maildrop and allows a client to access the same message in different

POP sessions. Mail is retrieved and marked for deletion by message-number. When the

client exits the session, the mail marked for deletion is removed from the maildrop.

2.3. SMTP

Simple Mail Transfer Protocol (SMTP) is an Internet standard for electronic mail (e-mail)

transmission. First defined by RFC 821 in 1982, it was last updated in 2008 with the

Extended SMTP additions by RFC 5321 - which is the protocol in widespread use

today. SMTP by default uses TCP port 25.

Simple Mail Transfer Protocol (SMTP) servers handle the sending of your e-mail

messages to the Internet. The SMTP server handles outgoing e-mail, and is used in

conjunction with a POP3 or IMAP incoming e-mail server.

SMTP by default uses TCP port 25. The protocol for mail submission is the same, but

uses port 587. SMTP connections secured bySSL, known as SMTPS, default to port 465

(nonstandard, but sometimes used for legacy reasons).

Although electronic mail servers and other mail transfer agents use SMTP to send and

receive mail messages, user-level client mail applications typically use SMTP only for

sending messages to a mail server for relaying. For receiving messages, client

applications usually use either POP3 or IMAP.

Although proprietary systems (such as Microsoft Exchange and Lotus Notes/Domino)

and webmail systems (such as Hotmail, Gmail and Yahoo! Mail) use their own non-

standard protocols to access mail box accounts on their own mail servers, all use SMTP

when sending or receiving email from outside their own systems.

Page 19: Mail server report

2.4. IP

An Internet Protocol address (IP address) is a numerical label assigned to each device

(e.g., computer, printer) participating in a computer network that uses the Internet

Protocol for communication. An IP address serves two principal functions: host or

network interface identification and location addressing. Its role has been characterized as

follows: "A name indicates what we seek. An address indicates where it is. A route

indicates how to get there.”

The designers of the Internet Protocol defined an IP address as a 32-bit number and this

system, known as Internet Protocol Version 4 (IPv4), is still in use today. However,

because of the growth of the Internet and the predicted depletion of available addresses, a

new version of IP (IPv6), using 128 bits for the address, was developed in 1995.

IP addresses are usually written and displayed in human-readable notations, such as

172.16.254.1 (IPv4), and 2001:db8:0:1234:0:567:8:1 (IPv6).

In IPv4 an address consists of 32 bits which limits the address space to 4294967296 (232)

possible unique addresses. IPv4 reserves some addresses for special purposes such

as private networks (~18 million addresses) or multicast addresses (~270 million

addresses).

IPv4 addresses are canonically represented in dot-decimal notation, which consists of

four decimal numbers, each ranging from 0 to 255, separated by dots, e.g., 172.16.254.1.

Each part represents a group of 8 bits (octet) of the address. In some cases of technical

writing, IPv4 addresses may be presented in various hexadecimal, octal,

or binary representations.

Figure 2.1 IPv4 IP Addressing

Page 20: Mail server report

Chapter 3. How to install Ubuntu

3.1. What is Ubuntu

Ubuntu is an open source software platform that runs everywhere from the

smartphone, the tablet and the PC to the server and the cloud.

We can Download Ubuntu 14.04 from Ubuntu.com. The file size is just under a

Gigabyte and may take anything from a few minutes to a few hours, depending

primarily on your connection speed. Downloads will be faster after the first day of

release (as less people download).

Should we use 32 or 64 Bit?

A good general rule of thumb is if your computer has 4 GB of RAM or more, go for

64bit. Any less and you should use 32bit. You might need to know how to find out

how much ram you have, if you don't already know, in Ubuntu, Windows, or OS X.

You might want to take a look at the pros and cons. Basically, 64bit is faster.

3.2. Installation of Ubuntu

To install Ubuntu, you must first put the installation image onto some form of media.

Your choices are DVD or USB (the image has grown too large for most CDs). Most

computers can boot from both, unless they lack a disc drive, in which case you can

skip the next paragraph, as you'll be using a USB then.

For DVDs, RW means you can write new data again and again, whereas R means once

the Ubuntu installation image is on there, there it will stay. It can be used again, but

never written to again. As for + or -, + means a computer can treat it like a USB drive,

whereas - is a little older and won't. Either + or -, and R or RW will work for this.

USB sticks need to be at least 2GB in size, and be prepared for it to be formatted

(everything deleted).

Once you've put the image you downloaded onto a DVD or USB, you will need to shut

down your computer. This may be a good time to print this page, or just read through

and make notes, if you're planning to install on this computer.

Once fully shutdown, Turn your computer back on, tapping the Setup key to select a

boot device when your screen shows the name of the manufacturer. This key is usually a

Function key (F1 to F12), or something like ESC. It will be shown on the BIOS, the

Page 21: Mail server report

screen displaying the manufacturer’s logo, usually along the bottom labeled Setup or

Boot Settings. You can then use the arrow keys, finally hitting enter, to select either

USB or Disc Drive.

Steps to install Ubuntu:

I. Click Install

Once Ubuntu has booted, you will be presented with a screen that looks like this.

Click Install Ubuntu to install. You can open the installer again later if you choose to

try it out, but remember it will be far slower running from a Disc/USB than had you

installed it, and nothing you do will actually be saved.

Figure 3.1 Ubuntu Installation STEP I

II. Check both Boxes

We recommend checking both boxes, but if you don't want to install all updates while

installing, or don't want to play MP3 files (music), then you can leave the relevant

box(es) unchecked.

If you don't have at least 4.5GB of available drive space, then you can't continue. If

you're not plugged in, then plug in before continuing. If you're not connected to the

internet, then you'll be prompted to connect when you click continue. You can do it

now using the icon to the left of the sound menu to connect. Mine shows two arrows,

Page 22: Mail server report

as I'm plugged in, disconnected it looks different and a little change again if using Wi

Fi. You can continue without connecting, but you won't be able to get updates, or any

language packs you may require.

Figure 3.2 Ubuntu Installation STEP II

III. Choose How to Install

Yours will probably look a little different to mine here. My hard drive doesn't have

anything on it yet, so i can choose either to use the whole disk, or specify partitions

manually (surprisingly easy stuff). Yours may have a slightly different first option, and

one or two extra.

It may say Delete Windows and Install Ubuntu and Shrink Windows and Install

Ubuntu Alongside.

Choosing to install alongside will mean you are presented with a menu with the option

to choose which operating system with the arrow keys and enter every time you turn

on your computer.

Page 23: Mail server report

Figure 3.3 Ubuntu Installation STEP III

Warning

In this step you could potentially erase your entire computer. This means all your

programs, documents, photos, videos, and everything else could be lost. Be careful,

especially if you plan to remove Windows or OS X and use only Ubuntu, or if you are

installing to a USB Drive. Make sure you understand where it is being installed and how

it will affect your data. This is the last point at which you can safely cancel the install

without potential data loss. It is always a good idea to make backups. If you have not

done so already, backup your data.

IV. Confirm your Choice

After clicking continue, you may be presented with a confirmation screen, much like

this, to confirm your choices.

Click Install Now to begin installing.

You'll be asked a few more questions in a second about where you are, what your name

is, and how you want your computer set up. These are for time settings, user names, and

home folders.

Page 24: Mail server report

Figure 3.4 Ubuntu Installation STEP IV

V. Choose your Location

Now you get to choose your location by dropping a pin on this nifty looking map. This

is to select your time zone and apply any regional adjustments.

Figure 3.5 Ubuntu Installation STEP V

VI. Choose your Keyboard Layout:

Page 25: Mail server report

This is probably the most technical step in the installation, made a lot simpler by

the Detect Keyboard Layout. Just click that and follow the instructions on screen.

Figure 3.6 Ubuntu Installation STEP VI

VII. Set a Username and Password

Now you get to enter your name, the name you want your computer to be (not really

important), your username (again, you won't see this much, but it can't have capitals or

spaces, best leave as it is made from your real name), a password (if you want, then

confirm it, and keep it strong), whether or not to log in automatically, and whether or

not to encrypt your home folder (which is where documents, music, and video folder

can be found, among others).

I would not recommend encrypting your home folder, as this usually complicates

things for you as much as any potential trespassers. It can lead to complications with

keyrings, forgotten passwords, and bad data recovery. Only use if it is a company

policy, or you thoroughly understand what you are doing. Also, only set your password

to nothing if you are unlikely to ever want one, otherwise yet more compilations with

keyrings and automatic unlocking-on-login can arise.

Page 26: Mail server report

Figure 3.7 Ubuntu Installation STEP VII

VIII. Sit Back and Relax

Sit back and enjoy a little slideshow about Ubuntu, all the free, full-version software

you've got, and just how great it is to have installed Ubuntu 14.04 LTS.

You can rest easy in the knowledge that your computer is faster, safer, and simpler to

use, now it's running a free open-source system.

Check out askubuntu.com if you need any further help.

Figure 3.7 Ubuntu Installation STEP VIII

Page 27: Mail server report

Chapter 4. IP addressing

4.1. What is IP Address?

IP address is short for Internet Protocol (IP) address.

An IP address is an identifier for a computer or device on a TCP/IP network. Networks

using the TCP/IP protocol route messages based on the IP address of the destination.

4.2. Format of an IP Address

The format of an IP address is a 32-bit numeric address written as four numbers separated

by periods. Each number can be zero to 255. For example, 1.160.10.240 could be an IP

address.

Within an isolated network, you can assign IP addresses at random as long as each one is

unique. However, connecting a private network to the Internet requires using registered

IP addresses (called Internet addresses) to avoid duplicates.

An IP address can be static or dynamic. A static IP address will never change and it is a

permanent Internet address. A dynamic IP address is a temporary address that is assigned

each time a computer or device accesses the Internet.

The four numbers in an IP address are used in different ways to identify a particular

network and a host on that network. Four regional Internet registries -- ARIN, RIPE

NCC, LACNIC and APNIC-- assign Internet addresses from the following three classes:

Class A - supports 16 million hosts on each of 126 networks

Class B - supports 65,000 hosts on each of 16,000 networks

Class C - supports 254 hosts on each of 2 million networks

The following section describes the process of configuring your systems IP address and

default gateway needed for communicating on a local area network and the Internet.

These are done with the help of commands in Terminal.

4.3. Types of IP Addressing with steps

4.3.1 Temporary IP Address Assignment

For temporary network configurations, you can use standard commands such as ip,

ifconfig and route, which are also found on most other GNU/Linux operating systems.

These commands allow you to configure settings which take effect immediately, however

Page 28: Mail server report

they are not persistent and will be lost after a reboot.

To temporarily configure an IP address, you can use the ifconfig command in the

following manner.

Just modify the IP address and subnet mask to match your network requirements.

sudo ifconfig eth0 10.0.0.100 netmask 255.255.255.0

To verify the IP address configuration of eth0, you can use the ifconfig command in the

following manner.

ifconfig eth0

Then you will get output in terminal like as:

eth0 Link encap:Ethernet

HWaddr 00:15:c5:4a:16:5a

Inet addr:10.0.0.100 Bcast:10.0.0.255 Mask:255.255.255.0

inet6 addr: fe80::215:c5ff:fe4a:165a/64 Scope:Link

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

RX packets:466475604 errors:0 dropped:0 overruns:0 frame:0

TX packets:403172654 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:2574778386 (2.5 GB)

TX bytes:1618367329 (1.6 GB)

To configure a default gateway, you can use the route command in the following manner.

Modify the default gateway address to match your network requirements.

sudo route add default gw 10.0.0.1 eth0

To verify your default gateway configuration, you can use the route command in the

following manner.

route -n

Then you will get output in terminal like as:

Kernel IP routing table

Destination Gateway Genmask Flags Metric Ref Use Iface

10.0.0.0 0.0.0.0 255.255.255.0 U 1 0 0 eth0

0.0.0.0 255.255.255.0 0.0.0.0 UG 1 0 0 eth0

Page 29: Mail server report

If you require DNS for your temporary network configuration, you can add DNS server

IP addresses in the file /etc/resolv.conf . The example below shows how to enter two

DNS servers to /etc/resolv.conf, which should be changed to servers appropriate for your

network. A more lengthy

description of DNS client configuration is in a following section.

nameserver 8.8.8.8

nameserver 8.8.4.4

If you no longer need this configuration and wish to purge all IP configuration from an

interface, you can use the ip command with the flush option as shown below:

ip addr flush eth0

Flushing the IP configuration using the ip command does not clear the contents of

/etc/resolv.conf . You must remove or modify those entries manually.

4.3.2 Dynamic IP Address Assignment (DHCP Client)

To configure your server to use DHCP for dynamic address assignment, add the dhcp

method to the inet address family statement for the appropriate interface in the file

/etc/network/interfaces . The example below assumes you are configuring your first

Ethernet interface identified as eth0.

auto eth0

iface eth0 inet dhcp

By adding an interface configuration as shown above, you can manually enable the

interface through the ifup command which initiates the DHCP process via dhclient.

sudo ifup eth0

To manually disable the interface, you can use the ifdown command, which in turn will

initiate the DHCP release process and shut down the interface.

sudo ifdown eth0

4.2.3. Static IP Address Assignment

To configure your system to use a static IP address assignment, add the static method to

the inet address family statement for the appropriate interface in the file

/etc/network/interfaces . The example below assumes you are configuring your first

Page 30: Mail server report

Ethernet interface identified as eth0. Change the address, netmask, and gateway values to

meet the requirements of your network.

auto eth0

iface eth0 inet static

address 192.168.1.5

netmask 255.255.255.0

gateway 192.168.1.1

By adding an interface configuration as shown above, you can manually enable the

interface through the ifup command.

sudo ifup eth0

To manually disable the interface, you can use the ifdown command.

sudo ifdown eth0

Chapter 5. DNS Server

5.1. Overview

DNS is usually implemented using one or more centralized servers that are authoritative

for certain domains. When a client host requests information from a nameserver, it

Page 31: Mail server report

usually connects to port 53. The nameserver then attempts to resolve the name requested.

If it does not have an authoritative answer, or does not already have the answer cached

from an earlier query, it queries other nameservers, called root nameservers, to determine

which nameservers are authoritative for the name in question, and then queries them to

get the requested name.

Domain Name Service (DNS) is an Internet service that maps IP addresses and fully

qualified domain names (FQDN) to one another. In this way, DNS alleviates the need to

remember IP addresses.

Computers that run DNS are called name servers. Ubuntu ships with BIND (Berkley

Internet Naming Daemon), the most common program used for maintaining a name

server on Linux.

Domain name system servers match domain names like google.com to their associated IP

addresses — 173.194.39.78 in the case of google.com. When you type google.com into

your web browser’s address bar, your computer contacts your current DNS server and

asks what IP address is associated with google.com. Your computer then connects to the

IP address and displays “google.com” in your web browser – the connection to

173.194.39.78 happens behind the scenes.

The DNS servers you use are likely provided by your Internet service provider (“ISP”). If

you’re behind a router, your computer is likely using your router as your DNS server, but

the router is likely forwarding requests to your Internet service provider’s DNS servers.

For example:- If I am having my domain mail.mukul.net and that domain is registered in

DNS server 192.168.1.5(say). If I want to access this domain/URL from other PC

connected in LAN, then I have to put192.168.1.5 address in DNS server column of that

PC so that mail.mukul.net can be resolved from there otherwise we can’t get located to

that URL.

5.2. BIND as a nameserver

BIND is a package for Linux. In Ubuntu, it’s version used is bind9. BIND consists of a

set of DNS-related programs. It contains a nameserver called bind9.BIND is acronym for

(Berkeley Internet Name Domain), the DNS server included in Linux. It focuses on the

Page 32: Mail server report

structure of its configuration files, and describes how to administer it both locally and

remotely.

5.3. Installation of Bind package

At a terminal prompt, enter the following command to install dns:

sudo apt-get install bind9

A very useful package for testing and troubleshooting DNS issues is the dnsutils package.

Very often these tools will be installed already, but to check and/or install dnsutils enter

the following:

sudo apt-get install dnsutils

5.4. Configurations

There are many ways to configure BIND9. Some of the most common configurations are

a caching nameserver, primary master, and as a secondary master.

• When configured as a caching nameserver BIND9 will find the answer to name queries

and

remember the answer when the domain is queried again.

• As a primary master server BIND9 reads the data for a zone from a file on it's host and

is

authoritative for that zone.

• In a secondary master configuration BIND9 gets the zone data from another nameserver

authoritative for the zone.

5.4.1. Overview of configurations

The DNS configuration files are stored in the /etc/bind directory. The primary

configuration file is /etc/bind/named.conf.

The include line specifies the filename which contains the DNS options. The directory

line in the /etc/bind/named.conf.options file tells DNS where to look for files. All files

BIND uses will be

relative to this directory.

The file named /etc/bind/db.root describes the root nameservers in the world. The servers

change over time, so the /etc/bind/db.root file must be maintained now and then. This is

usually done as updates to the bind9 package. The zone section defines a master server,

and it is stored in a file mentioned in the file option.

Page 33: Mail server report

It is possible to configure the same server to be a caching name server, primary master,

and secondary master. A server can be the Start of Authority (SOA) for one zone, while

providing secondary service for another zone. All the while providing caching services

for hosts on the local LAN.

5.4.2. Caching Nameserver

The default configuration is setup to act as a caching server. All that is required is simply

adding the IP Addresses of your ISP's DNS servers. Simply uncomment and edit the

following in /etc/bind/ named.conf.options:

forwarders {

1.2.3.4;

5.6.7.8;

};

Replace 1.2.3.4 and 5.6.7.8 with the IP Addresses of actual nameservers.

Now restart the DNS server, to enable the new configuration. From a terminal prompt:

sudo service bind9 restart

5.4.3. Primary Nameserver

In this section BIND9 will be configured as the Primary Master for the domain

example.com. Simply replace example.com with your FQDN (Fully Qualified Domain

Name).

1. Forward Zone File

To add a DNS zone to BIND9, turning BIND9 into a Primary Master server, the first step

is to edit /etc/bind/named.conf.local:

zone "example.com" {

type master;

file "/etc/bind/db.example.com";

};

Now use an existing zone file as a template to create the /etc/bind/db.example.com file:

sudo cp /etc/bind/db.local /etc/bind/db.example.com

Edit the new zone file /etc/bind/db.example.com change localhost. to the FQDN of your

Page 34: Mail server report

server, leaving the additional "." at the end. Change 127.0.0.1 to the nameserver's IP

Address and

root.localhost to a valid email address, but with a "." instead of the usual "@" symbol,

again leaving the "." at the end. Change the comment to indicate the domain that this file

is for.

Create an A record for the base domain, example.com. Also, create an A record for

ns.example.com,

the name server in this example:

;

; BIND data file for example.com

;

$TTL 604800

@ IN SOA example.com. root.example.com. (

2 ; Serial

604800 ; Refresh

86400 ; Retry

2419200 ; Expire

604800 ) ; Negative Cache TTL

IN A 192.168.1.10

;

@ IN NS ns.example.com.

@ IN A 192.168.1.10

@ IN AAAA ::1

ns IN A 192.168.1.10

You must increment the Serial Number every time you make changes to the zone file. If

you make multiple changes before restarting BIND9, simply increment the Serial once.

Now, you can add DNS records to the bottom of the zone file.

Many admins like to use the last date edited as the serial of a zone, such as 2012010100

which is yyyymmddss (where ss is the Serial Number).

Page 35: Mail server report

Once you have made changes to the zone file BIND9 needs to be restarted for the

changes to take effect:

sudo service bind9 restart

2. Reverse Zone File

Now that the zone is setup and resolving names to IP Adresses a Reverse zone is also

required. A

Reverse zone allows DNS to resolve an address to a name.

Edit /etc/bind/named.conf.local and add the following:

zone "1.168.192.in-addr.arpa" {

type master;

file "/etc/bind/db.192";

};

Replace 1.168.192 with the first three octets of whatever network you are using. Also,

name the zone file /etc/bind/db.192 appropriately. It should match the first octet of your

network.

Now create the /etc/bind/db.192 file:

sudo cp /etc/bind/db.127 /etc/bind/db.192

Next edit /etc/bind/db.192 changing the basically the same options as

/etc/bind/db.example.com:

;

; BIND reverse data file for local 192.168.1.XXX net

;

$TTL 604800

@ IN SOA ns.example.com. root.example.com. (

2 ; Serial

604800 ; Refresh

86400 ; Retry

2419200 ; Expire

604800 ) ; Negative Cache TTL

;

Page 36: Mail server report

@ IN NS ns.

10 IN PTR ns.example.com.

The Serial Number in the Reverse zone needs to be incremented on each change as well.

For each A record you configure in /etc/bind/db.example.com, that is for a different

address, you need to create a PTR record in /etc/bind/db.192.

After creating the reverse zone file restart BIND9:

sudo service bind9 restart

5.4.4. Secondary Nameserver

Once a Primary Master has been configured a Secondary Master is needed in order to

maintain the availability of the domain should the Primary become unavailable.

First, on the Primary Master server, the zone transfer needs to be allowed. Add the allow-

transfer option to the example Forward and Reverse zone definitions in

/etc/bind/named.conf.local:

zone "example.com" {

type master;

file "/etc/bind/db.example.com";

allow-transfer { 192.168.1.11; };

};

zone "1.168.192.in-addr.arpa" {

type master;

file "/etc/bind/db.192";

allow-transfer { 192.168.1.11; }; };

Replace 192.168.1.11 with the IP Address of your Secondary nameserver.

Restart BIND9 on the Primary Master:

sudo service bind9 restart

Next, on the Secondary Master, install the bind9 package the same way as on the

Primary. Then edit the /etc/bind/named.conf.local and add the following declarations for

the Forward and Reverse zones:

zone "example.com" {

type slave;

Page 37: Mail server report

file "db.example.com";

};

zone "1.168.192.in-addr.arpa" {

type slave;

file "db.192";

masters { 192.168.1.10; };

};

Replace 192.168.1.10 with the IP Address of your Primary nameserver.

Restart BIND9 on the Secondary Master:

sudo service bind9 restart

Note: A zone is only transferred if the Serial Number on the Primary is larger than the

one on the Secondary. If you want to have your Primary Master DNS notifying

Secondary

DNS Servers of zone changes, you can add also-notify { ipaddress; }; in to /etc/bind/

named.conf.local as shown in the example below:

zone "example.com" {

type master;

file "/etc/bind/db.example.com";

allow-transfer { 192.168.1.11; };

also-notify { 192.168.1.11; };

};

zone "1.168.192.in-addr.arpa" {

type master;

file "/etc/bind/db.192";

allow-transfer { 192.168.1.11; };

also-notify { 192.168.1.11; };

};

5.5. Common Record Types

This section covers some of the most common DNS record types.

• A record: This record maps an IP Address to a hostname.

Page 38: Mail server report

www IN A 192.168.1.12

• CNAME record: Used to create an alias to an existing A record. You cannot create a

CNAME

record pointing to another CNAME record.

web IN CNAME www

• MX record: Used to define where email should be sent to. Must point to an A record,

not a CNAME.

IN MX 1 mail.example.com.

mail IN A 192.168.1.13

• NS record: Used to define which servers serve copies of a zone. It must point to an A

record, not a CNAME. This is where Primary and Secondary servers are defined.

IN NS ns.example.com.

IN NS ns2.example.com.

ns IN A 192.168.1.10

ns2 IN A 192.168.1.11

5.6. Testing

5.6.1. resolv.conf file

The first step in testing BIND9 is to add the nameserver's IP Address to a hosts resolver.

The Primary nameserver should be configured as well as another host to double check

things. Simply edit /etc/resolv.conf and add the following:

nameserver 192.168.1.10

nameserver 192.168.1.11

You should also add the IP Address of the Secondary nameserver in case the Primary

becomes unavailable.

5.6.2. hosts file

The entries of hosts are must to be provided in the /etc/hosts file so that dns server can

resolve the host from that ip. It is a way of aliasing the IPs of those servers.For example:

192.168.1.10 example.com

5.6.3. dig

Page 39: Mail server report

If you installed the dnsutils package you can test your setup using the DNS lookup utility

dig:

• After installing BIND9 use dig against the loopback interface to make sure it is listening

on port 53.

From a terminal prompt:

dig -x 127.0.0.1

You should see lines similar to the following in the command output:

;; Query time: 1 msec

;; SERVER: 192.168.1.10#53(192.168.1.10)

• If you have configured BIND9 as a Caching nameserver "dig" an outside domain to

check the

query time:

dig ubuntu.com

Note the query time toward the end of the command output:

;; Query time: 49 msec

After a second dig there should be improvement:

;; Query time: 1 msec

5.6.4. ping

Now to demonstrate how applications make use of DNS to resolve a host name use the

ping utility to send an ICMP echo request. From a terminal prompt enter:

ping example.com

This tests if the nameserver can resolve the name ns.example.com to an IP Address. The

command output should resemble:

PING ns.example.com (192.168.1.10) 56(84) bytes of data.

64 bytes from 192.168.1.10: icmp_seq=1 ttl=64 time=0.800 ms

64 bytes from 192.168.1.10: icmp_seq=2 ttl=64 time=0.813 ms

Page 40: Mail server report

Chapter 6. Dynamic Host Configuration Protocol

6.1. DHCP

The Dynamic Host Configuration Protocol (DHCP) is a network service that enables host

computers to be automatically assigned settings from a server as opposed to manually

configuring each network host. Computers configured to be DHCP clients have no

control over the settings they receive from the DHCP server, and the configuration is

transparent to the computer's user.

The most common settings provided by a DHCP server to DHCP clients include:

• IP address and netmask

• IP address of the default-gateway to use

• IP addresses of the DNS servers to use

However, a DHCP server can also supply configuration properties such as:

• Host Name

• Domain Name

• Time Server

• Print Server

The advantage of using DHCP is that changes to the network, for example a change in

the address of the DNS server, need only be changed at the DHCP server, and all network

hosts will be reconfigured the next time their DHCP clients poll the DHCP server. As an

added advantage, it is also easier to integrate new computers into the network, as there is

no need to check for the availability of an IP address. Conflicts in IP address allocation

are also reduced.

A DHCP server can provide configuration settings using the following methods:

6.1.1. Manual allocation (MAC address)

This method entails using DHCP to identify the unique hardware address of each network

card connected to the network and then continually supplying a constant configuration

each time the DHCP client makes a request to the DHCP server using that network

device. This ensures that a particular address is assigned automatically to that network

card, based on it's MAC address called Dynamic allocation (address pool).

In this method, the DHCP server will assign an IP address from a pool of addresses

(sometimes also called a range or scope) for a period of time or lease, that is configured

Page 41: Mail server report

on the server or until the client informs the server that it doesn't need the address

anymore. This way, the clients will be receiving their configuration properties

dynamically and on a "first come, first served" basis. When a DHCP client is no longer

on the network for a specified period, the configuration is expired and released back to

the address pool for use by other DHCP Clients. This way, an address and be leased or

used for a period of time. After this period, the client has to renegotiate the lease with the

server to maintain use of the address.

6.1.2. Automatic allocation

Using this method, the DHCP automatically assigns an IP address permanently to a

device,

selecting it from a pool of available addresses. Usually DHCP is used to assign a

temporary

address to a client, but a DHCP server can allow an infinite lease time.

The last two methods can be considered “automatic” because in each case the DHCP

server assigns an address with no extra intervention needed. The only difference between

them is in how long the IP address is leased, in other words whether a client's address

varies over time. Ubuntu is shipped with both DHCP server and client. The server is

dhcpd (dynamic host configuration protocol daemon).

The client provided with Ubuntu is dhclient and should be installed on all computers

required to be automatically configured. Both programs are easy to install and configure

and will be automatically started at system boot.

6.2. Installation

At a terminal prompt, enter the following command to install dhcpd:

sudo apt-get install isc-dhcp-server

You will probably need to change the default configuration by editing

/etc/dhcp/dhcpd.conf to suit your needs and particular configuration.

You also may need to edit /etc/default/isc-dhcp-server to specify the interfaces dhcpd

should listen to.

NOTE: dhcpd's messages are being sent to syslog. Look there for diagnostics messages.

Page 42: Mail server report

6.3. Configurations

The error message the installation ends with might be a little confusing, but the following

steps will help you configure the service:

Most commonly, what you want to do is assign an IP address randomly. This can be done

with

settings as follows:

# minimal sample /etc/dhcp/dhcpd.conf

default-lease-time 600;

max-lease-time 7200;

subnet 192.168.1.0 netmask 255.255.255.0 {

range 192.168.1.150 192.168.1.200;

option routers 192.168.1.254;

option domain-name-servers 192.168.1.5;

option domain-name "mukul.net";

}

This will result in the DHCP server giving clients an IP address from the range

192.168.1.150-192.168.1.200. It will lease an IP address for 600 seconds if the client

doesn't ask for a specific time frame. Otherwise the maximum (allowed) lease will be

7200 seconds. The server will also advise the client to use 192.168.1.254 as the default-

gateway and 192.168.1.5 as it’s DNS servers.

After changing the config file you have to restart the dhcpd:

sudo /etc/init.d/isc-dhcp-server restart

Page 43: Mail server report

Chapter 7. Mail Transfer Agent

7.1. Overview

In other words, it's a mail server not a mail client like Thunderbird, Evolution, Outlook,

Eudora, or a web-based email service like Yahoo, Gmail, Hotmail, Earthlink, Comcast,

SBCGlobal.net, ATT.net etc.... If you worked for a company named Acme and owned

acme.com, you could provide your employees with email addresses @acme.com.

Employees could send and receive email through your computer, but not without your

computer running all the time. If all your email addresses are at a domain (@gmail.com,

@yahoo.com) you do not own (you don't own Google) or do not host (acme.com) then

you do not need this at all. 

Postfix is the default Mail Transfer Agent (MTA) for Ubuntu. It is in Ubuntu's main

repository, which means that it receives security updates. This guide explains how to

install and configure postfix and set it up as an SMTP server using a secure connection.

In our setup, Postfix sends and receives mail from Internet and stores them in the user

mailboxes while clients on the Internet can retrieve their mails via Courier IMAP or

POP3. The user authentication is done by Courier Authdaemon. The following diagram

shows this process.

Figure 6.1 Working of postfix

Page 44: Mail server report

7.2. Installation

In order to install Postfix with SMTP-AUTH and TLS, first install the postfix package

from the Main repository using your favorite package manager. For example:

sudo apt-get install postfix

Simply accept the defaults when the installation process asks questions. The

configuration will be done in greater detail in the next stage.

7.3. Configurations

From a terminal prompt:

sudo dpkg-reconfigure postfix

Insert the following details when asked (replacing server1.example.com with your

domain name if you have one):

1. General type of mail configuration: Internet Site

2. NONE doesn't appear to be requested in current config

3. System mail name: example.com

4. Root and postmaster mail recipient: <admin_user_name>

5. Other destinations for mail: server1.example.com, example.com,

localhost.example.com, localhost

6. Force synchronous updates on mail queue?: No

7. Local networks: 127.0.0.0/8

8. Yes doesn't appear to be requested in current config

9. Mailbox size limit (bytes): 0

10. Local address extension character: +

11. Internet protocols to use: all

Now is a good time to decide which mailbox format you want to use. By default Postifx

will use mbox for the mailbox format. Rather than editing the configuration file directly,

you can use the postconf command to configure all postfix parameters. The configuration

parameters will be stored in /etc/postfix/main.cf file. Later if you wish to re-configure a

particular parameter, you can either run the command or change it manually in the file.

To configure the mailbox format for Maildir:

Page 45: Mail server report

sudo postconf -e 'home_mailbox = Maildir/'

You may need to issue this as well:

sudo postconf -e 'mailbox_command ='

7.4. Components

7.4.1. Component structure

The following figure shows the main Postfix system components, and the main

information flows between them.

Figure 7.2 Component structure

1. Yellow ellipsoids are mail programs.

2. Yellow boxes are mail queues or files.

3. Blue boxes are lookup tables.

4. Programs in the large box run under control by the Postfix resident master daemon.

5. Data in the large box is property of the Postfix mail system.

6.4.2. Receiving a mail

When a message enters the Postfix mail system, the first stop is the incoming queue. The

figure below shows the main components that are involved with new mail.

Page 46: Mail server report

Figure 7.3 Mail flow

1. Mail is posted locally. The Postfix sendmail program invokes the

privileged postdrop program which deposits the message into the maildrop

directory, where the message is picked up by the pickup daemon. This daemon

does some sanity checks, in order to protect the rest of the Postfix system.

2. Mail comes in via the network. The Postfix SMTP server receives the message and

does some sanity checks, in order to protect the rest of the Postfix system.

3. Mail is generated internally by the Postfix system itself, in order to return

undeliverable mail to the sender. The bounce or defer daemon brings the bad news.

4. Mail is forwarded by the local delivery agent, either via an entry in the system-

wide alias database, or via an entry in a per-user .forward file. This is indicated

with the unlabeled arrow.

5. Mail is generated internally by the Postfix system itself, in order to notify the

postmaster of a problem (this path is also indicated with the unlabeled arrow).The

Postfix system can be configured to notify the postmaster of SMTP protocol

problems, UCE policy violations, and so on.

6. The cleanup daemon implements the final processing stage for new mail. It adds

missing From: and other message headers, arranges for address rewriting to the

standard [email protected] form, and optionally extracts recipient

addresses from message headers. Thecleanup daemon inserts the result as a single

queue file into the incoming queue, and notifies the queue manager of the arrival of

new mail. The cleanup daemon can be configured to transform addresses on the

basis of canonical and virtual table lookups.

Page 47: Mail server report

Chapter 8. Mail Delivery Agent

8.1. Overview

A mail delivery agent or message delivery agent (MDA) is a computer software

component that is responsible for the delivery of e-mailmessages to a local recipient's

mailbox. Also called an LDA, or localdelivery agent.

8.2. Dovecot as MDA

Dovecot is a Mail Delivery Agent, written with security primarily in mind. It supports the

major mailbox formats: mbox or Maildir. It is a simple and easy to install MDA. This

guide explains how to set it up as an IMAP or POP3 server.

To configure Dovecot to use LDAP for user authentication see DovecotLDAP

NOTE: Dovecot will NOT work in an encrypted directory/folder. Dovecot would just

complain about permissions and won’t work. One answer is to create a 2nd user account

that has an unencrypted home directory. We have not tested this solution on a separate

home partition, but most probably the outcome would be the same.

Installation

The installation is extremely simple, just install the following packages:

1. dovecot-imapd

2. dovecot-pop3d

For example, using apt-get:

sudo apt-get install dovecot-imapd dovecot-pop3d

8.3. Configurations

To configure dovecot, you edit the file /etc/dovecot/dovecot.conf. There are a couple of

choices which you need to make.

8.3.1. Choice of protocols

The choice is broadly between two protocols: IMAP and POP3. POP3 is useful when e-

mail is checked from only one computer. It is best for people who download their email

and then work off-line. IMAP is the better choice when you would like to check your

mail from multiple computers (at work and home, for example). IMAP has the added

benefit of accessing folders on the server, allowing you to organize your e-mail, and

Page 48: Mail server report

access it from anywhere. For more information, see the wikipedia articles

on POP3 and IMAP. IMAPS and POP3S are more secure than the simple IMAP and

POP3 because they use TLS encryption to connect.

Once you have chosen, amend the following line in the file /etc/dovecot/dovecot.conf:

protocols = pop3 pop3s imap imaps

This enables those protocols when dovecot is started. Note: if you like, you can enable all

the above protocols, or you can choose to enable just one or any number of them. In

addition, add the following line in the "protocol pop3" section in

the /etc/dovecot/dovecot.conf:

pop3_uidl_format = %08Xu%08Xv

8.3.2. Choice of mailboxes

Dovecot currently supports maildir and mbox formats. They are the most commonly used

mailbox formats. They both have their own benefits, discussed here.

If you have trouble figuring out what you are using, it's most likely mbox. Maildir mails

are almost always stored in ~/Maildir/ directory, which

contains cur/, new/ and tmp/ subdirectories. In maildir each mail is stored in a separate

file, while with the mbox format one file contains all mails in the mailbox. Files

in /var/mail/ are nearly always mbox files, one for each user.

Maildir is better overall because it is more scalable and can't get corrupted so easily. So,

if you have trouble figuring out what you should be using and have a choice, choose

maildir.

To configure Dovecot for your mailbox format use (for maildir):

mail_location = maildir:~/Maildir

or, for mbox;

mail_location = mbox:~/mail:INBOX=/var/mail/%u

Note: You will also need to configure your MTA to transfer the incoming mail to this

type of mailbox. (If you installed Postfix with instructions from the previous chapter,

then choose mbox.)

Page 49: Mail server report

8.3.3. Setting up Maildir

Do these steps ONLY if you want Maildir. This setup will put the Maildir in each user's

home directory.

If you are using Postfix as your MTA, then add the following line to

your /etc/postfix/main.cf file:

home_mailbox = Maildir/

Edit /etc/dovecot/dovecot.conf:

mail_location = maildir:/home/%u/Maildir

If !include conf.d/*.conf is uncommented in /etc/dovecot/dovecot.conf, it is necessary to

set mail_location in /etc/dovecot/conf.d/10-mail.conf or comment the line out. 10-

mail.conf will override the mail_location in dovecot.conf. If you choose to set the

mail_location in 10-mail.conf, you have to change it to:

mail_location = maildir:~/Maildir

8.4. Testing

Start dovecot:

/etc/init.d/dovecot start

Or in newer versions (as of Ubuntu 12.10) you need to use the upstart equivalent:

start dovecot

To check that it is running, type the command

ps -A | grep dovecot

You should see the dovecot service running. If you have enabled imap, or pop3, you can

also try to log in with the commands

telnet localhost pop3

or

telnet localhost imap2

Page 50: Mail server report

If you see something like the following, the installation has been successful.

matt@kalliope:~$ telnet localhost pop3

Trying localhost...

Connected to localhost.

Escape character is '^]'.

+OK dovecot ready.

Page 51: Mail server report

Chapter 9. Webmail Client

9.1. Introduction

Webmail is software which allows you to view email from any computer, anywhere in

the world, through your web browser. Squirrelmail is a simple, fast and popular webmail

package. This guide will enable you to setup webmail on your own server, for use either

within your home network, or outside.

SquirrelMail is a standards-based webmail package written in PHP. It includes built-in

pure PHP support for the IMAP and SMTP protocols, and all pages render in pure HTML

4.0 (with no JavaScript required) for maximum compatibility across browsers. It has very

few requirements and is very easy to configure and install.

9.2. Preparation

In order to run, you need to first set up a number of things:

1. A working Mail Transfer Agent.

2. A working (IMAP) Mail Delivery Agent.

3. A working Apache installation with PHP.

4. Squirrel mail does not require MySQL, so you can run it on a server

without MySQL installed. However if you wish, you can use MySQL for

address books, to set up MySQL.

9.3. Installation & Configurations

9.3.1 Installation

To install squirrelmail,run the below written command:

sudo apt-get install squirrelmail

9.3.2. Squirrelmail Configuration

Squirrelmail has a very simple configuration menu. To run it, type:

sudo squirrelmail-configure

You can use the numbers and letters to browse through the configuration menu. You

don't need to edit all the options. In fact, it is a good idea just to edit the necessary

options, until you have squirrelmail working, because it is easier to see what might be

Page 52: Mail server report

wrong. After squirrelmail is working, you can customise all the options! It is a good idea

to check the following options though:

1. In Menu 2 (mail server settings), although you shouldn't have to edit

these, just check they are correct. You can use an imaps server if you like,

but if squirrelmail is running on the same machine as your mail server, it

is faster and perfectly safe to use imap (you can configure your imap

server to ensure that it only listens on localhost if you like). Check that

your mail settings are:

2. A. Update IMAP Settings : localhost:143 (other)

B. Update SMTP Settings : localhost:25

The all options which we get are as below:

SquirrelMail Configuration : Read: config.php (1.4.0)

---------------------------------------------------------

Main Menu --

1.  Organization Preferences

2.  Server Settings

3.  Folder Defaults

4.  General Options

5.  Themes

6.  Address Books

7.  Message of the Day (MOTD)

8.  Plugins

9.  Database

10. Languages

D.  Set pre-defined settings for specific IMAP servers

C   Turn color off

S   Save data

Q   Quit

Command >>

Page 53: Mail server report

Go on to configure Apache, and then come back and explore the other options!

9.4. Apache Configuration

Squirrelmail comes with a sample apache configuration file

in /etc/squirrelmail/apache.conf. You can copy this file

to /etc/apache2/sites-available/squirrelmail with the command:

sudo cp /etc/squirrelmail/apache.conf /etc/apache2/sites-available/squirrelmail

then link it to the sites-enabled directory with the command:

sudo ln -s /etc/apache2/sites-available/squirrelmail

/etc/apache2/sites-enabled/squirrelmail

Alternatively you can use the a2ensite tool:

sudo a2ensite squirrelmail

You shouldn't have to edit anything else.

Alternatively, if you wish to use a virtual server setup instead, you can. For setting up

SSL, uncomment the last section from the configuration file. For more details on how to

use apache, see the Apache page.

Reload Apache Configuration:

sudo /etc/init.d/apache2 force-reload

If you ever wish to disable squirrelmail, you may simply delete the link in the site-

enabled directory and Reload Apache's Configuration.

Check it works!

Open a webbrowser, and go to the address http://localhost/squirrelmail.

Change localhost for the address of your server, or your virtualhost, if you have used that

Apache setup. You should see the Squirrelmail login box!

Page 54: Mail server report

Chapter 10. Apache Server

10.1. Introduction

The Apache web server is the most popular way of serving web content on the internet. It

accounts for more than half of all active websites on the internet and is extremely

powerful and flexible.

Apache breaks its functionality and components into individual units that can be

customized and configured independently. The basic unit that describes an individual site

or domain is called a virtual host.

These designations allow the administrator to use one server to host multiple domains or

sites off of a single interface or IP by using a matching mechanism. This is relevant to

anyone looking to host more than one site off of a single VPS.

Each domain that is configured will direct the visitor to a specific directory holding that

site's information, never indicating that the same server is also responsible for other sites.

This scheme is expandable without any software limit as long as your server can handle

the load.

Using Apache Virtual Host, you can run several websites on the same server.

For example, I can run both thegeekstuff.com and top5freeware.com on a single physical

server that has one Apache webserver running on it.

Figure 10.1 Apache Server

There are two types of Apache virtual host configurations: 1) IP-Based Virtual Host and

Page 55: Mail server report

2) Name-based Virtual Host. Name-based virtual host is recommended for most

scenarios.

10.2. Types of Virtual Host

10.2.1. IP-Based Virtual Host

In this configuration, when you are pointing two websites (with different ip-address) to

the server that runs Apache, that physical server should have two different ip-address

configured.

This means that the server should have two ethernet cards, each one of them configured

to the ip-address of the corresponding website that Apache virtual host will be serving.

So, this is not practical for most aspects, and you should not be using this.

In the following example, the server contains two NIC cards, one is configured with

192.168.101.1 ip-address for thegeekstuff.com, another is configured with 192.168.102.1

for top5freeware.com. Both these ip-address are served by a single Apache webserver

running on that server using IP-Based virtual host.

Figure 10.2 IP-Based Virtual Host

10.2.2 Name-Based Virtual Host

In this configuration, when Apache webserver receives a request, it looks for the

Page 56: Mail server report

hostname in the HTTP header, and depending on the hostname, it servers different

websites. This is very easy, as you need only one ip-address on that physical server; but,

you update the DNS with multiple website names pointing to the same ip-address. For all

practical purpose, you’ll be using only Name-based virtual host configuration.

In the following example, the server contains only one NIC card, which is configured

with 192.168.101.1 ip-address. The DNS entry for both thegeekstuff.com and

top5freeware.com website points to 192.168.101.1 ip-address. When Apache recives a

request, it looks for the hostname entry in the HTTP header, and serves the corresponding

website.

Figure 10.3 Name-Based Virtual Host

10.3. Setting up Virtual Host

In the following section, we will walk through how to set up Apache virtual hosts on an

Ubuntu 14.04 VPS. During this process, you'll learn how to serve different content to

different visitors depending on which domains they are requesting.

You will also need to have Apache installed in order to work through these steps. If you

haven't already done so, you can get Apache installed on your server through apt-get:

sudo apt-get update

Page 57: Mail server report

sudo apt-get install apache2

After these steps are complete, we can get started.

For the purposes of this work, my configuration will make a virtual host for example.com

and another for test.com. These will be referenced throughout the guide, but you should

substitute your own domains or values while following along.

Step One — Create the Directory Structure

The first step that we are going to take is to make a directory structure that will hold the

site data that we will be serving to visitors.

Our document root (the top-level directory that Apache looks at to find content to serve)

will be set to individual directories under the /var/www directory. We will create a

directory here for both of the virtual hosts we plan on making.

Within each of these directories, we will create a index.html file that will hold our actual

files. This gives us some flexibility in our hosting.

For instance, for our sites, we're going to make our directories like this:

sudo mkdir -p /var/www/mukul.net/index.html

The portions in red represent the domain names that we are wanting to serve from our

VPS.

Step Two — Grant Permissions

Now we have the directory structure for our files, but they are owned by our root user. If

we want our regular user to be able to modify files in our web directories, we can change

the ownership by doing this:

sudo chown -R $USER:$USER /var/www/mukul.net

The $USER variable will take the value of the user you are currently logged in as when

you press "ENTER". By doing this, our regular user now owns the index.html

subdirectories where we will be storing our content.

We should also modify our permissions a little bit to ensure that read access is permitted

to the general web directory and all of the files and folders it contains so that pages can

be served correctly:

sudo chmod -R 755 /var/www

Your web server should now have the permissions it needs to serve content, and your

user should be able to create content within the necessary folders.

Page 58: Mail server report

Step Three — Create Demo Pages for Each Virtual Host

We have our directory structure in place. Let's create some content to serve.

We're just going for a demonstration, so our pages will be very simple. We're just going

to make an index.html page for each site.

Let's start with example.com. We can open up an index.html file in our editor by typing:

nano /var/www/mukul.net/index.html

In this file, create a simple HTML document that indicates the site it is connected to. My

file looks like this:

<html>

<head>

<title>Mukul.net</title>

</head>

<body>

<h1>Success! The example.com virtual host is working!</h1>

</body>

</html>

Save and close the file when you are finished.

You now have the pages necessary to test the virtual host configuration.

Step Four — Create New Virtual Host Files

Virtual host files are the files that specify the actual configuration of our virtual hosts and

dictate how the Apache web server will respond to various domain requests.

Apache comes with a default virtual host file called 000-default.conf that we can use as a

jumping off point. We are going to copy it over to create a virtual host file for each of our

domains.

We will start with one domain, configure it, copy it for our second domain, and then

make the few further adjustments needed. The default Ubuntu configuration requires that

each virtual host file end in .conf.

Create the First Virtual Host File

Start by copying the file for the first domain:

sudo cp /etc/apache2/sites-available/000-default.conf

/etc/apache2/sites-available/mukul.net.conf

Page 59: Mail server report

Open the new file in your editor with root privileges:

sudo nano /etc/apache2/sites-available/mukul.net.conf

The file will look something like this (I've removed the comments here to make the file

more approachable):

<VirtualHost *:80>

ServerAdmin webmaster@localhost

DocumentRoot /var/www/html

ErrorLog ${APACHE_LOG_DIR}/error.log

CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

As you can see, there's not much here. We will customize the items here for our first

domain and add some additional directives. This virtual host section matches any

requests that are made on port 80, the default HTTP port.

First, we need to change the ServerAdmin directive to an email that the site administrator

can receive emails through.

ServerAdmin [email protected]

After this, we need to add two directives. The first, called ServerName, establishes the

base domain that should match for this virtual host definition. This will most likely be

your domain. The second, called ServerAlias, defines further names that should match as

if they were the base name. This is useful for matching hosts you defined, like www:

ServerName mukul.net

ServerAlias www.mukul.net

The only other thing we need to change for a basic virtual host file is the location of the

document root for this domain. We already created the directory we need, so we just need

to alter the DocumentRoot directive to reflect the directory we created:

DocumentRoot /var/www/mukul.net

In total, our virtualhost file should look like this:

<VirtualHost *:80>

ServerAdmin [email protected]

ServerName mukul.net

ServerAlias www.mukul.net

Page 60: Mail server report

DocumentRoot /var/www/mukul.net

ErrorLog ${APACHE_LOG_DIR}/error.log

CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

Save and close the file.

Step Five — Enable the New Virtual Host Files

Now that we have created our virtual host files, we must enable them. Apache includes

some tools that allow us to do this.

We can use the a2ensite tool to enable each of our sites like this:

sudo a2ensite mukul.net

When you are finished, you need to restart Apache to make these changes take effect:

sudo service apache2 restart

You will most likely receive a message saying something similar to:

* Restarting web server apache2

AH00558: apache2: Could not reliably determine the server's fully qualified domain

name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message

This is a harmless message that does not affect our site.

Step Six — Set Up Local Hosts File (Optional)

If you haven't been using actual domain names that you own to test this procedure and

have been using some example domains instead, you can at least test the functionality of

this process by temporarily modifying the hosts file on your local computer.

This will intercept any requests for the domains that you configured and point them to

your VPS server, just as the DNS system would do if you were using registered domains.

This will only work from your computer though, and is simply useful for testing

purposes.

Make sure you are operating on your local computer for these steps and not your VPS

server. You will need to know the computer's administrative password or otherwise be a

member of the administrative group.

If you are on a Mac or Linux computer, edit your local file with administrative privileges

by typing:

sudo nano /etc/hosts

Page 61: Mail server report

The details that you need to add are the public IP address of your VPS server followed by

the domain you want to use to reach that VPS.

For the domains that I used in this guide, assuming that my VPS IP address is

111.111.111.111, I could add the following lines to the bottom of my hosts file:

127.0.0.1 localhost

127.0.1.1 guest-desktop

192.168.1.5 mukul.net

This will direct any requests for mukul.net on our computer and send them to our server

at 192.168.1.5. This is what we want if we are not actually the owners of these domains

in order to test our virtual hosts.

Save and close the file.

Step Seven — Test your Results

Now that you have your virtual hosts configured, you can test your setup easily by going

to the domains that you configured in your web browser:

http://mukul.net

You should see a page that looks like this:

Figure 10.4 Output Page

If you adjusted your home computer's hosts file, you may want to delete the lines you

added now that you verified that your configuration works. This will prevent your hosts

file from being filled with entries that are not actually necessary.

If you need to access this long term, consider purchasing a domain name for each site you

need and setting it up to point to your VPS server.

There is no software limit on the number of domain names Apache can handle, so feel

free to make as many as your server is capable of handling.

Page 62: Mail server report

10.4. Addition of squirrelmail to Virtual Host

We can combine squirrelmail with virtual host using apache. For that purpose,we have to

do some configurations.

First of all,we have to make a link of squirrelmail in /var/www/html folder. For this,use

the below command:

sudo ln -s /usr/share/squirrelmail /var/www/html/squirrelmail

This command will create link of squirrelmail in virtual host and we can access

squirrelmail just by typing in browser as:

http://mukul.net/squirrelmail

we can host no. of sites using this procedure.

Page 63: Mail server report

Chapter 11. Codes and configurations of Project

Here is how we configured mail server in Ubuntu 14.04 LTS. The name of mail server

domain that we configured is mail.mukul.net.

11.1. Installation of Packages

We needed approximately 8 packages to set up mail server. Press ALT+CTRL+T to open

terminal. Then first of all, come into super user mode by using following command:

sudo su

It asked for root password. Type the password and press ENTER. We entered in super

user mode. For full procedure, we have to remain in super user mode because we cannot

do editing in configuration files without root privilege.

Then update the packages list of the Ubuntu by following command:

apt-get update

The updation is necessary because sometimes it becomes unavailable to find particular

package without updating list.

Next thing is to install all the packages required for mail server. To install packages, run

the following command:

apt-get install bind9 dnsutils apache2 php5 postfix dovecot-core dovecot-imapd

dovecot-pop3d squirrelmail

This starts installation of the above mentioned packages.

Now, we have to do configurations of installed packages.

11.2. Configurations

11.2.1. Static IP address assignment

To configure your system to use a static IP address assignment, add the static method to

the inet address family statement for the appropriate interface in the file

/etc/network/interfaces . The example below assumes you are configuring your first

Ethernet interface identified as eth0. Change the address, netmask, and gateway values to

meet the requirements of your network.

auto eth0

iface eth0 inet static

address 192.168.1.5

Page 64: Mail server report

netmask 255.255.255.0

gateway 192.168.1.1

By adding an interface configuration as shown above, you can manually enable the

interface through the ifup command.

sudo ifup eth0

To manually disable the interface, you can use the ifdown command.

sudo ifdown eth0

11.2.2. DNS server

11.2.2.1. named.conf.local file

To make DNS server,we have installed bind9 package. Now, for the configurations of the

DNS server, firstly we have to make entries of forward zone and reverse zone in

named.conf.local file which is located in /etc/bind directory. To do this use the following

commands:

cd /etc/bind

nano named.conf.local

nano named.conf.local file will open named.conf.local file and add the entries of forward

and reverse zone over here as:

zone “mukul.net” {

type master;

file “/etc/bind/db.mukul.net”;

}

zone “0.168.192.in-addr.arpa” {

type master;

file “/etc/bind/db.192”;

}

11.2.2.1. Forward and reverse zone files

Now we have to make zone files which we have mentioned in named.conf.local file. To

do so, we can use db.local and db.127 files as templates. These files we already have over

there. We can use db.local for forward zone file i.e. for db.mukul.net and db.127 for

reverse zone file i.e. for db.192. Below used commands will copy the content of db.local

Page 65: Mail server report

into db.mukul.net and that of db.127 into db.192. These commands will automatically

create db.mukul.net and db.192 files.

cp db.local db.mukul.net

cp db.127 db.192

Now one by one edit the both files and and add the configurations. Frstly open the file db.mukul.net using below command:

nano db.mukul.netWe will get the following output:;

; BIND data file for example.com

;

$TTL 604800

@ IN SOA localhost. root.localhost. (

2 ; Serial

604800 ; Refresh

86400 ; Retry

2419200 ; Expire

604800 ) ; Negative Cache TTL

;

@ IN NS localhost.

@ IN A 127.0.0.1

@ IN AAAA ::1

Change it to according to your need. We made it as:;

; BIND data file for example.com

;

$TTL 604800

@ IN SOA ns.mukul.net. root.mukul.net. (

2 ; Serial

604800 ; Refresh

86400 ; Retry

2419200 ; Expire

604800 ) ; Negative Cache TTL

Page 66: Mail server report

;

@ IN NS ns.mukul.net.

@ IN A 192.168.1.5

ns IN A 192.168.1.5

IN MX 10 mail.mukul.net.

www IN CNAME ns

mail IN CNAME nsNow open the file db.192 using below command:

nano db.192We will get the following output:;

; BIND reverse data file for local 192.168.1.XXX net

;

$TTL 604800

@ IN SOA localhost. root.localhost. (

2 ; Serial

604800 ; Refresh

86400 ; Retry

2419200 ; Expire

604800 ) ; Negative Cache TTL

;

@ IN NS localhost.

1.0.0 IN PTR localhost.

Change it to according to your need. We made it as:;

; BIND reverse data file for local 192.168.1.XXX net

;

$TTL 604800

@ IN SOA ns.mukul.net. root.mukul.net. (

2 ; Serial

604800 ; Refresh

86400 ; Retry

2419200 ; Expire

Page 67: Mail server report

604800 ) ; Negative Cache TTL

;

@ IN NS ns.mukul.net.

5 IN PTR ns.mukul.net.

11.2.2.3. Restart bind9 service.

Now, to update the configurations, we have to restart the bind9 service. We can use any

of the following commands to restart the bind9 service:

invoke-rc.d bind9 restart

service bind9 restart

We will get the following output:

Figure 11.1 bind9 restart output

We have to check nslookup status of our DNS server. So, to check it,run the following

command in terminal:

nslookup mail.mukul.net

We will get the following output like that:

Server: 192.168.1.5

Address: 192.168.1.5#53

If we didn’t get output like that then there is must be some wrong configuration.

Note: If we want our domain should be accessed from other computers also then that

computer must have DNS server address as address of our DNS server i.e. 192.168.1.5.

So, to make it easy, we can use DHCP server which will automatically assign ip

addresses as well as DNS server address.

11.2.3. Postfix configuration

11.2.3.1. Configurations

Now, we have to do configurations of mail transfer agent. For this purpose, we have

installed postfix package. Postfix configuration is easy in Ubuntu as we can do it

Page 68: Mail server report

graphically in Ubuntu. We also can do it by editing configuration files but it will be easy

to do it graphically. However it

will not be fully graphically as we have to open it through commands.To open postfix

configuartions, run the following command in terminal:

dpkg-reconfigure postfix

we will get the following graphical portal of postfix:

Figure 11.2 Postfix configuration Step I

This portal tells what are the next configurations. Tap on <OK> and press ENTER. We

will get a new portal as:

Page 69: Mail server report

Figure 11.3 Postfix configuration Step II

Here we have four options. Out of which, we have to select “Internet Site” option. Tap on

<OK> and press ENTER. We will get a new portal as:

Figure 11.4 Postfix configuration Step III

Page 70: Mail server report

Here we have to write the name of domain of our mail server. We write here

mail.mukul.net.

Then Tap on <OK> and press ENTER. We will get a new portal as:

Figure 11.5 Postfix configuration Step IV

We have to write here the e-mail address or the root user of the mail.mukul.net domain.

We write here mail.mukul.net. Then Tap on <OK> and press ENTER. We will get a new

portal as:

Page 71: Mail server report

Figure 11.6 Postfix configuration Step V

We have to write here the names of mail domain as well as the normal domain at the end

of line and starting of line respectively. We write here mail.mukul.net at the starting and

mukul.net at the end of line. Then Tap on <OK> and press ENTER. We will get a new

portal as:

Figure 11.7 Postfix configuration Step VI

Page 72: Mail server report

Here is no need to do any changes. Simply tap on <No> and press ENTER. We will get a

new portal as:

Figure 11.8 Postfix configuration Step VII

Here we have to eter the network address in which we want our mail server to be worked

in. Here we entered 192.168.1.0/24 because we want that our domain should work in

192.168.1.0 network and computers in our network having ip addresses from 192.168.1.1

to 192.168.1.254 can access our domain mail.mukul.net. Enter the address, tap on <OK>

and press ENTER.

We will get a new portal as:

Page 73: Mail server report

Figure 11.9 Postfix configuration Step VIII

Here is no need to do any changes. Simply tap on <OK> and press ENTER. We will get a

new portal as:

Figure 11.10 Postfix configuration Step IX

Here is no need to do any changes. Simply tap on <OK> and press ENTER. We will get a

new portal as:

Page 74: Mail server report

Figure 11.11 Postfix configuration Step X

Here we have to set whether to allow ipv4, ipv6 or both (all) protocols. We select here

all, Tap on <OK> and press ENTER. We will get out of configurations and there will be

terminal progression describing our configurations and restarting postfix.

Figure 11.12 Postfix configuration Output

11.2.3.2. Restart Postfix service.

Page 75: Mail server report

Now, to update the configurations, we have to restart the postfix service. We can use any

of the following commands to restart the postfix service:

invoke-rc.d postfix restart

service postfix restart

But here we don’t need to restart postfix as it has already been restarted after

configurations.

11.2.4. Dovecot configuration

11.2.4.1. Configurations

Now, we have to do configurations of mail delivery agent. We have installed dovecot

package for that purpose. To do the configurations, we have to edit the configuration file

dovecot.conf which is located in /etc/dovecot directory.

To open the file run the following commands:

cd /etc/dovecot

nano dovecot.conf

Now at the starting of file, add the lines which are written below:

protocols = imap pop3

mail_location = mbox:~/mail:INBOX=/var/mail/%u

First line tells to dovecot about the protocols used and the second line defines the

mailbox location.

11.2.4.2. Restart dovecot service.

Now, to update the configurations, we have to restart the dovecot service. We can use any

of the following commands to restart the dovecot service:

invoke-rc.d dovecot restart

service dovecot restart

We will get the following output:

Figure 11.13 Dovecot output restart

After that, restart the postfix service also.

Page 76: Mail server report

11.2.5. Adding users

To add users, we have to use adduser command in terminal. We added here two users:

mani, manu. To add first user i.e. manu, run the following command:

adduser manu

It will ask for password that we want to set for manu user. Once we set it, it will ask for

5-6 options. Just skip them by pressing ENTER and at last option, it will ask yes/no.

write yes and press ENTER.

User manu has been created. Similarly we can create second user i.e. mani. Only the

users created on the PC where we build mail server can login into mail server

mail.mukul.net. If we want that someone login from other PC then his/her account must

be created on the PC in which mail server is built.

11.2.6. Apache configuration

11.2.6.1. Configurations

Now, we have to do configurations of apache server because to access squirrelmail

through http service, we need to do it’s attachment with apache server. To do apache

configurations, we have to go into /etc/apache2/sites-enabled and have to do some

changes in that directory. So, using below command to enter in that directory:

cd /etc/apache2/sites-enabled

Now, there will be a default file named as 000-default.conf. we have to copy the content

of that file to create our domain’s configuration file. Use below command to do that:

cp 000-default.conf mail.conf

But, to make mail.conf file as our domain’s configuration file, we have to do some

changes. Open the file mail.conf using below command:

nano mail.conf

See the options over there as:

#ServerName www.example.com

ServerAdmin webmaster@localhost

DocumentRoot /var/www/html

Change these according to requirement. We did here as:

ServerName mail.mukul.net

Page 77: Mail server report

ServerAdmin webmaster@localhost

DocumentRoot /var/www/squirrelmail

Now, open the apche2.conf file which is the main configuration file of apache server and

is located in /etc/apache2 directory. So, using below command to enter in that directory:

cd /etc/apache2/

Open the file apache2.conf using below command:

nano apache2.conf

See the options over there as:

<Directory /var/www>

Options Indexes FollowSymLinks

AllowOverride None

Require all granted

</Directory>

Change these according to requirement. We did here as:

<Directory /var/www/squirrelmail>

Options Indexes FollowSymLinks

AllowOverride None

Require all granted

</Directory>

As we declared here directory /var/www/squirrelmail. So, we have to create it over there

also. For that purpose, we can use links. Also, if we want that squirrelmail should be

accessed without using mail.mukul.net and should be accessed using

ip_address/squirrelmail, then we have to create it’s link in /var/www/html directory. To

create squirrelmail link in /var/www and /var/www/html directory, we can use following

commands:

ln -s /usr/share/squirrelmail/ /var/www/squirrelmail

ln -s /usr/share/squirrelmail/ /var/www/html/squirrelmail

First command makes the link in /var/www directory and second line creates link in

/var/www/html directory.

11.2.6.2. hosts file configuration

Page 78: Mail server report

We have to add the ip address and domain name in hosts file that is located in /etc

directory as we did in virtual host setup. Open the file using below command:

nano /etc/hosts

add the below mentioned line at the bottom of lines written in that file:

192.168.1.5 mail.mukul.net

11.2.6.3. Restart apache2 service

Now, to update the configurations, we have to restart the apache2 service. We can use

any of the following commands to restart the apache2 service:

invoke-rc.d apache2 restart

service apache2 restart

Now we can access the mail server using three URLs:

1. mail.mukul.net

2. mukul.net/squirrelmail

3. 192.168.1.5/squirrelmail

To access squirrelmail login through mukul.net/squirrelmail we can also required to set

up virtual host as we did in 9th chapter.

Then we can also access mail.mukul.net as a part of mukul.net website as shown below:

Figure 11.14 Virtual host page

11.2.7. DHCP server configuration

11.2.7.1. Installation

At a terminal prompt, enter the following command to install dhcpd:

sudo apt-get install isc-dhcp-server

Page 79: Mail server report

You will probably need to change the default configuration by editing

/etc/dhcp/dhcpd.conf to suit your needs and particular configuration.

You also may need to edit /etc/default/isc-dhcp-server to specify the interfaces dhcpd

should listen to.

NOTE: dhcpd's messages are being sent to syslog. Look there for diagnostics messages.

11.2.7.2. Configuration

The error message the installation ends with might be a little confusing, but the following

steps will help you configure the service:

Most commonly, what you want to do is assign an IP address randomly. This can be done

with

settings as follows:

# minimal sample /etc/dhcp/dhcpd.conf

default-lease-time 600;

max-lease-time 7200;

subnet 192.168.1.0 netmask 255.255.255.0 {

range 192.168.1.150 192.168.1.200;

option routers 192.168.1.254;

option domain-name-servers 192.168.1.5;

option domain-name "mukul.net";

}

This will result in the DHCP server giving clients an IP address from the range

192.168.1.150-192.168.1.200. It will lease an IP address for 600 seconds if the client

doesn't ask for a specific time frame. Otherwise the maximum (allowed) lease will be

7200 seconds. The server will also advise the client to use 192.168.1.254 as the default-

gateway and 192.168.1.5 as it’s DNS servers.

After changing the config file you have to restart the dhcpd:

sudo /etc/init.d/isc-dhcp-server restart

11.2.8. Squirrelmail configuration

Squirrelmail doesnot need to make any changes. It automatically get the configurations.

Page 80: Mail server report

11.3. Login to mail server

Open browser on PC and enter URL: http://mail.mukul.net

We will get login page of squirrelmail. As shown below:

Figure 11.15 Login Page

Then fill username and password of any user on the mail server and press login. We will

get the following page:

Figure 11.16 Inbox page

Now here you can see options like Inbox, Sent, Trash, Drafts, Compose etc. We can use

them as we use in other mail servers like gmail, yahoo mail etc.

Page 81: Mail server report

We can also use another client like thunderbird. Put address mail.mukul.net, username

and password of any user/client. Then whenever mail is sent to that user , thunderbird

will automatically show a notification that a mail has been received.

Page 82: Mail server report

REFERENCES[1] www.OCFreaks.com[2] www.linuxhomenetworking.com[3] www.askubuntu.com[4] www.slideshare.com[5] www.networkingnotes.com[6] www.howtoforge.com[7] www.tldp.org[8] www.access.redhat.com