Changeset fd7a59b for fedkit


Ignore:
Timestamp:
Oct 16, 2007 6:47:07 PM (17 years ago)
Author:
Kevin Lahey <lahey@…>
Branches:
axis_example, compt_changes, info-ops, master, version-1.30, version-2.00, version-3.01, version-3.02
Children:
e5fee75
Parents:
e863014
Message:

Support for tunneling between multiple interfaces -- it looks like the
script actually got shorter in the course of adding functionality!
Note that this change contains a BSD-specific call to 'route get'; if we
eventually start using Linux as a tunnel node type, we'll need to tweak
this.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fedkit/fed-tun.pl

    re863014 rfd7a59b  
    1414#
    1515# * Create a layer 2 ssh tunnel, set up bridging, and hang loose.
     16#
    1617
    1718use strict;
     
    2627my $NC = "/usr/bin/nc";
    2728my $SSH_PORT = 22;
     29my $ROUTE_GET = "/sbin/route get";  # XXX:  works on FreeBSD, but should
     30                                    #       should be 'ip route get' for Linux
    2831
    2932sub setup_bridging;
     
    4043my $usage = "Usage: fed-tun.pl [-r] [-d] [-f config-filename] [count addr]\n";
    4144
    42 my %opts;
     45my %opts;       # Note that this is used for both getops and the options file
    4346my @expected_opts = qw(active tunnelcfg bossname fsname type
    4447                       peer pubkeys privkeys);
     
    176179    close(IFFILE);
    177180} elsif ($remote) {
    178     # We're on the remote system;  for now, we just grab and use
    179     # the one experimental interface.  Later, we'll actually look
    180     # at the address passed to match up the appropriate interfaces.
     181    # We're on the remote system;  figure out which interface to
     182    # tweak, based on the IP address passed in.
    181183
    182184    my $iter = 0;
    183 
    184     open(IFFILE, "/var/emulab/boot/ifmap") || die "couldn't open ifmap\n";
    185     while (<IFFILE>) {
    186         die "Argh, too many experimental interfaces!" if ($iter > 0);
    187         my @a = split(' ');
    188         my $iface = $a[0];
    189         my $addr = $a[1];
    190         my $bridge = "bridge" . $count;
    191         my $tun = "tap" . $count;
    192 
    193         &setup_bridging($tun, $bridge, $iface, $addr);
    194         $iter++;
    195     }
    196     close(IFFILE);
    197 
     185    my $iface;
     186
     187    open(RTFILE, "$ROUTE_GET $addr |") || die "couldn't do $ROUTE_GET\n";
     188    while (<RTFILE>) {
     189        if (/interface: (\w+)/) {
     190            $iface = $1;
     191        }
     192    }
     193    close(RTFILE);
     194
     195    die "Couldn't find interface to use." if (!defined($iface));
     196    my $bridge = "bridge" . $count;
     197    my $tun = "tap" . $count;
     198
     199    &setup_bridging($tun, $bridge, $iface, $addr);
    198200    print "Remote connection all set up!\n";  # Trigger other end with output
    199201} else {
Note: See TracChangeset for help on using the changeset viewer.