Make a mail server gateway

0
55
views

The NetBSD project is a good place to start when looking for a mail server. Straight forward and precise, NetBSD can power some of the largest networks on the internet. To install NetBSD, follow the easy to understand installation wizard. There are several differences found in NetBSD than FreeBSD or OpenBSD.

Simply add these configuration settings to the rc.conf file in /etc

rc_configured=YES
ifconfig_fxp0=192.168.0.10/24
ifconfig_fxp1=10.1.10.100/24
sshd=YES
hostname=mail.nvita.org
sendmail_enable=yes
defaultroute=10.1.10.1
samba=YES
smbd=YES
nmbd=YES

As you can you see here, ifconfig_fxp1 incorporates the input “inet” and “netmask” but in IP notation, where the subnet mask is abriviated. These provisions are an example of how NetBSD is a viable network operating system. For example, make sure the correct default route is listed correctly. To list the correct default route, make sure the entry coresponds to the interface that will answer internet data.

If your internet service provider includes equipment which assigns a dynamic ipaddress, update the address:

dhclient fxp1

Change the new address in /etc/rc.conf

Next, install the post-fix mail system. Run the following commands:

pkg_add ftp://ftp.netbsd.org/pub/NetBSD/packages/current-packages/NetBSD-4.0/i386/All/postfix-2.6.20080903.tgz

Find the correct postfix configuration file with the find command:

find / -name “master.cf”

/usr/share/examples/postfix/master.cf
/usr/pkg/share/examples/postfix/master.cf
/usr/pkg/etc/postfix/master.cf
/usr/local/sbin/master.cf
/var/db/pkg.refcount/files/usr/pkg/etc/postfix/master.cf
/etc/postfix/master.cf

The default configuration file that postfix will use is located in the /etc directory. The master.cf configuration file determines what network interfaces to use. Here, we would like to use all the available interfaces such that users are able to send mail on the internal network as well as the external network:

vi /etc/postfix/master.cf

Press the ESC key

Type :ins

Type: smtp inet n – n – – smtpd

Strike CTRL – C

Press the ESC key

Type: wq!

Next modify the main.cf file in the /etc directory:

Type vi /etc/postfix/main.cf

Press the ESC key

Type :ins

Type:

myhostname = mail.nvita.org
inet_interfaces = mail.nvita.org
mydomain = nvita.org
myorigin = mail.nvita.org
virtual_alias_maps= hash:/etc/postfix/virtual
virtual_alias_domains = nvita.org, inverselog.com, giantfood.nl
mynetworks = 192.168.0.0/24, 127.0.0.0/8, 10.1.10.0/24

Strike the ENTER key

Strike CTRL – C

Press the ESC key

Type :wq!

Next, create the file /etc/postfix/virtual:

Type vi /etc/postfix/virtual

Press the ESC key

Type :ins

@nvita.org squirrel
mkearney@nvita.org squirrel

Strike the ENTER key

Strike CTRL – C

Press the ESC key

Type :wq!

Now create the virtual user database used by the postfix deamon:

postmap virtual

Next, add new users to the system, since you don’t want to use the root account for your daily work (yes, we’re serious about that!). NetBSD offers the useradd(8) utility to create user accounts. Accounts that can su(1) to root are required to be in the “wheel” group. This can be done when the account is created by specifying a secondary group:

useradd -m -G wheel squirrel

passwd squirrel

Start the postfix server:

/etc/rc.d/postfix start

Now the SMTP server should respond to quires. You can check the status of the process by using the netstat command:

netstat -a

tcp 0 0 mail.smtp *.* LISTEN
tcp 0 0 mail.smtp *.* LISTEN
tcp 0 0 localhost.smtp *.* LISTEN

If the server does not respond to your configuration, most likely you have added addtional perameters to the configuration file. If this configuration is modified for any reason, postfix will fail.

Next install a POP deamon to check the virtual mailboxes:

pkg_add -R ftp://ftp.netbsd.org/pub/NetBSD/packages/current-packages/NetBSD-4.0/i386/All/dovecot-1.1.6.tgz

Find the correct dovecot configuration with the find command:

find / -name “dovecot.conf”

/usr/pkg/etc/dovecot.conf
/var/db/pkg.refcount/files/usr/pkg/etc/dovecot.conf

The default configuration file that postfix will use is located in the /usr/pkg/etc/ directory. The dovecot.conf configuration file determines what network interfaces to use. Here, we would like to use all the available interfaces such that users are able to retrive mail on the internal network as well as the external network:

vi /usr/pkg/etc/dovecot.conf

Press the ESC key

Type :ins

protocol pop3 {
listen = *:110
}

disable_plaintext_auth = no

