diff -r 3b1e7941542f src/director/director-request.c
--- a/src/director/director-request.c	Tue Oct 13 21:57:29 2015 +0300
+++ b/src/director/director-request.c	Tue Oct 13 22:36:21 2015 +0300
@@ -111,7 +111,7 @@
 
 		array_delete(&dir->pending_requests, 0, 1);
 		T_BEGIN {
-			request->callback(NULL, errormsg, request->context);
+			request->callback(NULL, NULL, errormsg, request->context);
 		} T_END;
 		director_request_free(request);
 	}
@@ -316,7 +316,8 @@
 	i_assert(!user->weak);
 	director_update_user(dir, dir->self_host, user);
 	T_BEGIN {
-		request->callback(&user->host->ip, NULL, request->context);
+		request->callback(&user->host->ip, user->host->hostname,
+				  NULL, request->context);
 	} T_END;
 	director_request_free(request);
 	return TRUE;
diff -r 3b1e7941542f src/director/director-request.h
--- a/src/director/director-request.h	Tue Oct 13 21:57:29 2015 +0300
+++ b/src/director/director-request.h	Tue Oct 13 22:36:21 2015 +0300
@@ -5,8 +5,8 @@
 struct director_request;
 
 typedef void
-director_request_callback(const struct ip_addr *ip, const char *errormsg,
-			  void *context);
+director_request_callback(const struct ip_addr *ip, const char *hostname,
+			  const char *errormsg, void *context);
 
 void director_request(struct director *dir, const char *username,
 		      const char *tag,
diff -r 3b1e7941542f src/director/login-connection.c
--- a/src/director/login-connection.c	Tue Oct 13 21:57:29 2015 +0300
+++ b/src/director/login-connection.c	Tue Oct 13 22:36:21 2015 +0300
@@ -3,6 +3,7 @@
 #include "lib.h"
 #include "ioloop.h"
 #include "net.h"
+#include "str.h"
 #include "istream.h"
 #include "ostream.h"
 #include "llist.h"
@@ -124,8 +125,8 @@
 }
 
 static void
-login_host_callback(const struct ip_addr *ip, const char *errormsg,
-		    void *context)
+login_host_callback(const struct ip_addr *ip, const char *hostname,
+		    const char *errormsg, void *context)
 {
 	struct login_host_request *request = context;
 	struct director *dir = request->conn->dir;
@@ -148,9 +149,17 @@
 		   login_host_request_is_self(request, ip)) {
 		line = request->line;
 	} else {
+		string_t *str = t_str_new(64);
+
 		secs = dir->set->director_user_expire / 2;
-		line = t_strdup_printf("%s\thost=%s\tproxy_refresh=%u",
-				       request->line, net_ip2addr(ip), secs);
+		str_printfa(str, "%s\tproxy_refresh=%u\t", request->line, secs);
+		if (hostname == NULL)
+			str_printfa(str, "host=%s", net_ip2addr(ip));
+		else {
+			str_printfa(str, "host=%s\thostip=%s",
+				    hostname, net_ip2addr(ip));
+		}
+		line = str_c(str);
 	}
 	login_connection_send_line(request->conn, line);
 
diff -r 3b1e7941542f src/director/mail-host.c
--- a/src/director/mail-host.c	Tue Oct 13 21:57:29 2015 +0300
+++ b/src/director/mail-host.c	Tue Oct 13 22:36:21 2015 +0300
@@ -154,18 +154,26 @@
 }
 
 static int
-mail_host_add(struct mail_host_list *list, const char *host, const char *tag)
+mail_host_add(struct mail_host_list *list, const char *hostname, const char *tag)
 {
-	struct ip_addr *ips;
+	struct mail_host *host;
+	struct ip_addr *ips, ip;
 	unsigned int i, ips_count;
 
-	if (net_gethostbyname(host, &ips, &ips_count) < 0) {
-		i_error("Unknown mail host: %s", host);
+	if (net_addr2ip(hostname, &ip) == 0) {
+		(void)mail_host_add_ip(list, &ip, tag);
+		return 0;
+	}
+
+	if (net_gethostbyname(hostname, &ips, &ips_count) < 0) {
+		i_error("Unknown mail host: %s", hostname);
 		return -1;
 	}
 
-	for (i = 0; i < ips_count; i++)
-		(void)mail_host_add_ip(list, &ips[i], tag);
+	for (i = 0; i < ips_count; i++) {
+		host = mail_host_add_ip(list, &ips[i], tag);
+		host->hostname = i_strdup(hostname);
+	}
 	return 0;
 }
 
@@ -309,6 +317,7 @@
 static void mail_host_free(struct mail_host *host)
 {
 	i_free(host->tag);
+	i_free(host->hostname);
 	i_free(host);
 }
 
diff -r 3b1e7941542f src/director/mail-host.h
--- a/src/director/mail-host.h	Tue Oct 13 21:57:29 2015 +0300
+++ b/src/director/mail-host.h	Tue Oct 13 22:36:21 2015 +0300
@@ -14,6 +14,7 @@
 	time_t last_updown_change;
 
 	struct ip_addr ip;
+	char *hostname;
 	char *tag;
 
 	/* host was recently changed and ring hasn't synced yet since */
