Tuesday, August 30, 2011

Motion and a low-cost home surveillance system


I have this Creative Live webcam from years ago. While it works perfectly well, its resolution is no better than my iPhone 3Gs…
So, rather than throwing it away or let it sit around idle, I connected it into the Ubuntu server, installed the “motion”package and turned it into a low-cost web surveillance system…

As you shall see, it is a straight-forward procedure:
1. On the Ubuntu server, to install motion, enter:

# apt-get install motion
2. Configure "motion.conf" file to enable remote access (web browser):
File: /etc/motion/motion.conf
# Restrict webcam connections to localhost only (default: on)
webcam_localhost off
# Restrict control connections to localhost only (default: on)
control_localhost off
3. Lastly, restart “motion” daemon:
/etc/init.d/motion restart
The webcam’s image should be available through the url “http://:8081”

Monday, August 22, 2011

BSD Mail/ SendMail 101

While working on HE's IPv6 certification, I gathered some useful experiences with setting up a basic mail server on FreeBSD so I thought it would be worthwhile to do a quick blog on this...
Overview
Firstly, the Mail User Agent (MUA) is what the user uses to compose emails. BSD Mail is the default MUA which comes with FreeBSD. Its syntax is as follows (for composing emails):
#mail
Subject:
[Mail Content]
. Remember to enter a “.” in a new line to end writing the email
EOT
Secondly, the Mail Transfer Agent (MTA) is what interacts with the rest of the internet i.e. the MTA is responsible for sending and receiving emails. Sendmail is the default FreeBSD's MTA.
I configured the following files (under /etc/mail) to have this setup working:
1. "virtualusertable" - the email address accepted and local user to forward the email to.
2. "access" - like an ACL for emails, it identifies the incoming/ outgoing email addresses permitted/ denied.
3. local-host-names - email domain accepted into local machine.
In /etc/rc.conf, I have also added "sendmail_enable=yes"; along with setting my NAT gateway to accept TCP 25.
For those interested in more details, FreeBSD Handbook has dedicated a page on Sendmail. According to this page, there are certain occasions when either a "make" or process restart is required for the configuration changes to take effect but in the interest of keeping this post simple I will not go into any details here.
That seems to be it, Sendmail was running fine and accepting emails:
home-unix6# /etc/rc.d/sendmail status
sendmail is running as pid 1170.
sendmail_clientmqueue is running as pid 1174.
On DNS
Also worth noting is when you send an email, the local MTA actually perform two DNS queries:
1. MX (Mail Exchange) query against the destination email domain - to resolve the mail server's hostname.
2. A (or AAAA) query against the MX response, to resolve the IP address of the receiving SMTP server.
P.S. As a test, I tried sending an email to my service provider, iiNet email account, using this machine. Interesting enough, I received an error message informing me the email I sent has been rejected due to the "poor reputation" of the MTA...at least I can be sure my setup is working (there is a Whirlpool forum on this from others with similar experiences).

Hurricane Electric IPv6 Certification

Hurricane Electric has a free IPv6 Certification available online.

I used a laptop and a FreeBSD server with the related open-source packages installed, and managed to reach the Sage level.

IPv6 Certification Badge for JonathonL

I recommend this test for anybody who wish to gain further exposure to IPv6 technologies.