diff -uNr zabbix-1.8.4/create/schema/ibm_db2.sql zabbix-1.8.4.p/create/schema/ibm_db2.sql
--- zabbix-1.8.4/create/schema/ibm_db2.sql	2011-01-04 16:58:34.000000000 +0300
+++ zabbix-1.8.4.p/create/schema/ibm_db2.sql	2011-02-17 16:55:26.117387002 +0300
@@ -1063,6 +1064,7 @@
 	autoreg_hostid		bigint		DEFAULT '0'	NOT NULL,
 	proxy_hostid		bigint		DEFAULT '0'	NOT NULL,
 	host		varchar(64)		DEFAULT ''	NOT NULL,
+	ip              varchar(39)             DEFAULT '127.0.0.1'     NOT NULL,
 	PRIMARY KEY (autoreg_hostid)
 );
 CREATE UNIQUE INDEX autoreg_host_1 on autoreg_host (proxy_hostid,host);
@@ -1070,6 +1072,7 @@
 	id		bigint			NOT NULL	GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1),
 	clock		integer		DEFAULT '0'	NOT NULL,
 	host		varchar(64)		DEFAULT ''	NOT NULL,
+	ip              varchar(39)             DEFAULT '127.0.0.1'     NOT NULL,
 	PRIMARY KEY (id)
 );
 CREATE INDEX proxy_autoreg_host_1 on proxy_autoreg_host (clock);
diff -uNr zabbix-1.8.4/create/schema/mysql.sql zabbix-1.8.4.p/create/schema/mysql.sql
--- zabbix-1.8.4/create/schema/mysql.sql	2011-01-04 16:58:34.000000000 +0300
+++ zabbix-1.8.4.p/create/schema/mysql.sql	2011-02-17 16:56:18.747387002 +0300
@@ -1063,6 +1064,7 @@
 	autoreg_hostid		bigint unsigned		DEFAULT '0'	NOT NULL,
 	proxy_hostid		bigint unsigned		DEFAULT '0'	NOT NULL,
 	host		varchar(64)		DEFAULT ''	NOT NULL,
+	ip              varchar(39)             DEFAULT '127.0.0.1'     NOT NULL,
 	PRIMARY KEY (autoreg_hostid)
 ) ENGINE=InnoDB;
 CREATE UNIQUE INDEX autoreg_host_1 on autoreg_host (proxy_hostid,host);
@@ -1070,6 +1072,7 @@
 	id		bigint unsigned			NOT NULL	auto_increment unique,
 	clock		integer		DEFAULT '0'	NOT NULL,
 	host		varchar(64)		DEFAULT ''	NOT NULL,
+	ip              varchar(39)             DEFAULT '127.0.0.1'     NOT NULL,
 	PRIMARY KEY (id)
 ) ENGINE=InnoDB;
 CREATE INDEX proxy_autoreg_host_1 on proxy_autoreg_host (clock);
diff -uNr zabbix-1.8.4/create/schema/oracle.sql zabbix-1.8.4.p/create/schema/oracle.sql
--- zabbix-1.8.4/create/schema/oracle.sql	2011-01-04 16:58:35.000000000 +0300
+++ zabbix-1.8.4.p/create/schema/oracle.sql	2011-02-17 16:57:39.247387000 +0300
@@ -1505,6 +1506,7 @@
 	autoreg_hostid		number(20)		DEFAULT '0'	NOT NULL,
 	proxy_hostid		number(20)		DEFAULT '0'	NOT NULL,
 	host		nvarchar2(64)		DEFAULT '',
+	ip              nvarchar2(39)           DEFAULT '127.0.0.1',
 	PRIMARY KEY (autoreg_hostid)
 )
 /
@@ -1516,6 +1518,7 @@
 	id		number(20)			NOT NULL,
 	clock		number(10)		DEFAULT '0'	NOT NULL,
 	host		nvarchar2(64)		DEFAULT '',
+	ip              nvarchar2(39)           DEFAULT '127.0.0.1',
 	PRIMARY KEY (id)
 )
 /