Strike the ENTER key

Strike CTRL – C

Press the ESC key

Type :wq!

Start the POP deamon:

dovecot start

If you would like to add additional users, use the useradd utility:

useradd -m -G wheel mkearney

passwd mkearney

Then modify the /etc/postfix/virtual file and create the database once more:

postmap virtual

Make sure your DNS server is setup correctly to direct mail to your new server. Zoneedit.com makes this easy:

Now you can configure a client e-mail program to use the new mail server. Microsoft Outlook is a fairly good client and is easy to setup.

Click Tools, Options:

Click Mail Setup, Email Accounts

Click New

Click Next and enter the account information:

Click Next Click Next

Click Finish, Close, OK

The NetBSD mail server is now ready to send and recive mail either from the local system or Workstation clients. NetBSD is a reliable cost effective alternative operating system that can handle thousands of users. Sometimes it is more adventageous to use the Microsoft Exchange Server and use the NetBSD server as a relay host.

Exchange server is a convient mail server to use with the Microsoft Office system. It has a number of features unavailable to other mail clients and is easy to manage. For instance with Exchange server, you can backup and retrieve individual email messages from the server. However this convienince does not go without a price. Exchange server is a volitle liability that has many security flaws and is unstable within the scope of the public. It can be rendered useless in a matter of minutes and the responsiblity for an entire organization could fall on the administrator. With NetBSD and Postfix, it is possible to use Exchange server as a viable mail server.

To configure postfix to use exchange server,

Type vi /etc/postfix/main.cf

Press the ESC key

Type :ins

Type:

myhostname = mail.nvita.org
inet_interfaces = 192.168.0.10, 10.1.10.100
mydomain = nvita.org
myorigin = mail.nvita.org
relay_recipient_maps = hash:/etc/postfix/exchange
transport_maps = hash:/etc/postfix/transport
relay_domains = nvita.org, inverselog.com, giantfood.nl
mynetworks = 192.168.0.0/24, 127.0.0.0/8, 10.1.10.0/24

Strike the ENTER key

Strike CTRL – C

Press the ESC key

Type :wq!

virtual_alias_maps and virtual_alias_domains are removed. Comment them out with the pound sign:

#virtual_alias_maps= hash:/etc/postfix/virtual
#virtual_alias_domains = nvita.org, inverselog.com, giantfood.nl

inet_interfaces lists numeric ip addresses. To effect, the Postfix deamon cannot communicate across multiple interfaces if they are not specified.  

Next, create the file /etc/postfix/exchange:

Type vi /etc/postfix/exchange

Press the ESC key

Type :ins

mkearney@nvita.org OK

Strike the ENTER key

Strike CTRL – C

Press the ESC key

Type :wq!

Now create the exchange user database used by the postfix deamon:

postmap /etc/postfix/exchange

Next, create the file /etc/postfix/transport:

Type vi /etc/postfix/transport

Press the ESC key

Type :ins

* smtp:squirrelserver.nvita.org

Strike the ENTER key

Strike CTRL – C

Press the ESC key

Type :wq!

Now create the transport relay database used by the postfix deamon:

postmap /etc/postfix/transport

Install Exchange Server. These settings set the Receive Connector to relay mail from the NetBSD server:

Set-ReceiveConnector -Identity “Default squirrelserver” -PermissionGroups “AnonymousUsers”

Get-ReceiveConnector “Default SQUIRRELSERVER” | Add-ADPermission -User “NT AUTHORITY\ANONYMOUS LOGON ” -ExtendedRights “ms-Exch-SMTP-Accept-Any-Recipient”

Start the server. The postfix server also includes a simple mail que, which can store mail messages in the event that the Exchange server should fail. Exchange server fails and does not keep mail messages when there is not enough disk space. For example, the latest version of Exchange Server keeps 8 gigabytes of log files over a very short period of time. Acting as a backup and a go between; the postfix mail que will be delivered to the exchange server and to all Microsoft Office clients connected to the server immediately with the command:

/etc/rc.d/postfix start

Note that postfix will deny connections to the mail server if the ip address listening on the connection is not listed in “mynetworks” For example your external ip address!

More notes: Using software programs like DSPAM and Spamassasin, the NetBSD server can catch some spam emails but not all of them:

[Postfix] (LMTP) -> [DSPAM]                     [Postfix] -> [Microsoft Exchange] { Delivery }
                       |___ (SMTP Reinjection) ____|

However, it’s more effective to keep your hand on the delete button.

NetBSD is a reliable operating system that is particularly useful for mail servers and other internetwork software programs, with these precise configuration settings you can implement internet and intranet mail in a few hours.

LEAVE A REPLY

Please enter your comment!
Please enter your name here