Install/iRedMail/FreeBSD.Jail

From iRedMail

(Difference between revisions)
Jump to: navigation, search
(Prepare Jail)
(Create Jail and install iRedMail)
(17 intermediate revisions not shown)
Line 1: Line 1:
__TOC__
__TOC__
-
 
-
----
 
-
This is a DRAFT, still working in progress. Don't try it on production server.
 
-
----
 
= Summary =
= Summary =
 +
 +
This tutorial describes how to create a FreeBSD Jail with ezjail, and install the latest iRedMail in Jail.
 +
 +
Notes:
 +
 +
* This tutorial was tested with FreeBSD 9 and the latest ports tree, but it should work on FreeBSD 8 and 10 too.
 +
* All backends available in iRedMail (OpenLDAP, MySQL, PostgreSQL) were tested, work like a charm. :)
 +
 +
= Requirements =
= Requirements =
-
* iRedMail-0.8.2 or later releases.
 
-
= Prepare Jail =
+
* iRedMail-0.8.3 or later releases.
 +
* Port '''sysutils/ezjail''' for FreeBSD.
 +
 
 +
= Preparation =
 +
 
 +
* Prepare IP address used for Jail. Here we use internal IP address '''172.16.122.244''' for example. We created an alias IP address on network interface '''em0''', so we have below setting in '''/etc/rc.conf''' for this IP address:
 +
{{cfg|/etc/rc.conf|<pre>
 +
ifconfig_em0_alias0="inet 172.16.122.244 netmask 255.255.255.0"
 +
</pre>}}
 +
 
 +