diff -uNr zabbix-1.8.4/create/schema/postgresql.sql zabbix-1.8.4.p/create/schema/postgresql.sql
--- zabbix-1.8.4/create/schema/postgresql.sql	2011-01-04 16:58:35.000000000 +0300
+++ zabbix-1.8.4.p/create/schema/postgresql.sql	2011-02-17 16:58:26.917387002 +0300
@@ -1063,6 +1064,7 @@
 	autoreg_hostid		bigint		DEFAULT '0'	NOT NULL,
 	proxy_hostid		bigint		DEFAULT '0'	NOT NULL,
 	host		varchar(64)		DEFAULT ''	NOT NULL,
+	ip              varchar(39)             DEFAULT '127.0.0.1'     NOT NULL,
 	PRIMARY KEY (autoreg_hostid)
 ) with OIDS;
 CREATE UNIQUE INDEX autoreg_host_1 on autoreg_host (proxy_hostid,host);
@@ -1070,6 +1072,7 @@
 	id		serial			NOT NULL,
 	clock		integer		DEFAULT '0'	NOT NULL,
 	host		varchar(64)		DEFAULT ''	NOT NULL,
+	ip              varchar(39)             DEFAULT '127.0.0.1'     NOT NULL,
 	PRIMARY KEY (id)
 ) with OIDS;
 CREATE INDEX proxy_autoreg_host_1 on proxy_autoreg_host (clock);
diff -uNr zabbix-1.8.4/create/schema/sqlite.sql zabbix-1.8.4.p/create/schema/sqlite.sql
--- zabbix-1.8.4/create/schema/sqlite.sql	2011-01-04 16:58:35.000000000 +0300
+++ zabbix-1.8.4.p/create/schema/sqlite.sql	2011-02-17 16:59:36.807387000 +0300
@@ -1059,13 +1060,15 @@
 	autoreg_hostid		bigint		DEFAULT '0'	NOT NULL,
 	proxy_hostid		bigint		DEFAULT '0'	NOT NULL,
 	host		varchar(64)		DEFAULT ''	NOT NULL,
+	ip              varchar(39)             DEFAULT '127.0.0.1'     NOT NULL,
 	PRIMARY KEY (autoreg_hostid)
 );
 CREATE UNIQUE INDEX autoreg_host_1 on autoreg_host (proxy_hostid,host);
 CREATE TABLE proxy_autoreg_host (
 	id		integer			NOT NULL	PRIMARY KEY AUTOINCREMENT,
 	clock		integer		DEFAULT '0'	NOT NULL,
-	host		varchar(64)		DEFAULT ''	NOT NULL
+	host		varchar(64)		DEFAULT ''	NOT NULL,
+	ip              varchar(39)             DEFAULT '127.0.0.1'     NOT NULL
 );
 CREATE INDEX proxy_autoreg_host_1 on proxy_autoreg_host (clock);
 COMMIT;
diff -uNr zabbix-1.8.4/frontends/php/include/schema.inc.php zabbix-1.8.4.p/frontends/php/include/schema.inc.php
--- zabbix-1.8.4/frontends/php/include/schema.inc.php	2011-01-04 16:57:51.000000000 +0300
+++ zabbix-1.8.4.p/frontends/php/include/schema.inc.php	2011-02-17 17:00:42.967387002 +0300
@@ -4678,6 +4678,14 @@
 				'length' => 64,
 				'default' => '',
 			),
+			'ip' => array(
+                                'null' => false,
+                                'type' => DB::FIELD_TYPE_CHAR,
+                                'length' => 39,
+                                'default' => '127.0.0.1',
+                        ),
+
+
 		),
 	),
 	'proxy_autoreg_host' => array(
@@ -4700,7 +4708,14 @@
 				'length' => 64,
 				'default' => '',
 			),
+                       'ip' => array(
+                                'null' => false,
+                                'type' => DB::FIELD_TYPE_CHAR,
+                                'length' => 39,
+                                'default' => '127.0.0.1',
+                        ),
+
 		),
 	),
 );
-?>
\ В конце файла нет новой строки
+?>
diff -uNr zabbix-1.8.4/include/db.h zabbix-1.8.4.p/include/db.h
--- zabbix-1.8.4/include/db.h	2011-01-04 16:57:50.000000000 +0300
+++ zabbix-1.8.4.p/include/db.h	2011-02-17 17:01:55.147387002 +0300
@@ -619,8 +619,8 @@
 double	DBmultiply_value_float(DB_ITEM *item, double value);
 zbx_uint64_t	DBmultiply_value_uint64(DB_ITEM *item, zbx_uint64_t value);
 
