I'm running Debian on a Raspberry Pi colocated with a static IP address. I want to host my domain and I have a few questions.

I run lighttpd and can access my site via the static IP address. Note, this is static content, a few html pages, just a hobby site. I'd like to know what I'd need to install and configure to:

  1. Host my domain
  2. Host email for my domain

With an emphasis on security. As a sub question my domain is registered but they say they need two name servers for me to point it elsewhere. How can I achieve this on my own?


2 Answers 2


To "host your own domain":

  • You need to first purchase a domain from a domain registrar. It sounds like you've done this.
  • You need -- somewhere on the internet -- nameservers that are responsible for mapping hostnames (like www.mydomain.com) to ip addresses. Many registrars provide DNS services for free. There are also some free third-party DNS servers, although in this you get what you pay for. There are a variety of high-quality, low cost dns hosting companies that you could investigate. You could of course also run your own nameservers (using bind or some other dns software), but as you have noticed most registrars want you to have more than a single nameserver. You could work out an arrangement with a friend to cross-host your domains,
  • If you want to host a website, you need to install and configure a webserver, and it sounds like you've already got that working.

So other than getting some nameservers provisioned you're all set.

To "host email for your domain":

  • You need (well, should) establish MX records in DNS that indicate what servers are responsible for handling mail for your domain. You can actually get away without this if your domain has an A record, but it's good form (and offers you flexibility you wouldn't otherwise have). The MX record points to a hostname which must also be available in DNS.
  • On the host pointed to by your MX record, you need to run some sort of "MTA" (mail transfer agent), like Postfix or Sendmail or Exim or something. I use Postfix.
  • If you want to be able to access email via POP or IMAP (as opposed to simply forwarding it elsewhere), you would also need to install something like Dovecot or Courier or Cyrus IMAPD to provide the POP/IMAP service.

If you're concerned about security, you'll want to configure all of your email-related services to support SSL, and you'll want your MTA to require authentication for outbound email (if you plan on using it for outbound mail).

For what it's worth: while I host my own MX server, I don't actually receive any email there -- it just forwards mail to other accounts (mostly Gmail these days, but also elsewhere).

There's lots of good documentation there on how to set things up. If you have questions about specific problems, posting to superuser or the unix/linux sites is probably a good place to start.

  • larsks is correct, there is no reason to hosting own personal mail server if you don't want to learn the technical way. I prefer Google Apps as mail server instead hosting your own mail server. Reliable, SPAM-free and no pain. Commented Aug 13, 2013 at 14:52
  • In addition to what Larsks said, for the mail server you will also need to get the Colo facility to enter your server's name into their reverse (PTR records) DNS. This is in addition to entering an A and an MX record in your DNS (forward) servers. Only the Colo facility's DNS servers can properly resolve the PTR record. If your A and PTR don't match most mail servers will count you as spam. Commented Aug 13, 2013 at 16:30
  • @RodMacPherson Thank you for this additional information. Very useful & informative Commented Aug 14, 2013 at 15:13
  • Has anyone of you set up Google Apps with pi?
    – nikhil
    Commented Apr 12, 2014 at 19:59

It's not related to Raspberry Pi. By the way, you need a DNS hosting for this. There are free DNS hosting sites available. My suggestion is freedns.afraid.org. They will give you 4 DNS nameservers and you will have to register those nameservers on your domain registrar. Then create AAA,MX DNS records on freedns.afraid.org for your static IP address.

  • I know it's not specific to Raspberry Pi, as you can see someone at serverfault.com thought otherwise and moved it here. Thanks for the DNS info. Commented Aug 13, 2013 at 10:48
  • 2
    This question doesn't pass the "related to professional system administration" filter for serverfault...if you hadn't mentioned raspberry pi in the question it would probably have ended up on superuser.
    – larsks
    Commented Aug 13, 2013 at 13:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.