= Create Jail and install iRedMail=
* Install ezjail:
* Install ezjail:
{{cmd|<pre>
{{cmd|<pre>
Line 18: Line 32:
* Add below setting in /etc/rc.conf:
* Add below setting in /etc/rc.conf:
{{cfg|/etc/rc.conf|<pre>
{{cfg|/etc/rc.conf|<pre>
 +
# Start ezjail while system start up
 +
ezjail_enable="YES"
 +
 +
# Set security.jail.allow_raw_sockets=1 to allow PostgreSQL initial database.
jail_sysvipc_allow="YES"
jail_sysvipc_allow="YES"
</pre>}}
</pre>}}
-
* Reboot system.
+
* Rebooting system is required after changing '''/etc/rc.conf'''.
{{cmd|<pre># reboot</pre>}}
{{cmd|<pre># reboot</pre>}}
-
* After system start up, create Jail for domain name '''mx.example.com''', bound to internal IP address 172.16.122.244. All files are placed under '''/jails/mx.example.com''':
+
* After system start up, create the base jail that all jails we created later will use:
 +
{{cmd|<pre>
 +
# ezjail-admin install -p
 +
</pre>}}
 +
 
 +
* create Jail for domain name '''mx.example.com''', bound to internal IP address 172.16.122.244. All files are placed under '''/jails/mx.example.com''':
{{cmd|<pre>
{{cmd|<pre>
# ezjail-admin create -r /jails/mx.example.com mx.example.com 172.16.122.244
# ezjail-admin create -r /jails/mx.example.com mx.example.com 172.16.122.244
 +
</pre>}}
 +
 +
* Set hostname of Jail in '''/jails/mx.example.com/etc/rc.conf''':
 +
{{cfg|/jails/mx.example.com/etc/rc.conf|<pre>
 +
hostname="mx.example.com"
</pre>}}
</pre>}}
Line 34: Line 62:
</pre>}}
</pre>}}
-
* In Jail, update /etc/resolv.conf with valid DNS server address(es).
+
* List all Jails:
-
* In Jail, install bash:
+
{{cmd|<pre>
{{cmd|<pre>
-
# pkg_add -r bash-static
+
# ezjail-admin list
 +
STA JID  IP              Hostname                          Root Directory
 +
--- ---- ---------------- --------------------------------- ------------------------
 +
DS  1    172.16.122.244  mx.example.com                    /jails/mx.example.com
</pre>}}
</pre>}}
-
* Start iRedMail installer with your Jail ip address:
+
We can now enter this Jail:
{{cmd|<pre>
{{cmd|<pre>
-
# bash
+
# ezjail-admin console mx.example.com
 +
</pre>}}
 +
 
 +
* In Jail, update '''/etc/resolv.conf''' with valid DNS server address(es). For example:
 +
{{cfg|Jail: /etc/resolv.conf|<pre>
 +
nameserver 172.16.122.2
 +
</pre>}}
 +
 
 +
* In Jail, install binary package '''bash'''. Required by iRedMail.
 +
{{cmd|<pre>
 +
Jail # pkg_add -r bash-static
 +
</pre>}}
 +
 
 +
* In Jail, Start iRedMail installer with your Jail ip address:
 +
{{cmd|<pre>
 +
Jail # bash
bash # cd /root/iRedMail/
bash # cd /root/iRedMail/
-
bash # LOCAL_ADDRESS='192.168.1.2' bash iRedMail.sh
+
bash # LOCAL_ADDRESS='172.16.122.244' bash iRedMail.sh
</pre>}}
</pre>}}
 +
 +
That's all.

Revision as of 06:07, 28 November 2012

Contents


Summary

This tutorial describes how to create a FreeBSD Jail with ezjail, and install the latest iRedMail in Jail.

Notes:

  • This tutorial was tested with FreeBSD 9 and the latest ports tree, but it should work on FreeBSD 8 and 10 too.
  • All backends available in iRedMail (OpenLDAP, MySQL, PostgreSQL) were tested, work like a charm. :)


Requirements

  • iRedMail-0.8.3 or later releases.
  • Port sysutils/ezjail for FreeBSD.

Preparation

  • Prepare IP address used for Jail. Here we use internal IP address 172.16.122.244 for example. We created an alias IP address on network interface em0, so we have below setting in /etc/rc.conf for this IP address:
File: /etc/rc.conf
ifconfig_em0_alias0="inet 172.16.122.244 netmask 255.255.255.0"

Create Jail and install iRedMail

  • Install ezjail:
Terminal:
# cd /usr/ports/sysutils/ezjail/
# make install clean
  • Add below setting in /etc/rc.conf:
File: /etc/rc.conf
# Start ezjail while system start up
ezjail_enable="YES"

# Set security.jail.allow_raw_sockets=1 to allow PostgreSQL initial database.
jail_sysvipc_allow="YES"
  • Rebooting system is required after changing /etc/rc.conf.
Terminal:
# reboot
  • After system start up, create the base jail that all jails we created later will use:
Terminal:
# ezjail-admin install -p
  • create Jail for domain name mx.example.com, bound to internal IP address 172.16.122.244. All files are placed under /jails/mx.example.com:
Terminal:
# ezjail-admin create -r /jails/mx.example.com mx.example.com 172.16.122.244
  • Set hostname of Jail in /jails/mx.example.com/etc/rc.conf:
File: /jails/mx.example.com/etc/rc.conf
hostname="mx.example.com"
  • Start Jail.
Terminal:
# /usr/local/etc/rc.d/ezjail restart
  • List all Jails:
Terminal:
# ezjail-admin list
STA JID  IP               Hostname                          Root Directory
--- ---- ---------------- --------------------------------- ------------------------
DS  1    172.16.122.244   mx.example.com                    /jails/mx.example.com

We can now enter this Jail:

Terminal:
# ezjail-admin console mx.example.com
  • In Jail, update /etc/resolv.conf with valid DNS server address(es). For example:
File: Jail: /etc/resolv.conf
nameserver 172.16.122.2
  • In Jail, install binary package bash. Required by iRedMail.
Terminal:
Jail # pkg_add -r bash-static
  • In Jail, Start iRedMail installer with your Jail ip address:
Terminal:
Jail # bash
bash # cd /root/iRedMail/
bash # LOCAL_ADDRESS='172.16.122.244' bash iRedMail.sh

That's all.

Personal tools