diff --git a/doc/man/man8/slapd.8 b/doc/man/man8/slapd.8
index bc6cd546807f277610c57db586123c6e9fed534e..36bd63c5883ae19077e1e9191ef394c63edcf7b8 100644
--- a/doc/man/man8/slapd.8
+++ b/doc/man/man8/slapd.8
@@ -3,7 +3,7 @@
 slapd \- Stand-alone LDAP Daemon
 .SH SYNOPSIS
 .B LIBEXECDIR/slapd [\-d debug\-level]
-.B [\-f slapd\-config\-file] [\-p port\-number]
+.B [\-f slapd\-config\-file] [\-a address] [\-p port\-number]
 .B [\-s syslog\-level] [\-l syslog\-local\-user] [\-i]
 .B 
 .SH DESCRIPTION
@@ -87,10 +87,16 @@ facility.
 Specifies the slapd configuration file. The default is
 .BR ETCDIR/slapd.conf .
 .TP
+.BI \-a " address"
+.B slapd
+will listen on all addresses (INADDR_ANY) unless this option
+is given to override the default.  The address is expected in 
+Internet standard '.' format.
+.TP
 .BI \-p " port\-number"
 .B slapd
 will listen on the default LDAP port (389) unless this option is given
-to override the default.
+to override the default.  A numeric port number is expected.
 .TP
 .B \-i
 This option tells
diff --git a/servers/slapd/daemon.c b/servers/slapd/daemon.c
index 0b0cfe6b4d9bfca0dd9660bcf7c75a1d6a78fe05..b395a72ee2af5c2316546f5ce7bfd418fd3133a4 100644
--- a/servers/slapd/daemon.c
+++ b/servers/slapd/daemon.c
@@ -50,12 +50,12 @@ extern char *slapd_args_file;
 
 void *
 slapd_daemon(
-    void *port
+	void *ptr
 )
 {
+	struct sockaddr_in *addr = ptr;
 	int			i;
 	int			tcps, ns;
-	struct sockaddr_in	addr;
 	fd_set			readfds;
 	fd_set			writefds;
 	FILE			*fp;
@@ -104,11 +104,7 @@ slapd_daemon(
 		    "unknown", 0 );
 	}
 
