1 | #!/usr/bin/perl |
---|
2 | |
---|
3 | use strict; |
---|
4 | |
---|
5 | use gateway_lib; |
---|
6 | |
---|
7 | use Getopt::Long; |
---|
8 | |
---|
9 | my $ssh_pubkey; |
---|
10 | my $tunnelip; |
---|
11 | my $peer; |
---|
12 | |
---|
13 | exit(20) unless GetOptions('ssh_pubkey=s' => \$ssh_pubkey, |
---|
14 | 'tunnelip' => \$tunnelip, |
---|
15 | 'peer=s' => \$peer, |
---|
16 | ); |
---|
17 | |
---|
18 | gateway_lib::set_sshd_params( |
---|
19 | { 'GatewayPorts' => 'yes', 'PermitTunnel' => 'yes' } ); |
---|
20 | system("/etc/rc.d/sshd restart"); |
---|
21 | |
---|
22 | gateway_lib::import_key($ssh_pubkey,'/root/.ssh/authorized_keys') |
---|
23 | if $ssh_pubkey; |
---|
24 | |
---|
25 | # Need these to make the Ethernet tap and bridge work. |
---|
26 | system("kldload /boot/kernel/bridgestp.ko") |
---|
27 | if -r "/boot/kernel/bridgestp.ko"; |
---|
28 | system("kldload /boot/kernel/if_bridge.ko"); |
---|
29 | system("kldload /boot/kernel/if_tap.ko"); |
---|
30 | |
---|
31 | if ( $tunnelip ) { |
---|
32 | my ($interface, $ip, $netmask, $mac, $router) = |
---|
33 | gateway_lib::deter_tunnelip(); |
---|
34 | |
---|
35 | gateway_lib::configure_outgoing_iface($interface, $ip, $netmask); |
---|
36 | # Add the route to a peer. Wait up to an hour for the peer's IP address to |
---|
37 | # appear in the DNS. |
---|
38 | gateway_lib::add_route($peer, $router, 1, 60 *60); |
---|
39 | } |
---|
40 | |
---|
41 | exit(0); |
---|
42 | |
---|
43 | =pod |
---|
44 | |
---|
45 | =head1 NAME |
---|
46 | |
---|
47 | B<prep_tunnel.pl> - Prepare a tunnel node for use as either a service or connectivity gateway. |
---|
48 | |
---|
49 | =head1 OPTIONS |
---|
50 | |
---|
51 | =over 8 |
---|
52 | |
---|
53 | =item B<peer=>I<hostname> |
---|
54 | |
---|
55 | The other gateway providing forwarding. |
---|
56 | |
---|
57 | =item B<ssh_pubkey=>I<keyfile> |
---|
58 | |
---|
59 | A public to install as authorized. |
---|
60 | |
---|
61 | =item B<tunnelip> |
---|
62 | |
---|
63 | True if the testbed uses the DETER tunnelip extension to provide external |
---|
64 | connectivity information |
---|
65 | |
---|
66 | =back |
---|
67 | |
---|
68 | =head1 SYNOPSIS |
---|
69 | |
---|
70 | B<prep_gateway.pl> laods the necessary kernel modules for low-level bridging |
---|
71 | configures the local sshd to allow it, restarts that sshd, and installs the |
---|
72 | given key in root's authorized keys. |
---|
73 | |
---|
74 | If the gateway supports DETER gateway, it setablishes outside connectivity and |
---|
75 | adds a host rout to the given peer. |
---|
76 | |
---|
77 | =head1 AUTHORS |
---|
78 | |
---|
79 | Ted Faber <faber@isi.edu> |
---|
80 | |
---|
81 | =cut |
---|