diff -up zabbix-1.8/src/libs/zbxmedia/jabber.c.orig zabbix-1.8/src/libs/zbxmedia/jabber.c
--- zabbix-1.8/src/libs/zbxmedia/jabber.c.orig	2009-12-07 14:43:56.000000000 -0500
+++ zabbix-1.8/src/libs/zbxmedia/jabber.c	2010-01-07 13:55:07.000000000 -0500
@@ -25,6 +25,9 @@
 
 #include <iksemel.h>
 
+/* For SRV lookups */
+#include <resolv.h>
+
 static void
 zbx_io_close (void *socket)
 {
@@ -334,6 +337,103 @@ static void on_log (jabber_session_p ses
 
 /******************************************************************************
  *                                                                            *
+ * Function: srv_lookup_jabber                                                *
+ *                                                                            *
+ * Purpose: lookup the REAL jabber servername                                 *
+ *                                                                            *
+ * Return value: SUCCEED on successfull                                       *
+ *               FAIL - otherwise                                             *
+ *                                                                            *
+ * Author: Edward Rudd                                                        *
+ *                                                                            *
+ ******************************************************************************/
+
+typedef union
+{
+	HEADER hdr;
+	u_char buf[1024];
+} querybuf;
+
+static int srv_lookup_jabber(char *domain, char *realserver, int buflen, int *realport)
+{
+	querybuf answer;
+	HEADER *hp;
+	char request[1024];
+	int ancount, qdcount;
+	unsigned char *msg, *eom, *cp;
+	int dlen, type, aclass, pref, weight, port;
+	long ttl;
+	char hostbuf[256];
+	int rsize, answerno;
+
+	zbx_snprintf(request, 1024, "_xmpp-client._tcp.%s", domain);
+
+	rsize = res_query (request,
+		C_IN, T_SRV, (unsigned char *) &answer, sizeof (answer));
+
+	if (rsize < (int) sizeof(HEADER)) {
+		zabbix_log(LOG_LEVEL_DEBUG, "JABBER: failed DNS response for server %s",domain);
+		return FAIL;
+	}
+	
+	hp = (HEADER *)&answer;
+	qdcount = ntohs(hp->qdcount);
+	ancount = ntohs(hp->ancount);
+
+	msg = (unsigned char *) (&answer);
+	eom = (unsigned char *) (&answer) + rsize;
+	cp = (unsigned char *) (&answer) + sizeof(HEADER);
+	
+	while (qdcount-- > 0 && cp < eom)
+	{
+		rsize = dn_expand (msg, eom, cp, (char *)hostbuf, 256);
+		if (rsize < 0)
+		{
+			zabbix_log(LOG_LEVEL_DEBUG, "JABBER: failed DNS responsse for server %s",domain);
+			return FAIL;
+		}
+		cp += rsize + QFIXEDSZ;
+	}
+	answerno = 0;
+
+	// loop through responses
+	while (ancount-- > 0 && cp < eom)
+	{
+		rsize = dn_expand (msg, eom, cp, (char *)hostbuf, 256);
+		if (rsize < 0)
+		{
+			zabbix_log(LOG_LEVEL_DEBUG, "JABBER: failed DNS responsse for server %s",domain);
+			return FAIL;
+		}
+		cp += rsize;
+		NS_GET16(type, cp);
+		NS_GET16(aclass, cp);
+		NS_GET32(ttl, cp);
+		NS_GET16(dlen, cp);
+		if (type != T_SRV) {
+			cp += dlen;
+			continue;
+		}
+		NS_GET16(pref, cp);
+		NS_GET16(weight, cp);
+		NS_GET16(port, cp);
+		rsize = dn_expand(msg, eom, cp, (char *)hostbuf, 256);
+		if (rsize < 0)
+			break;
+		cp += rsize;
+
+		/** FIXME: Probable should go through ALL responses and do proper load balancing based on priorities and weights */
+		zbx_strlcpy(realserver, hostbuf, buflen);
+		*realport = port;
+		return SUCCEED;
+
+		answerno++;
+	}
+	return FAIL;
+}
+
+/******************************************************************************
+ *                                                                            *
  * Function: connect_jabber                                                   *
  *                                                                            *
  * Purpose: Connect to jabber server                                          *
@@ -354,6 +454,9 @@ static int connect_jabber(const char *ja
 	char		*buf = NULL;
 	int		iks_error, timeout, ret = FAIL;
 
+	char realserver[256];
+	int realport;
+
 	zabbix_log(LOG_LEVEL_DEBUG, "%s: In %s('%s')",
 			__module_name, __function_name, jabber_id);
 
@@ -407,7 +510,12 @@ static int connect_jabber(const char *ja
 		IKS_RULE_ID, "auth",
 		IKS_RULE_DONE);
 
-	switch (iks_connect_with(jsess->prs, jsess->acc->server, port, jsess->acc->server, &zbx_iks_transport))
+	if (srv_lookup_jabber(jsess->acc->server, realserver, 256, &realport) != SUCCEED) {
+	    /* no SRV entry use original data */
+	    zbx_strlcpy(realserver, jsess->acc->server, 256);
+	    realport = port;
+	}
+	switch (iks_connect_with(jsess->prs, realserver, realport, jsess->acc->server, &zbx_iks_transport))
 /*	switch (iks_connect_via(jsess->prs, jsess->acc->server, port, jsess->acc->server))*/
 	{
 		case IKS_OK:
