# Question about DNSmasq and MX record



## danaeckel (Mar 12, 2013)

Greetings,
   I am looking to add mail services to my gate/IPFW server I am trying to get a handle on DNSMasq, but can't find real answers on the net how I should configure it. Would it be as simple as the following?


```
# Change these lines if you want dnsmasq to serve MX records.

# Return an MX record named "maildomain.com" with target
66.234.44.33(public IP) and preference 50
mx-host=bsd-srv.home, bsd-srv.home,50 (This is the host name of the server)

# Set the default target for MX records created using the localmx option.
#mx-target=servermachine.com

# Return an MX record pointing to the mx-target for all local
# machines.
#localmx

# Return an MX record pointing to itself for all local machines.
#selfmx
```

Are my thoughts correct?


----------



## gqgunhed (Mar 12, 2013)

Hi danaeckel,

Could you please clarify what exactly you are trying to accomplish?

If you set your MX record for your internal domain (I don't think .home is your internet domain) this will be served as answer to your internal clients ONLY.

So roughly speaking, if a client on your internal network wants to send an email to user@home then your dnsmasq daemon will respond with "send it to bsd-srv.home".

Does this help?
https://en.wikipedia.org/wiki/Mx_record


----------



## danaeckel (Mar 13, 2013)

Well, what I am trying to do is understand mail servers, and doing so by trying to make one. I am hung up on the MX record part of it. So from now what I understand I would use the following.


```
# Change these lines if you want dnsmasq to serve MX records.

# Return an MX record named "maildomain.com" with target
66.234.44.33(public IP) and preference 50

# Set the default target for MX records created using the localmx option.
#mx-target=servermachine.com

# Return an MX record pointing to the mx-target for all local
# machines.
#localmx

# Return an MX record pointing to itself for all local machines.
#selfmx
```


----------



## gqgunhed (Mar 13, 2013)

> Well, what I am trying to do is understand mail servers, and doing so by trying to make one. I am hung up on the MX record part of it. So from now what I understand I would use the following.



Hmm, the MX record is part of the DNS system. So it helps e.g. mail servers to find the next "hop" to deliver an email to. "Just" defining an MX record with your public IP for your internal email clients will not have the desired effect.

If you want to create an externally addressable SMTP server you should first get one up and running within your local subnet/domain. If you just open up an SMTP server to the internet while not knowing what you are doing will surely get your box owned (e.g. spam relay).

mail/postfix(SMTP) and mail/dovecot(IMAP) are some of the possible choices. Maybe use mail/fetchmail to collect mails from external accounts and serve them internally via your own IMAP server.

Just some thoughts for you to get a grip on the email ecosystem. (It's not just setting up some DNS records  )


----------

