source: fedkit/prep_gateway.pl @ 358e0b8

axis_examplecompt_changesinfo-opsversion-3.01version-3.02
Last change on this file since 358e0b8 was 55779d4, checked in by Ted Faber <faber@…>, 15 years ago

Supporting nodes connected by transit networks

  • Property mode set to 100644
File size: 2.2 KB
Line 
1#!/usr/bin/perl
2
3use strict;
4
5use gateway_lib;
6
7use Getopt::Long;
8
9my $ssh_pubkey;
10my $tunnelip;
11my $peer;
12my $use_file;
13my %opts = (
14    'ssh_pubkey=s' => \$ssh_pubkey,
15    'tunnelip' => \$tunnelip,
16    'peer=s' => \$peer,
17    'use_file' => \$use_file,
18);
19
20exit(20) unless GetOptions(%opts);
21
22gateway_lib::read_config(gateway_lib::emulab_config_filename(), \%opts)
23    if $use_file;
24
25gateway_lib::set_sshd_params( 
26    { 'GatewayPorts' => 'yes', 'PermitTunnel' => 'yes' } );
27system("/etc/rc.d/sshd restart");
28
29gateway_lib::import_key($ssh_pubkey,'/root/.ssh/authorized_keys')
30    if $ssh_pubkey;
31
32# Need these to make the Ethernet tap and bridge work.
33system("kldload /boot/kernel/bridgestp.ko") 
34    if -r "/boot/kernel/bridgestp.ko"; 
35system("kldload /boot/kernel/if_bridge.ko");
36system("kldload /boot/kernel/if_tap.ko");
37
38if ( $tunnelip ) {
39    my ($interface, $ip, $netmask, $mac, $router) = 
40        gateway_lib::deter_tunnelip();
41
42    gateway_lib::configure_outgoing_iface($interface, $ip, $netmask);
43    # Add the route to a peer.  Wait up to an hour for the peer's IP address to
44    # appear in the DNS.
45    gateway_lib::add_route($peer, $router, 1, 60 *60) 
46        if $peer && $router;
47}
48
49exit(0);
50
51=pod
52
53=head1 NAME
54
55B<prep_tunnel.pl> - Prepare a tunnel node for use as either a service or connectivity gateway.
56
57=head1 OPTIONS
58
59=over 8
60
61=item B<peer=>I<hostname>
62
63The other gateway providing forwarding.
64
65=item B<ssh_pubkey=>I<keyfile>
66
67A public to install as authorized.
68
69=item B<tunnelip>
70
71True if the testbed uses the DETER tunnelip extension to provide external
72connectivity information
73
74=item B<use_file>
75
76If given read additional parameters from the file in
77/proj/I<project>/exp/I<experiment/tmp/I<hostname>.gw/conf where those are the
78current testbed project and experiment and the hostname is before the first
79dot.  The file is option: value.
80
81
82=back
83
84=head1 SYNOPSIS
85
86B<prep_gateway.pl> laods the necessary kernel modules for low-level bridging
87configures the local sshd to allow it, restarts that sshd, and installs the
88given key in root's authorized keys.
89
90If the gateway supports DETER gateway, it setablishes outside connectivity and
91adds a host rout to the given peer.
92
93=head1 AUTHORS
94
95Ted Faber <faber@isi.edu>
96
97=cut
Note: See TracBrowser for help on using the repository browser.