-	(void) memset( (void *) &addr, '\0', sizeof(addr) );
-	addr.sin_family = AF_INET;
-	addr.sin_addr.s_addr = INADDR_ANY;
-	addr.sin_port = htons( (int)port );
-	if ( bind( tcps, (struct sockaddr *) &addr, sizeof(addr) ) == -1 ) {
+	if ( bind( tcps, (struct sockaddr *) addr, sizeof(*addr) ) == -1 ) {
 		Debug( LDAP_DEBUG_ANY, "bind() failed errno %d (%s)\n",
 		    errno, errno > -1 && errno < sys_nerr ? sys_errlist[errno] :
 		    "unknown", 0 );
diff --git a/servers/slapd/main.c b/servers/slapd/main.c
index 10e14d7fb500c2c19e9e9acd3c2e8445673113a1..f7b446939072e727445bbd64dc8de1ab8cce477b 100644
--- a/servers/slapd/main.c
+++ b/servers/slapd/main.c
@@ -62,7 +62,7 @@ main( int argc, char **argv )
 	int		i;
 	int		inetd = 0;
 	int		rc = 0;
-	int		port;
+	struct sockaddr_in	bind_addr;
 	int		udp;
 #ifdef LOG_LOCAL4
     int     syslogUser = DEFAULT_SYSLOG_USER;
@@ -72,16 +72,27 @@ main( int argc, char **argv )
 	int         serverMode = SLAP_SERVER_MODE;
 
 	configfile = SLAPD_DEFAULT_CONFIGFILE;
-	port = LDAP_PORT;
+
+	(void) memset( (void*) &bind_addr, '\0', sizeof(bind_addr));
+	bind_addr.sin_family = AF_INET;
+	bind_addr.sin_addr.s_addr = htonl(INADDR_ANY);
+	bind_addr.sin_port = htons(LDAP_PORT);
+
 	g_argc = argc;
 	g_argv = argv;
 
 #ifdef SLAPD_BDB2
-	while ( (i = getopt( argc, argv, "d:f:ip:s:ut" )) != EOF ) {
+	while ( (i = getopt( argc, argv, "d:f:ia:p:s:ut" )) != EOF ) {
 #else
-	while ( (i = getopt( argc, argv, "d:f:ip:s:u" )) != EOF ) {
+	while ( (i = getopt( argc, argv, "d:f:ia:p:s:u" )) != EOF ) {
 #endif
 		switch ( i ) {
+		case 'a':	/* bind address */
+			if(!inet_aton(optarg, &bind_addr.sin_addr)) {
+				fprintf(stderr, "invalid address (%s) for -a option", optarg);
+			}
+            break;
+
 #ifdef LDAP_DEBUG
 		case 'd':	/* turn on debugging */
 			if ( optarg[0] == '?' ) {
@@ -132,21 +143,24 @@ main( int argc, char **argv )
 			inetd = 1;
 			break;
 
-		case 'p':	/* port on which to listen */
-			port = atoi( optarg );
-			break;
+		case 'p': {	/* port on which to listen */
+				int port = atoi( optarg );
+				if(! port ) {
+					fprintf(stderr, "-p %s must be numeric\n", optarg);
+				} else {
+					bind_addr.sin_port = htons(port);
+				}
+			} break;
 
 		case 's':	/* set syslog level */
 			ldap_syslog = atoi( optarg );
 			break;
 
 #ifdef LOG_LOCAL4
-
 		case 'l':	/* set syslog local user */
 			syslogUser = cnvt_str2int( optarg, syslog_types,
                                            DEFAULT_SYSLOG_USER );
 			break;
-
 #endif
 
 		case 'u':	/* do udp */
@@ -221,7 +235,7 @@ main( int argc, char **argv )
 		time( &starttime );
 
 		status = ldap_pvt_thread_create( &listener_tid, 0,
-						 slapd_daemon, (void *) port );
+						 slapd_daemon, &bind_addr );
 		if ( status != 0 )
 		{
 			Debug( LDAP_DEBUG_ANY,
diff --git a/tests/scripts/defines.sh b/tests/scripts/defines.sh
index d9005382a02a0c6bf018e76b1a3f4e1205f25465..8d84c1f72611038b140a31105b604c6b30ce2eb4 100755
--- a/tests/scripts/defines.sh
+++ b/tests/scripts/defines.sh
@@ -35,6 +35,7 @@ LDAPADD=../clients/tools/ldapadd
 LDAPMODRDN=../clients/tools/ldapmodrdn
 SLAPDTESTER=$PROGDIR/slapd-tester
 LVL=5
+ADDR=127.0.0.1
 PORT=9009
 SLAVEPORT=9010
 DBDIR=./test-db
diff --git a/tests/scripts/test001-ldif2ldbm b/tests/scripts/test001-ldif2ldbm
index 6ab1a5c52b7034a8c5be920560baa1caa772d995..547aa830d392174e38ce82153bdf600234d63100 100755
--- a/tests/scripts/test001-ldif2ldbm
+++ b/tests/scripts/test001-ldif2ldbm
@@ -28,7 +28,7 @@ if [ $RC != 0 ]; then
 fi
 
 echo "Starting slapd on TCP/IP port $PORT..."
-$SLAPD -f $CONF -p $PORT -d $LVL $TIMING > $MASTERLOG 2>&1 &
+$SLAPD -f $CONF -p $PORT -a $ADDR -d $LVL $TIMING > $MASTERLOG 2>&1 &
 PID=$!
 
 echo "Using ldapsearch to retrieve all the entries..."
diff --git a/tests/scripts/test001-slapadd b/tests/scripts/test001-slapadd
index 6ab1a5c52b7034a8c5be920560baa1caa772d995..547aa830d392174e38ce82153bdf600234d63100 100755
--- a/tests/scripts/test001-slapadd
+++ b/tests/scripts/test001-slapadd
@@ -28,7 +28,7 @@ if [ $RC != 0 ]; then
 fi
 
 echo "Starting slapd on TCP/IP port $PORT..."
-$SLAPD -f $CONF -p $PORT -d $LVL $TIMING > $MASTERLOG 2>&1 &
+$SLAPD -f $CONF -p $PORT -a $ADDR -d $LVL $TIMING > $MASTERLOG 2>&1 &
 PID=$!
 
 echo "Using ldapsearch to retrieve all the entries..."