diff -uNr samba-2.2.3a.original/source/include/proto.h samba-2.2.3a/source/include/proto.h
--- samba-2.2.3a.original/source/include/proto.h	Wed Jul 24 10:12:04 2002
+++ samba-2.2.3a/source/include/proto.h	Fri Jul 26 13:08:30 2002
@@ -1216,6 +1216,7 @@
 void client_setfd(int fd);
 char *client_name(void);
 char *client_addr(void);
+struct in_addr *get_interface_ip_to_bind(void); /* samba-2.2.3a-socketbinding.patch */
 char *get_socket_name(int fd);
 char *get_socket_addr(int fd);
 int open_pipe_sock(char *path);
diff -uNr samba-2.2.3a.original/source/lib/util_sock.c samba-2.2.3a/source/lib/util_sock.c
--- samba-2.2.3a.original/source/lib/util_sock.c	Wed Jul 24 10:12:04 2002
+++ samba-2.2.3a/source/lib/util_sock.c	Fri Jul 26 13:13:37 2002
@@ -36,6 +36,9 @@
 
 int smb_read_error = 0;
 
+/* samba-2.2.3a-socketbinding.patch */
+extern struct in_addr loopback_ip;
+
 /****************************************************************************
  Determine if a file descriptor is in fact a socket.
 ****************************************************************************/
@@ -811,25 +814,61 @@
   int connect_loop = 250; /* 250 milliseconds */
   int loops = (timeout) / connect_loop;
 
+  DEBUG(3,("Connecting to %s at port %d\n",inet_ntoa(*addr),port));
+
+  /*-----------------------------*/
   /* create a socket to write to */
+  /*-----------------------------*/
+  DEBUG(5,("Opening socket\n"));
+
   res = socket(PF_INET, type, 0);
   if (res == -1) 
     { DEBUG(0,("socket error\n")); return -1; }
 
   if (type != SOCK_STREAM) return(res);
   
-  memset((char *)&sock_out,'\0',sizeof(sock_out));
-  putip((char *)&sock_out.sin_addr,(char *)addr);
-  
-  sock_out.sin_port = htons( port );
-  sock_out.sin_family = PF_INET;
-
   /* set it non-blocking */
   set_blocking(res,False);
+  
+  /*---------------------------------------------------------------------*/
+  /* samba-2.2.3a-socketbinding.patch                                    */
+  /* ------------------------------------------------------------------- */
+  /* If only binding "INTERFACES", bind the socket to a local interface. */
+  /* In theory, this should be done for all outbound packets. Also, this */
+  /* makes the browse list propagation work great over a VPN.            */
+  /*---------------------------------------------------------------------*/
+  if (lp_bind_interfaces_only())
+    {
+    struct in_addr *ifip;
+    
+    DEBUG(5,("bind_interfaces_only is set, search INTERFACES for IP\n"));
 
-  DEBUG(3,("Connecting to %s at port %d\n",inet_ntoa(*addr),port));
+    ifip = get_interface_ip_to_bind();
+
+    DEBUG(5,("Binding socket to %s\n",inet_ntoa(*ifip)));
+
+    memset((char *)&sock_out,'\0',sizeof(sock_out));
+    sock_out.sin_family = PF_INET;
+    putip((char *)&sock_out.sin_addr,(char *)ifip);
   
+    if (bind(res, (struct sockaddr * ) &sock_out,sizeof(sock_out)) < 0) 
+      { 
+      DEBUG(0,("bind failed on port %d socket_addr=%s (%s)\n",
+               port,inet_ntoa(sock_out.sin_addr),strerror(errno))); 
+      close(res); 
+      return(-1); 
+      }
+    }
+
+  /*-----------------------------------*/
   /* and connect it to the destination */
+  /*-----------------------------------*/
+  memset((char *)&sock_out,'\0',sizeof(sock_out));
+  
+  sock_out.sin_port = htons( port );
+  sock_out.sin_family = PF_INET;
+  putip((char *)&sock_out.sin_addr,(char *)addr);
+
 connect_again:
   ret = connect(res,(struct sockaddr *)&sock_out,sizeof(sock_out));
 