-void	DBregister_host(zbx_uint64_t proxy_hostid, const char *host, int now);
-void	DBproxy_register_host(const char *host);
+void   DBregister_host(zbx_uint64_t proxy_hostid, const char *host, int now, const char *ip);
+void   DBproxy_register_host(const char *host, const char *ip);
 void	DBexecute_overflowed_sql(char **sql, int *sql_allocated, int *sql_offset);
 char	*DBget_unique_hostname_by_sample(char *host_name_sample);
 #endif
diff -uNr zabbix-1.8.4/src/libs/zbxdbhigh/db.c zabbix-1.8.4.p/src/libs/zbxdbhigh/db.c
--- zabbix-1.8.4/src/libs/zbxdbhigh/db.c	2011-01-04 16:57:50.000000000 +0300
+++ zabbix-1.8.4.p/src/libs/zbxdbhigh/db.c	2011-02-18 11:37:45.538519000 +0300
@@ -1942,9 +1942,9 @@
  * Comments:                                                                  *
  *                                                                            *
  ******************************************************************************/
-void	DBregister_host(zbx_uint64_t proxy_hostid, const char *host, int now)
+void   DBregister_host(zbx_uint64_t proxy_hostid, const char *host, int now, const char *ip)
 {
-	char		*host_esc;
+	char		*host_esc, *ip_esc;
 	DB_RESULT	result;
 	DB_ROW		row;
 	DB_EVENT	event;
@@ -1952,6 +1952,7 @@
 	int		res = SUCCEED;
 
 	host_esc = DBdyn_escape_string_len(host, HOST_HOST_LEN);
+	ip_esc = DBdyn_escape_string_len(ip, HOST_IP_LEN);
 
 	if (0 != proxy_hostid)
 	{
@@ -1986,10 +1987,10 @@
 		{
 			autoreg_hostid = DBget_maxid("autoreg_host");
 			DBexecute("insert into autoreg_host"
-					" (autoreg_hostid,proxy_hostid,host)"
+					" (autoreg_hostid,proxy_hostid,host,ip)"
 					" values"
-					" (" ZBX_FS_UI64 "," ZBX_FS_UI64 ",'%s')",
-					autoreg_hostid, proxy_hostid, host_esc);
+					" (" ZBX_FS_UI64 "," ZBX_FS_UI64 ",'%s', '%s')",
+					autoreg_hostid, proxy_hostid, host_esc, ip_esc);
 		}
 		DBfree_result(result);
 
@@ -2023,15 +2024,16 @@
  * Comments:                                                                  *
  *                                                                            *
  ******************************************************************************/
-void	DBproxy_register_host(const char *host)
+void	DBproxy_register_host(const char *host, const char *ip)
 {
-	char	*host_esc;
+	char	*host_esc, *ip_esc;
 
 	host_esc = DBdyn_escape_string_len(host, HOST_HOST_LEN);
+	ip_esc =DBdyn_escape_string_len(ip, HOST_IP_LEN);
 
-	DBexecute("insert into proxy_autoreg_host (clock,host) values (%d,'%s')",
+	DBexecute("insert into proxy_autoreg_host (clock,host,ip) values (%d,'%s','%s')",
 			(int)time(NULL),
-			host_esc);
+			host_esc,ip_esc);
 
 	zbx_free(host_esc);
 }
diff -uNr zabbix-1.8.4/src/libs/zbxdbhigh/dbschema.c zabbix-1.8.4.p/src/libs/zbxdbhigh/dbschema.c
--- zabbix-1.8.4/src/libs/zbxdbhigh/dbschema.c	2011-01-04 16:58:35.000000000 +0300
+++ zabbix-1.8.4.p/src/libs/zbxdbhigh/dbschema.c	2011-02-18 11:15:41.118519000 +0300
@@ -1163,6 +1164,7 @@
 		{"autoreg_hostid",	ZBX_TYPE_ID,	ZBX_NOTNULL,	NULL},
 		{"proxy_hostid",	ZBX_TYPE_ID,	ZBX_NOTNULL | ZBX_SYNC,	"hosts"},
 		{"host",	ZBX_TYPE_CHAR,	ZBX_NOTNULL | ZBX_SYNC,	NULL},
+		{"ip",  ZBX_TYPE_CHAR,  ZBX_NOTNULL | ZBX_SYNC | ZBX_PROXY,     NULL},
 		{0}
 		}
 	},
