Email - preparing the Slice

Beginning a series of articles on many aspects of email (sending, receiving, configuring, etc), we need to start with the very basics by preparing the Slice.

This article looks at the hostname and reverse DNS (RDNS) settings on the Slice.


The only assumptions made for these email articles are:

1: You are running Ubuntu Hardy (The instructions may work on other distros but it has not been tested and is not guaranteed)

2: You have followed the setup articles: page 1 and page 2

Beyond that, I hope to show everything that is needed from the very basics upwards.


The first thing to look at is the Slice hostname.

This is simply the 'name' of the Slice and is used in the headers of the email (the headers can be thought of as the address and sender label on the email).

There are a couple of ways of setting the host name.


When you build a new Slice or rebuild a Slice, you are given the opportunity to set the Slice name - this can be a FQDN (Fully Qualified Domain Name). This name is then used to set the hostname when the Slice is built.

This can be a quick and easy way of setting the hostname.

However, you do not have restrict your Slice name to match that of the hostname.

On the demo account I have a Slice named 'slice1'. As such, the hostname of the Slice was initially set as 'slice1'.

I don't want to rebuild the Slice and I am happy with the Slicemanager name of 'slice1'. As such, let's look at changing the hostname from the command line:

Command Line

Setting the hostname via the command line involves the very simple adjustment of a couple of files.

We can start by checking what the current hostname is:

hostname -f

On my Slice, the output is:


Well, that makes sense. When I built the Slice I named it 'slice1' in the Slicemanager. As such, the hostname was set to 'slice1'.

For these basic articles I am going to use the domain '' - I am setting up a mail server so that makes sense.

I need to change the hostname to match the domain:

sudo nano /etc/hostname