@@ -933,7 +972,47 @@
 	return False;
 }
 
- 
+/* samba-2.2.3a-socketbinding.patch */
+/****************************************************************************
+* Function:    get_interface_ip_to_bind
+*
+* Parameters:  none
+* Returns:     struct in_addr * - IP of Valid Interface for Socket Binding
+*
+* Description: Searches the list of interfaces created from the INTERFACES
+*              config parameter.  Returns the IP address of the first valid
+*              interface found.  Loopback and NULL IP addresses are skipped.
+*              This function is called when the "BIND INTERFACES ONLY"
+*              config option is specified.
+****************************************************************************/
+struct in_addr *get_interface_ip_to_bind()
+  {
+  int             i;
+  struct in_addr *ifip;
+  
+  for (i = 0; i < iface_count(); i++) 
+    {
+    ifip = iface_n_ip(i);
+    
+    if (ifip == NULL) 
+      {
+      DEBUG(10,("interface %d has NULL IP address !\n", i));
+      continue;
+      }
+    
+    if (ip_equal(*ifip,loopback_ip)) 
+      {
+      DEBUG(10,("ignoring loopback interface (%d)\n", i));
+      continue;
+      }
+
+    return(ifip);
+    }
+
+  DEBUG(0,("No valid interfaces specified for INTERFACES.\n"));
+  return(NULL);
+  }
+
 /*******************************************************************
  return the DNS name of the remote end of a socket
  ******************************************************************/
diff -uNr samba-2.2.3a.original/source/nmbd/nmbd_packets.c samba-2.2.3a/source/nmbd/nmbd_packets.c
--- samba-2.2.3a.original/source/nmbd/nmbd_packets.c	Wed Jul 24 10:12:05 2002
+++ samba-2.2.3a/source/nmbd/nmbd_packets.c	Fri Jul 26 13:08:37 2002
@@ -227,6 +227,26 @@
   packet->packet_type = NMB_PACKET;
   packet->locked = False;
   
+  /*----------------------------------------------------------------*/
+  /* samba-2.2.3a-socketbinding.patch                               */
+  /* -------------------------------------------------------------- */
+  /* If only binding "INTERFACES", select the appropriate socket.   */
+  /* In theory, this should be done for all outbound packets. Also, */
+  /* this makes the browse list propagation work great over a VPN.  */
+  /*----------------------------------------------------------------*/
+  if (lp_bind_interfaces_only()) 
+    {
+    struct in_addr *ifip;
+    
+    DEBUG(5,("bind_interfaces_only is set, looking for suitable source IP\n"));
+
+    ifip = get_interface_ip_to_bind();
+      
+    DEBUG(5,("using source IP %s\n",inet_ntoa(*ifip)));
+
+    packet->fd = find_subnet_fd_for_address( *ifip );
+    }
+  
   return packet; /* Caller must free. */
 }
 
@@ -699,29 +719,6 @@
 					  subrec->bcast_ip)) == NULL)
     return NULL;
 
-  if(lp_bind_interfaces_only()) {
-    int i;
-
-    DEBUG(10,("queue_query_name: bind_interfaces_only is set, looking for suitable source IP\n"));
-    for(i = 0; i < iface_count(); i++) {
-      struct in_addr *ifip = iface_n_ip(i);
-
-      if(ifip == NULL) {
-        DEBUG(0,("queue_query_name: interface %d has NULL IP address !\n", i));
-        continue;
-      }
-
-      if (ip_equal(*ifip,loopback_ip)) {
-        DEBUG(5,("queue_query_name: ignoring loopback interface (%d)\n", i));
-        continue;
-      }
-
-      DEBUG(10,("queue_query_name: using source IP %s\n",inet_ntoa(*ifip)));
-      p->fd = find_subnet_fd_for_address( *ifip );
-      break;
-    }
-  }
-
   if(initiate_name_query_packet( p ) == False) {
     p->locked = False;
     free_packet(p);
