blog@ntecs

About technology, programming and languages

Publishing SPF Records

The Sender Policy Framework (SPF) is today used by many mail servers or SPAM filters to determine if an email sent as originating from user@example.net really originates from example.net or if it was highjacked by a spammer. An SPF-enabled receiving mail server checks both, the fully qualified domain name (FQDN) as specified in the HELO or EHLO announce message sent by the mail client, and the domain of the envelop email address (MAIL FROM) against the SPF record(s) stored in DNS for that domain.

Example

As an example, I own two domains, ntecs.de and michaelonroad.de. I run a SMTP server on the domain mail.ntecs.de. As such, I need two SPF DNS records for domain ntecs.de:

1
2
3
# DNS zone for domain ntecs.de
@ IN TXT "v=spf1 mx -all"
mail IN TXT "v=spf1 a -all"

The first line tells the SPF enabled mail server that all email in the form of user@ntecs.de MUST exclusively be sent by one of the servers listed as a Mail Exchange (MX) record of the same domain. The MX record resolves to an IP address which is then checked against the IP address of the connection. The second line is used to check against the EHLO (or HELO) announcement. For example my SMTP server announces itself with a EHLO mail.ntecs.de. Only the IP address of the mail.ntecs.de server is accepted here in this case (or more specifically the IP address it’s A record resolves to).

For my second domain michaelonroad.de I would only need one SPF record:

1
2
# DNS zone for domain michaelonroad.de
@ IN TXT "v=spf1 mx -all"

This is because I use mail.ntecs.de even for sending mail from user@michaelonroad.de. Also note that in my case I only run one server for both incoming and outgoing mail (for all domains).

Cross-compiling for DragonFly BSD

In this short article I want to show the basics of how to generate an executable for the DragonFly BSD operating system from a Linux system. This process is called cross compiling. The reason why I investigated into this topic was that I wanted to cross-compile the Rust compiler.

All you need is clang installed and a DragonFly BSD installer ISO image which you can obtain from it’s homepage. The application we want to cross-compile is the one listed below:

1
2
3
4
5
6
#include <stdio.h>

int main(int argc, char **argv) {
  printf("Hello World\n");
  return 0;
}

The first step is to mount the ISO image into the local directory ./iso because we need the header files for compilation as well as the files crt{1,i,begin}.o and libgcc.a for linking.

1
2
mkdir iso
sudo mount -o loop,ro DragonFly-x86_64-LATEST-ISO.iso ./iso

After that, we are ready to compile our simple Hello World example application. To compile we need to specify the corresponding include and link paths and tell the compiler the target we want to create code for, in our case this is x86_64-pc-dragonfly-elf.

1
2
3
4
5
clang -I./iso/usr/include \
      -L./iso/usr/lib -L./iso/usr/lib/gcc47 \
      -B./iso/usr/lib -B./iso/usr/lib/gcc47 \
      -target x86_64-pc-dragonfly-elf \
      -o hw hw.c

Running file hw should now display something like this:

hw: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked
    (uses shared libs), for DragonFly 3.0.702, not stripped

VoilĂ , there it is, our binary for DragonFly BSD.