@@ -1171,6 +1173,7 @@
 		{"id",	ZBX_TYPE_UINT,	ZBX_NOTNULL,	NULL},
 		{"clock",	ZBX_TYPE_INT,	ZBX_NOTNULL,	NULL},
 		{"host",	ZBX_TYPE_CHAR,	ZBX_NOTNULL,	NULL},
+		{"ip",  ZBX_TYPE_CHAR,  ZBX_NOTNULL | ZBX_SYNC | ZBX_PROXY,     NULL},
 		{0}
 		}
 	},
@@ -2240,13 +2244,15 @@
  autoreg_hostid bigint DEFAULT '0' NOT NULL,\
  proxy_hostid bigint DEFAULT '0' NOT NULL,\
  host varchar(64) DEFAULT '' NOT NULL,\
+ ip varchar(39) DEFAULT '127.0.0.1' NOT NULL,\
  PRIMARY KEY (autoreg_hostid)\
 );\
 CREATE UNIQUE INDEX autoreg_host_1 on autoreg_host (proxy_hostid,host);\
 CREATE TABLE proxy_autoreg_host (\
  id integer NOT NULL PRIMARY KEY AUTOINCREMENT,\
  clock integer DEFAULT '0' NOT NULL,\
- host varchar(64) DEFAULT '' NOT NULL\
+ host varchar(64) DEFAULT '' NOT NULL,\
+ ip varchar(39) DEFAULT '127.0.0.1' NOT NULL\
 );\
 CREATE INDEX proxy_autoreg_host_1 on proxy_autoreg_host (clock);\
 COMMIT;\
diff -uNr zabbix-1.8.4/src/libs/zbxdbhigh/proxy.c zabbix-1.8.4.p/src/libs/zbxdbhigh/proxy.c
--- zabbix-1.8.4/src/libs/zbxdbhigh/proxy.c	2011-01-04 16:57:50.000000000 +0300
+++ zabbix-1.8.4.p/src/libs/zbxdbhigh/proxy.c	2011-02-18 11:17:21.638519001 +0300
@@ -82,6 +82,7 @@
 		{
 		{"p.clock",	ZBX_PROTO_TAG_CLOCK,		ZBX_JSON_TYPE_INT,	NULL},
 		{"p.host",	ZBX_PROTO_TAG_HOST,		ZBX_JSON_TYPE_STRING,	NULL},
+		{"p.ip",        ZBX_PROTO_TAG_IP,               ZBX_JSON_TYPE_STRING,   NULL},
 		{NULL}
 		}
 };
@@ -1648,6 +1649,7 @@
 	const char		*p = NULL;
 	time_t			now, hosttime, itemtime;
 	char			host[HOST_HOST_LEN_MAX];
+	char                    ip[HOST_IP_LEN_MAX];
 
 	zabbix_log(LOG_LEVEL_DEBUG, "In %s()", __function_name);
 
@@ -1673,8 +1675,11 @@
 		if (FAIL == zbx_json_value_by_name(&jp_row, ZBX_PROTO_TAG_HOST, host, sizeof(host)))
 			goto json_parse_error;
 
+		if (FAIL == zbx_json_value_by_name(&jp_row, ZBX_PROTO_TAG_IP, ip, sizeof(ip)))
+                       zbx_strlcpy(ip, "127.0.0.1", 10); // leave compatibility with previous versions of proxy
+
 		DBbegin();
-		DBregister_host(proxy_hostid, host, itemtime);
+		DBregister_host(proxy_hostid, host, itemtime, ip);
 		DBcommit();
 
 		continue;
diff -uNr zabbix-1.8.4/src/zabbix_server/operations.c zabbix-1.8.4.p/src/zabbix_server/operations.c
--- zabbix-1.8.4/src/zabbix_server/operations.c	2011-01-04 16:57:50.000000000 +0300
+++ zabbix-1.8.4.p/src/zabbix_server/operations.c	2011-02-18 11:42:02.938519001 +0300
@@ -484,6 +485,7 @@
 	zbx_uint64_t	hostid = 0, proxy_hostid, host_proxy_hostid;
 	char		host[MAX_STRING_LEN], *host_esc, *ip_esc, *host_unique, *host_unique_esc;
 	int		port;
