source: fedkit/prep_gateway.pl @ 6a8a9ec

axis_examplecompt_changesinfo-opsversion-3.01version-3.02
Last change on this file since 6a8a9ec was 8d4e4fb, checked in by Ted Faber <faber@…>, 15 years ago

Add support for parameters via files in a standard emulab location

Also moved combo_active.pl to combo.pl and added support for passive gateways.

  • 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}
47
48exit(0);
49
50=pod
51
52=head1 NAME
53
54B<prep_tunnel.pl> - Prepare a tunnel node for use as either a service or connectivity gateway.
55
56=head1 OPTIONS
57
58=over 8
59
60=item B<peer=>I<hostname>
61
62The other gateway providing forwarding.
63
64=item B<ssh_pubkey=>I<keyfile>
65
66A public to install as authorized.
67
68=item B<tunnelip>
69
70True if the testbed uses the DETER tunnelip extension to provide external
71connectivity information
72
73=item B<use_file>
74
75If given read additional parameters from the file in
76/proj/I<project>/exp/I<experiment/tmp/I<hostname>.gw/conf where those are the
77current testbed project and experiment and the hostname is before the first
78dot.  The file is option: value.
79
80
81=back
82
83=head1 SYNOPSIS
84
85B<prep_gateway.pl> laods the necessary kernel modules for low-level bridging
86configures the local sshd to allow it, restarts that sshd, and installs the
87given key in root's authorized keys.
88
89If the gateway supports DETER gateway, it setablishes outside connectivity and
90adds a host rout to the given peer.
91
92=head1 AUTHORS
93
94Ted Faber <faber@isi.edu>
95
96=cut
Note: See TracBrowser for help on using the repository browser.