2010年6月

Build your Sendmail Relay Server in your LAN

sendmail

I installed a sendmail relay server in my LAN so that other servers can use it to send emails. The following is how I did the configuration in a Ubuntu 9 machine.

1. First you need to install sendmail package.

2. After installation, you need to do the following configuration:

(1) Sendmail Master Configuration File: /etc/mail/sendmail.mc

# vi sendmail.mc

To enable relay on a specific IP, you need to change SMTP Daemon's IP address. By default, it is 127.0.0.1 which is your localhost loopback address. This setting only allows you to send email from localhost. If you want other servers to use this server as relay to send emails, you much change to a valid IP address in your LAN, for example, it can be 192.168.0.88. In order to do so, you need to change the line 57 and 59 to as below:

DAEMON_OPTIONS('Family=inet, Name=MTA-v4, Port=smtp, Addr=192.168.0.88')dnl
DAEMON_OPTIONS('Family=inet, Name=MSP-v4, Port=submission, M=Ea, Addr=192.168.0.88')dnl


Please replace 192.168.0.88 with your real IP address. You also need to change following two lines at 100 and 104:

LOCAL_DOMAIN('yourhost.yourdomain')dnl
MAILER('smtp')dnl


Next step, you need to compile the sendmail.mc file to sendmail.cf file which will be actually used by sendmail. You need to type:

# m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf

You need to restart the sendmail server to make the change effective:

# /etc/init.d/sendmail restart

To check if the Sendmail is listening on an IP and a specific port, you can type:

# netstat -aunt

To check if the SMTP Port is open and listening from another server, you can type:

# nmap -v -sT 192.168.10.10 (IP address of this SMTP server)

(2) Configure the Access Control file: /etc/mail/access

# vi access

If you want to allow 192.168.0.99 to relay, add the following line:

Connect:192.168.0.99 RELAY

You also need to compile the access file to access.db file.

# makemap hash /etc/mail/access.db < /etc/mail/access

You need to restart the sendmail service to make it effective.

3. Sendmail Troubleshooting


If the local domain emails can not be delivered, and if your email service is hosted by an outside ISP, like Gmail (Google App.), please make sure your DNS setting will let you to resolve the correct MX record. Usually, you can set the external DNS server as your DNS server.

For example,

# vi /etc/resolv.conf

nameserver 206.0.6.60


You need to replace 206.0.6.60 with your real DNS Server's IP address provided by your ISP.

How to Change the Hostid of a Sun Solaris Machine?

Solaris

The Hostid is a globally unique ID for a Sun Solaris Machine. Sometimes, you need to change this hostid for whatever purpose. For example, you current machine is down for hardware failure and you purchased a new machine. However, all your current running software are based on this old hostid, and you must bring the new machine up within a very short time. The quick solution is to change the new machine's hostid to be as same as the old one.

There are several ways to do so, including using a program to flush NVRAM which will change the hostid permanently. I did following experiment to change the Hostid in a Solaris 10 machine temperately. It adds several lines in the /etc/rc2.d/S20sysetup file. If you want to restore the original hostid, you just need to remove these lines and reboot the machine.

My environment is:
# uname -a
SunOS myhostname 5.10 Generic_127111-11 sun4v sparc SUNW,SPARC-Enterprise-T5120


Step 1: Calculate your new Hostid

(1) If you want to change your hostid to 800a1b2c (hexdecimal format), you need to calculate its decimal first. You can use following online calculator to do this.

http://www.easycalculation.com/hex-converter.php

Hexdecimal: 800a1b2c
Decimal: 2148145964

(2) Then, divide the decimal number to three parts:
2148
1459
64

(3) You treat the above 3 parts as string combined by ASCII Characters. Use following calculator to get the HEX value:
32 31 34 38
31 34 35 39
36 34

http://www.easycalculation.com/ascii-hex.php

You need to pad 0s to the 3rd part. So it will become:
32313438
31343539
36340000

Step 2: Save your original Hostid:
cd /etc
cat hostid > hostid.orig


Step 3: Change the /etc/rc2.d/S20sysetup file
At the bottom of this file, add following code:
# Change Host ID to Hexdecimal: 800a1b2c
# It's Decimal Value: 2148145964
# Divide to 3 parts: 2148 1459 64
# Hex value of the above ASCII Characters:
# 32 31 34 38
# 31 34 35 39
# 36 34
# After padding:
# 32313438
# 31343539
# 36340000
# The following code will apply the new Hostid
adb -w -k /dev/ksyms /dev/mem </dev/null
hw_serial/W 0x32313438
hw_serial+4/W 0x31343539
hw_serial+8/W 0x36340000
END


Step 4: If you want to make the new hostid effective without reboot the machine, just type:
#sh S20sysetup

Otherwise, you can reboot the machine. If you want restore the original factory hostid, you can just comment out the above several lines of code in S20sysetup file.

9 Must Known Websites for .NET Developers

As an .NET application developer, the following 9 websites are my most frequently visited websites.

1. ASP.net



I learned .NET and get a lot of resources from this website.

2. MSDN



MSDN's primary web presence at msdn.microsoft.com is a collection of sites for the developer community that provide information, documentation, and discussion which is authored both by Microsoft and by the community at large. Recent emphasis on and incorporation of applications such as forums, blogs, library annotations, and social bookmarking are changing the nature of the MSDN site from a one-way information service to an open dialog between Microsoft and the developer community.

3. CodeProject



I downloaded many source code from this website. There are also many very good articles.

4. DotNetNuke



5. 4GuysFromRolla.com



6. DevSource



7. DevX



8. Chanel 9



Many videos introducing very cool and latest Microsoft technologies.

9. ScottGu's Glog


The About Me Page of this blog:

My name is Scott Guthrie, and I am a Corporate Vice President in the Microsoft Developer Division. I run the development teams that build the following products/technologies:

* CLR and the core .NET Base Class Libraries
* ASP.NET
* Silverlight
* WPF
* IIS 7.0
* Visual Studio Tools for ASP.NET, WPF, Silverlight and Mobile