Replace the current hostname (slice1) with the one you need (in this case

The second file to edit is:

sudo nano /etc/hosts

The default looks like this on my Slice:       localhost localhost.localdomain       slice1

Following on from what we are doing, replace 'slice1' with ''.

Of course, replace with your domain.


Conduct a quick reboot:

sudo reboot

and check the hostname:

hostname -f

The output is now:

Good start!

Reverse DNS

The second main aspect we need to look at when preparing the Slice is the Reverse DNS (RDNS).

One of the main reasons for email being marked as spam and causing IP addresses to be blocklisted is a mismatch between the sending domain and the RDNS of the Slice.

We can check the RDNS of the Slice from the Slicemanager.

Log into the Slicemanager

Once done, click the DNS tab and then the 'Reverse DNS' link.

On the demo account, one of the Slices has this record as the default:

Slicemanager - Reverse DNS

All we need to do is change the default entry to match our main domain:

Slicemanager - Changing the RDNS


Check the RDNS

The RDNS may take a while to propagate and you really need to wait until it has done so before you can fully configure and test any mail setup.

To check the RDNS, you need to input the IP address if the Slice into the 'dig' command.

Note that 'dig' is not installed on a base Ubuntu Hardy Slice:

sudo aptitude install dnsutils

(Many thanks for the comments that noted dig is not installed by default - I use my workstation to conduct dig commands and didn't think that others may use the Slice for that!)

So, to check the RDNS:

dig -x

In this case, the output includes the correct answer:

dig -x
;     IN      PTR




Preparing the Slice is a vital step in any mail setup - even if 'only' sending mail from your application to an administrator, it is very important to get the basics right.

As the articles progress you will start to see where this preparation comes into play when sending and receiving emails.


Article Comments:

Luke commented Mon Jul 28 22:15:27 UTC 2008:

I think I said this before but I'd like to say it again. Your articles are excellent and very much appreciated!

Jose commented Tue Jul 29 00:40:27 UTC 2008:

Looking forward for the upcoming postfix article.

Alesandro commented Tue Jul 29 02:28:58 UTC 2008:

I don't know if an article on setting up SPF (or other e-mail sender verification methods) is on the schedule, but it seems perfect for this series. I've yet to find a good article on setting up SPF.

Thanks for the excellent articles!

PickledOnion commented Tue Jul 29 10:22:27 UTC 2008:


I do plan on covering SPF records during the series.


davemck commented Tue Jul 29 16:19:51 UTC 2008:

I get "command not found" when I try to dig. There is no manual entry for it either.

dozens commented Wed Jul 30 00:20:58 UTC 2008:

Yeah, what is the path to dig ?

jfrench commented Wed Jul 30 01:23:25 UTC 2008:

dig is not pre-installed on Ubuntu 8. Get it with sudo apt-get install dnsutils

PickledOnion commented Wed Jul 30 09:21:50 UTC 2008:


Thanks for the comments regarding dig. I have adjusted the article to reflect the installation of dig.

I use my workstation for dig queries and I did not think of people using the Slice.

As an aside, please note that apt-get was depreciated a couple of years ago and the last distro that it is recommended to use it with is Ubuntu Dapper LTS.

It has been recommended to use 'aptitude' since then.


dedekind commented Thu Jul 31 14:49:25 UTC 2008:

I'm not sure I get this. Why do you choose as your hostname? Is this the name of your main website (that you are pointing towards the slicehost nameservers)? Are you planning on making emails like is that why you choose this hostname?

What if I have a bunch of domains (say and and want to make email addresses for both domains, say and ?

PickledOnion commented Thu Jul 31 17:48:48 UTC 2008:


As I mention in this and the other articles, this is for a single domain only.

I will get onto multiple domains at a later article.

I use the domain as it is a demonstration domain name.

You use your own main domain.

I am not sure what you mean in your comment about making emails for a different domain - you mention making an email for which has nothing to do with the main domain used in the articles (


Michael commented Fri Aug 01 21:42:30 UTC 2008:

to install dig on Fedora 9 using yum: yum install bind-utils

Hope this helps someone.

dedekind commented Mon Aug 04 18:06:29 UTC 2008:

Yes oops. Didn't mean to say there earlier. Just a typo.

But anyway, I somehow find it strange to be changing the hostname of the whole slice from slicename to Because this will change the Bash prompt's feedback from username@slicename to, which I found very weird...

dedekind commented Mon Aug 04 18:20:38 UTC 2008:

Correction: I meant to say that in Bash, that "mail" thing sits screaming at you at all times. So in the above, I made a typo. "" was only supposed to be "username@mail". Is there any way to do this thing without changing the machine's hostname? Seems kind of weird to change the whole hostname just to incorporate email...

PickledOnion commented Tue Aug 05 10:36:16 UTC 2008:


I am not really sure what your question is - as explained in the articles, the hostname is needed to set the correct details in the email headers.

It is as simple as that.

Not sure what the 'mail' thing is you are referring to? Do you mean the bash prompt? If so, edit the .bash_config file to change it to one you prefer.


Barry commented Wed Aug 06 03:32:24 UTC 2008:

For the main domain name on my server, I'm using Google Apps for my email.

Can I still use this setup to send emails from my server even if my MX records are directing mail to Google?

Is there a way to setup my server to use Google's SMTP servers?

archondigital commented Thu Aug 07 08:25:39 UTC 2008:

I would also like to know how postfix would work if the points to Google Apps. Thanks.

FatherShawn commented Thu Aug 14 10:34:11 UTC 2008:

I'm wondering why you would set the RDNS to and not simply

PickledOnion commented Sun Aug 17 09:37:59 UTC 2008:


I set the hostname to as the Slice is the mail server for

I could host the main domain anywhere.

It is impossible to cover every possible eventuality for Slice setups and the simplest thing to do is to concentrate on one thing.

In the email articles, we are looking at email - that is to say, running a mail server.

As such, the hostname and RDNS are set to the mail server domain.

I hope that helps.


nerb commented Sat Aug 23 15:52:33 UTC 2008:

So it is fair to say then, that if we only own ONE slice, and run both our websites and mail from the same slice, we would need to just ensure that reverse DNS is working and that we have SOME name in the hostname -f.


Mike commented Fri Sep 19 16:14:03 UTC 2008:

When I change the hostname and reboot, the command 'hostname -f' returns: hostname: Unknown host

Jay commented Thu Oct 16 14:51:18 UTC 2008:

I get the same problem as Mike. Also, this is a web / mail server, so why am I doing this?

Jeremy Lim commented Tue Dec 02 05:07:58 UTC 2008:

As a complete klutz with anything that doesn't have a GUI, I can't tell you how grateful I am for this series.

So much love, PickledOnion!

Baruch commented Thu Dec 04 05:48:22 UTC 2008:

Like some others, I got a peculiar prompt (baruch@mail). Also, when I tried running hostname -f, I got "Unknown Host".

Furthermore, my Websites no longer worked, nor did webmin.

I don't understand this article, nor is my system responding as described, even though I followed the directions faithfully. I am confused.

PickledOnion commented Thu Dec 04 10:58:46 UTC 2008:


Not sure what is peculiar about the prompt. If you don't like it, then you can change it by following the Slice setup articles. It shows exactly what we set it to show.

If you are having issues with the hostname then you didn't change one of the mentioned items or are using a distro not covered in this article (this is for Ubuntu Hardy).

Sorry I can't be more help but it really is as simple as that. If you changed the files as noted then it works.


Dhanil commented Tue Dec 09 08:16:15 UTC 2008:


I am using Fedora Core 9. I want to setup postfix & as per articles i have tried to configured basic setup but it does not have file /etc/hostname so do i have to create one or I can use /etc/hosts file? I have setup /etc/hosts file as : localhost localhost.localdomain


When i type hostname -f it shows

Eric commented Tue Dec 09 18:53:39 UTC 2008:

The point a lot of comments here are getting at, and one which I share, is:

If I have one slice, my hostname is:

My reverse DNS is:

Will this discrepancy cause any problems? I don't want to make the hostname for my one and only slice to be, but I would like mail to work from it and not get blacklisted/rejected.


Eric commented Tue Dec 09 18:58:02 UTC 2008:

As a continuation of my previous comment, would the solution be to just set my reverse DNS as: Slice Name: Record: And just forget the 'mail.' prefix altogether?

Jamie commented Sat Dec 13 06:28:14 UTC 2008:

This setup guide appears to be for if you intend to setup a Slice that is purely used as a mail server. If you wish to use it as both a mail server and a web server, you'd be better to drop the mail prefix from most of the setup as doing so may cause problems with your web server setup.

The change in bash prompt occurs because you are changing the hostname of the machine... and so to try and be convenient (under the assumption your "group of servers" works within one domain), bash assumes the first part of your domain - in this case, mail. This works on the basis that you would have another web server slice named "" which bash would call "@web", or a fileserver called "" which bash would call "@files", etc, to aid in identification when using SSH or whatever.

You can easily set the RDNS and mail server to run from without causing any problems - there is no requirement to run from except for the ease of identifying what the server is for.

Your MX records will identify where your mail server is, so using the mail. prefix is purely for convenience.


Tibor commented Tue Jan 06 02:16:42 UTC 2009:

hostname -f or -a gave me "Unknown Host" too

For some reason the host name was not picked up from the /etc/hosts file.

I found one workaround: comment or remove the line setting the HOSTNAME in the /etc/sysconfig/network file. Something like this: NETWORKING=yes



Seems to me the above HOSTNAME comes from the slice web management interface. I am not sure what tool should be used to change this line officially but editing the file + reboot the slice resolved my problem!

Andrew B commented Sun Jan 11 05:21:38 UTC 2009:

How long does it take the RDNS to propagate? If it has not propagated yet, could that be a reason for a "Relay access denied" error when attempting to send email?

Abed commented Mon Jan 19 00:14:43 UTC 2009:

Re: dedekind (and others) (about the Bash prompt)

I'm essentially a complete noob to *nix. Changing the hostname to mail.domain... would change the bash prompt to "mail", which was quite irksome for me. PickledOnion mentioned ".bash_config" which I couldn't figure out but I did after some googling + talking to a friend.

If you followed along the series of Ubuntu articles (particularly the Ubuntu Hardy setup page 2: ) you may have already come across this, too. Edit the .bash_rc file in your home directory. If you followed the article change the export PS1 line where it says \h (the "mail" part of your hostname) to whatever you want (then do what you have to do so the changes are applied, which in the article above is "source ~/.bashrc"). Here's a page I referred to on more bash prompt / .bashrc info:

Now I can have my bash prompt read as my slicename, keep the host as to follow along the series of tutorials without any worries or irritations =)

Abed commented Mon Jan 19 00:16:35 UTC 2009:

whoops! In my comment above "Edit the .bash_rc file" should read "Edit the .bashrc file" (no underscore!).

Michael commented Wed Feb 18 01:18:05 UTC 2009:

Hi there,

There's been a few comments about the necessity to name your slice I can see where these people are coming from. They don't want their slice to have an email centric name because they they might want to use it for lots of other things.

I've set mine up in the following way: I've given it a FQDN of and added a and reverse dns for I can then (if I want) add an MX for and mail will arrive at my slice and spam people will be happy that everything is kosha.

Does this make sense to people? Is it a good way to proceed? Any drawbacks?

Matt Enright commented Thu Feb 26 14:17:14 UTC 2009:

Hey guys, If you're getting the hostname not found error when requesting the FQDN (i.e. using hostname -f), you need to return to /etc/hosts, and give it two columns - the FQDN first, and the local hostname second. mail

Patrick Sanchez commented Mon Mar 23 09:43:55 UTC 2009:

I tried "mail myemail" and it hangs after I input the subject.

Gswain commented Thu May 21 17:58:29 UTC 2009:

For Centos (and probably fedora) you can change your hostname permanently by editing /etc/sysconfig/network

Hope that helps someone

Mark McLean commented Thu Jul 02 21:17:25 UTC 2009:

For Jaunty Matt Enright is correct except his example is wrong whereas his text is correct.

Should be: mail

datakid commented Fri Sep 25 23:07:30 UTC 2009:

These are great, easy to follow tutes PO. But fwiw, I think the comments on this one are indicative of a trend and important to note. There needs to be another tutorial here for those that only have one server. There are a number of other steps that need to be taken if you decide to use:

hostname = berlin hostname -f = mail = web =,

all on the same slice. I'm struggling with it now, and it's not obvious which way to go. Should I be adding:

to the bottom of /etc/hosts for instance? ie:     localhost localhost.localdomain 
# entries for subdomains

Jason commented Fri Oct 09 02:28:28 UTC 2009:

I'm trying to setup email on my slice as outlined and after reboot I'm getting ~: hostname -f hostname: Unknown host. I'm running Ubuntu 9.04 (jaunty) and have added the domain name to my zone.

Thanks for any help,


iChaitanya commented Wed Nov 04 16:30:17 UTC 2009:

Ubuntu 9.10: If you're getting a "hostname: Unknown host" reply after issuing the command 'hostname -f', change the hostname of your slice to a FQDN from the SliceManager. After a reboot if you issue the command 'hostname -f', it'll display the same FQDN that you entered in SliceManager. Hope this helps someone!

Brian commented Mon Nov 09 00:05:17 UTC 2009:

If I follow you setup and set records for, should I be sending emails from or can I still send them from Does it not matter?

Gabriel commented Sat Jan 09 08:25:00 UTC 2010:

Debian Lenny + Exim4 I configured my RDNS, hostname, hosts, according to these instructions.

And every recipient mail servers look at the incoming email address and try to verify the domain, or mx (I'm assuming.. )

I get things like this:

2006-08-28 11:08:57 1GH7KP-0001Gq-Py == R=dnslookup T=remote_smtp defer (-44): SMTP error from remote mail server after RCPT host[]: 450 Sender address rejected: Domain not found

Any help would be greatly appreciated.


nicolas block commented Sat Jan 16 00:45:13 UTC 2010:

the protocol for changing my hostname didn't work for me on Ubuntu Hardy.

here's what did work:

first back up just in case i'm wrong sudo cp /etc/hosts /etc/hosts.bak sudo cp /etc/hostname /etc/hostname.bak


sudo nano /etc/hosts

make it look like this: localhost

where is your actual hostname


sudo nano /etc/hostname

make it look like this:

where is your actual hostname


sudo reboot

nicolas block commented Sat Jan 16 00:50:46 UTC 2010:

*ok, that formatted horibly, let me try again, maybe i can make this markdown thingy work...

the protocol for changing my hostname didn't work for me on Ubuntu Hardy.

here's what did work:

first back up just in case i'm wrong

sudo cp /etc/hosts /etc/hosts.bak 
sudo cp /etc/hostname /etc/hostname.bak


sudo nano /etc/hosts

make it look like this:    localhost

where is your actual hostname


sudo nano /etc/hostname

make it look like this:

where is your actual hostname


sudo reboot

Ben Maden commented Sat Mar 20 03:32:51 UTC 2010:

All works for Fedora too.

thanks, very handy :)

J.Ganesan commented Sun May 02 00:59:33 UTC 2010:

I have signed up for one slice and my requirements are

  1. I run my web sites a. b.
  2. I need to have email ids a. b.

At present when I do hostname -f I get

I do not want to have anything like My question is wherever the article mentions "", if I substitute "", will postfix work or not ?

Jered commented Tue May 04 15:39:46 UTC 2010:

You can use "" instead of "", just make sure that the reverse DNS for your slice points back to "" when you use it for the mail host address too.

John commented Sun May 16 21:56:10 UTC 2010:

Hi guys was just wondering what you think is the best server currently for email hosting?

Frank Malina commented Sat Nov 27 16:36:58 UTC 2010:

I was getting bounced mails "Undelivered Mail Returned to Sender" with errors such as: host ... refused to talk to me ... Helo command rejected: need fully-qualified hostname.

This fixed it.

Additionally I went to and got my IP removed from PBL list as it originated from a dynamically assigned IP range, all good.

Fred Cord commented Tue Aug 30 01:38:17 UTC 2011:

These articles are of great help!!!!!!!!!!!!!!!!! It works for me perfectly.

architectural wall deca commented Fri May 03 19:08:25 UTC 2013:

I went over this website once i think a few a lot of wonderful info, saved to bookmarks (:.

architectural wall deca commented Fri May 03 19:08:31 UTC 2013:

I went over this website once i think a few a lot of wonderful info, saved to bookmarks (:.

a house commented Wed Jun 12 07:41:32 UTC 2013:

We have joined your feed and show toward seeking greater amounts of your magnificent post. Also, I've shared your site within my myspace!

a house commented Wed Jun 12 07:44:09 UTC 2013:

We have joined your feed and show toward seeking greater amounts of your magnificent post. Also, I've shared your site within my myspace!

yahoo commented Fri Jul 18 04:56:57 UTC 2014:

It's very straightforward to find out any matter on net as compared to textbooks, as I found this piece of writing at this site.

My blog - yahoo

Want to comment?

(not made public)


(use plain text or Markdown syntax)