All I want to do is change the default interface!!!

David Wuertele dave-gnus at bfnet.com
Tue Nov 18 01:17:13 GMT 2003


Here's my situation:  "MYHOST" is a box on two networks.  I'm trying
to write a program that will print out a list of all the workgroups
and servers he can see.  The problem is that there are two disjoint,
completely independent "WG1" workgroups.  WG1 hosts on subnet0 can't
browse WG1 hosts on subnet1, and they're not supposed to.  Only MYHOST
can see both.

   subnet0: 192.168.0.0/24
   ----+------+--------+--
       |      |        |
   WG1 //ZERO |        |
              |        |
          WG2 //ONE    |
                       |eth0
                    MYHOST
                       |eth1
                       |
   WG1 //TWO           |
       |               |
       |  WG3 //THREE  |
       |      |        |
   ----+------+--------+--
   subnet1: 192.168.1.0/24

The problem is when I try to use libsmbclient's "smbc_opendir(url);"
API, I can't explicitly direct it to use eth0 or eth1.  It tries both,
and if it finds a browse list on subnet0, it doesn't look for a browse
list on subnet1.  I know it can see subnet1, because it finds //THREE,
which is in a workgroup of its own.  But since smbc_opendir() always
tries eth0 first, it somehow gets stuck on the browse list returned by
subnet0's WG1 LMB, which it gets from ZERO.

I've tried many different ways to convince smbc_opendir() to look only
on subnet1:

A.  realoading smb.conf:  I do something like this:

      for (interface=0, interface<=1; interface++) {
        gencache_shutdown();
        system ("/bin/rm -f /var/lock/samba/gencache.tdb");
        gencache_init();
        unlink (TMPCONF_FILENAME);
        tmpconf = fopen (TMPCONF_FILENAME, "w");
        fprintf (tmpconf, "interfaces = eth%d\n", interface);
        fclose (tmpconf);
        lp_load (TMPCONF_FILENAME, True, False, False);
        load_interfaces();
        smbc_init(auth_fn, 0);
        setup_logging("read-all-browse-lists", False);
        dh = smbc_opendir(url);
        while (dirptr = smbc_readdir( dh )) {
          char newurl[MAX_BUFF_SIZE];
          if (debug > 2) fprintf (stderr, "adding server %s\n", dirptr->name);
          printf ("found %s\n", dirptr->name);
        }
        smbc_closedir(dh);
      }

    But this only finds ZERO, ONE, and THREE.  It does not find TWO.

B.  calling lp_do_parameter() directly:

      for (interface=0, interface<=1; interface++) {
        snprintf (ifname, "eth%d", interface);
        interface_name = str_list_make (ifname, 0);
        lp_do_parameter (GLOBAL_SECTION_SNUM, "interfaces", ifname);
        load_interfaces();
        smbc_init(auth_fn, 0);
        setup_logging("read-all-browse-lists", False);
        dh = smbc_opendir(url);
        while (dirptr = smbc_readdir( dh )) {
          char newurl[MAX_BUFF_SIZE];
          if (debug > 2) fprintf (stderr, "adding server %s\n", dirptr->name);
          printf ("found %s\n", dirptr->name);
        }
        smbc_closedir(dh);
      }

    But this only finds ZERO, ONE, and THREE.  It does not find TWO.

C.   using a more qualified URL as per the "SMB Filesharing URL Scheme":

      for (interface=0, interface<=1; interface++) {
        snprintf (url, MAX_BUFF_SIZE, "smb://%s/?BROADCAST=%s", glp->name, broadcast_addr[interface]);
        dh = smbc_opendir(url);
        while (dirptr = smbc_readdir( dh )) {
          char newurl[MAX_BUFF_SIZE];
          if (debug > 2) fprintf (stderr, "adding server %s\n", dirptr->name);
          printf ("found %s\n", dirptr->name);
        }
        smbc_closedir(dh);
      }

    But this doesn't find anything.


Can anyone suggest how I can force smbc_opendir() to use a specific
interface?

Thanks,
Dave




More information about the samba-technical mailing list