+	int		useip=1; // by default use IP agent
 	zbx_uint64_t	groupid;
 
 	zabbix_log(LOG_LEVEL_DEBUG, "In %s(eventid:" ZBX_FS_UI64 ")",
@@ -531,7 +533,7 @@
 				event->objectid);
 		break;
 	case EVENT_OBJECT_ZABBIX_ACTIVE:
-		result = DBselect("select proxy_hostid,host from autoreg_host"
+		result = DBselect("select proxy_hostid,host,ip from autoreg_host"
 				" where autoreg_hostid=" ZBX_FS_UI64,
 				event->objectid);
 		break;
@@ -546,6 +548,10 @@
 		if (EVENT_OBJECT_ZABBIX_ACTIVE == event->object)
 		{
 			host_esc = DBdyn_escape_string_len(row[1], HOST_HOST_LEN);
+			ip_esc = DBdyn_escape_string_len(row[2], HOST_IP_LEN);
+
+			if (0 == strncmp(row[2],"127.0.0.1", 9))
+				useip=0;
 
 			result2 = DBselect(
 					"select hostid,proxy_hostid"
@@ -559,12 +565,14 @@
 			{
 				hostid = DBget_maxid("hosts");
 
-				DBexecute("insert into hosts (hostid,proxy_hostid,host,useip,dns)"
-						" values (" ZBX_FS_UI64 "," ZBX_FS_UI64 ",'%s',0,'%s')",
+				DBexecute("insert into hosts (hostid,proxy_hostid,host,useip,dns,ip)"
+						" values (" ZBX_FS_UI64 "," ZBX_FS_UI64 ",'%s',%d,'%s','%s')",
 						hostid,
 						proxy_hostid,
 						host_esc,
-						host_esc);
+						useip,
+						host_esc,
+						ip_esc);
 			}
 			else
 			{
diff -uNr zabbix-1.8.4/src/zabbix_server/trapper/active.c zabbix-1.8.4.p/src/zabbix_server/trapper/active.c
--- zabbix-1.8.4/src/zabbix_server/trapper/active.c	2011-01-04 16:57:50.000000000 +0300
+++ zabbix-1.8.4.p/src/zabbix_server/trapper/active.c	2011-02-18 11:34:41.988519001 +0300
@@ -40,7 +40,7 @@
  * Comments:                                                                  *
  *                                                                            *
  ******************************************************************************/
-static int	get_hostid_by_host(const char *host, zbx_uint64_t *hostid, char *error, unsigned char zbx_process)
+static int	get_hostid_by_host(const char *host, zbx_uint64_t *hostid, char *error, unsigned char zbx_process, const char *ip)
 {
 	char		*host_esc;
 	DB_RESULT	result;
@@ -81,11 +81,11 @@
 
 		if (0 != (zbx_process & ZBX_PROCESS_SERVER))
 		{
-			DBregister_host(0, host, (int)time(NULL));
+			DBregister_host(0, host, (int)time(NULL), ip);
 		}
 		else if (0 != (zbx_process & ZBX_PROCESS_PROXY))
 		{
-			DBproxy_register_host(host);
+			DBproxy_register_host(host, ip);
 		}
 
 		DBcommit();
@@ -144,7 +144,7 @@
 		goto out;
 	}
 
-	if (FAIL == get_hostid_by_host(host, &hostid, error, zbx_process))
+	if (FAIL == get_hostid_by_host(host, &hostid, error, zbx_process, get_ip_by_socket(sock)))
 		goto out;
 
 	buffer = zbx_malloc(buffer, buffer_alloc);
@@ -275,7 +275,7 @@
 		goto error;
 	}
 
-	if (FAIL == get_hostid_by_host(host, &hostid, error, zbx_process))
+	if (FAIL == get_hostid_by_host(host, &hostid, error, zbx_process, get_ip_by_socket(sock)))
 		goto error;
 
 	sql = zbx_malloc(sql, sql_alloc);
