1 | #!/usr/bin/perl |
---|
2 | |
---|
3 | use strict; |
---|
4 | |
---|
5 | use gateway_lib; |
---|
6 | |
---|
7 | use IO::File; |
---|
8 | |
---|
9 | use Getopt::Long; |
---|
10 | |
---|
11 | my $ssh_pubkey; |
---|
12 | my $ssh_privkey; |
---|
13 | my $tunnelip; |
---|
14 | my $peer; |
---|
15 | my $fedkit_dir= "/usr/local/federation"; |
---|
16 | my $perl = "/usr/bin/perl"; |
---|
17 | my $iface_file = "/var/emulab/boot/ifmap"; |
---|
18 | my $ssh = "/usr/bin/ssh"; |
---|
19 | my $use_file; |
---|
20 | |
---|
21 | my %opts = ( |
---|
22 | 'ssh_pubkey=s' => \$ssh_pubkey, |
---|
23 | 'ssh_privkey=s' => \$ssh_privkey, |
---|
24 | 'tunnelip' => \$tunnelip, |
---|
25 | 'peer=s' => \$peer, |
---|
26 | 'fedkit=s' => \$fedkit_dir, |
---|
27 | 'perl=s' => \$perl, |
---|
28 | 'interfaces=s' => \$iface_file, |
---|
29 | 'ssh=s' => \$ssh, |
---|
30 | 'use_file' => \$use_file, |
---|
31 | ); |
---|
32 | |
---|
33 | exit(20) unless GetOptions(%opts); |
---|
34 | |
---|
35 | gateway_lib::read_config(gateway_lib::emulab_config_filename(), \%opts) |
---|
36 | if $use_file; |
---|
37 | |
---|
38 | my $tunnelparam = $tunnelip ? '--tunnelip' : ''; |
---|
39 | |
---|
40 | system("$perl -I$fedkit_dir/lib $fedkit_dir/bin/prep_gateway.pl --peer=$peer " . |
---|
41 | "--ssh_pubkey=$ssh_pubkey $tunnelparam"); |
---|
42 | exit(20) if $?; |
---|
43 | |
---|
44 | my $f = new IO::File($iface_file) || die "Can't open $iface_file: $!\n"; |
---|
45 | my $ifnum = 0; |
---|
46 | |
---|
47 | while (<$f>) { |
---|
48 | /([[:alnum:]]+)\s+([\d\.]+)/ && do { |
---|
49 | my ($iface, $addr) = ($1, $2); |
---|
50 | |
---|
51 | my $cmd = "$ssh -w $ifnum:$ifnum -o \"Tunnel ethernet\" " . |
---|
52 | "-o \"StrictHostKeyChecking no\" -i $ssh_privkey " . |
---|
53 | "$peer perl -I$fedkit_dir/lib $fedkit_dir/bin/setup_bridge.pl " . |
---|
54 | "--tapno=$ifnum --dest=$addr &"; |
---|
55 | system($cmd); |
---|
56 | die if $?; |
---|
57 | gateway_lib::bind_tap_to_iface($ifnum, $iface, $addr); |
---|
58 | $ifnum++; |
---|
59 | }; |
---|
60 | } |
---|
61 | $f->close(); |
---|
62 | exit(0); |
---|
63 | |
---|
64 | =pod |
---|
65 | |
---|
66 | =head1 NAME |
---|
67 | |
---|
68 | B<active_config.pl> - Configure an active connectivity gateway under the DETER Federation Architecture |
---|
69 | |
---|
70 | =head1 OPTIONS |
---|
71 | |
---|
72 | =over 8 |
---|
73 | |
---|
74 | =item B<fedkit=>I<install_dir> |
---|
75 | |
---|
76 | Directory in which this software is installed. Generally not needed. |
---|
77 | |
---|
78 | =item B<interfaces=>I<interface table> |
---|
79 | |
---|
80 | A list of interfaces to forward data on of the form: |
---|
81 | |
---|
82 | =begin text |
---|
83 | |
---|
84 | iface ip_addr |
---|
85 | |
---|
86 | =end text |
---|
87 | |
---|
88 | The interface is the operating system name of the interface and the IP address |
---|
89 | is given in standard dotted decimal notation. Other characters on a line are |
---|
90 | ignored. |
---|
91 | |
---|
92 | =item B<peer=>I<hostname> |
---|
93 | |
---|
94 | The other gateway providing forwarding. |
---|
95 | |
---|
96 | =item B<perl=>I<perl_binary> |
---|
97 | |
---|
98 | Location of the perl binary. Usually unneeded. |
---|
99 | |
---|
100 | =item B<ssh=>I<ssh_binary> |
---|
101 | |
---|
102 | The pathname of the ssh binary. Unusally unnecessary. |
---|
103 | |
---|
104 | =item B<ssh_pubkey=>I<keyfile> |
---|
105 | |
---|
106 | A public to install as authorized. |
---|
107 | |
---|
108 | =item B<ssh_privkey=>I<identity_file> |
---|
109 | |
---|
110 | The identity to use for remote access |
---|
111 | |
---|
112 | =item B<tunnelip> |
---|
113 | |
---|
114 | True if the testbed uses the DETER tunnelip extension to provide external |
---|
115 | connectivity information |
---|
116 | |
---|
117 | =item B<use_file> |
---|
118 | |
---|
119 | If given read additional parameters from the file in |
---|
120 | /proj/I<project>/exp/I<experiment/tmp/I<hostname>.gw/conf where those are the |
---|
121 | current testbed project and experiment and the hostname is before the first |
---|
122 | dot. The file is option: value. |
---|
123 | |
---|
124 | |
---|
125 | =back |
---|
126 | |
---|
127 | =head1 SYNOPSIS |
---|
128 | |
---|
129 | B<active_config.pl> initiates the active side of the connectivity connection, |
---|
130 | which is to say that it: |
---|
131 | |
---|
132 | =over 4 |
---|
133 | |
---|
134 | =item * |
---|
135 | |
---|
136 | Installs local keys and reconfigures that local ssh system to do link layer |
---|
137 | tunneling. |
---|
138 | |
---|
139 | =item * |
---|
140 | |
---|
141 | Starts a tunnel for each interface in the given interface table, both locally |
---|
142 | and remotely. |
---|
143 | |
---|
144 | =back |
---|
145 | |
---|
146 | =head1 AUTHORS |
---|
147 | |
---|
148 | Ted Faber <faber@isi.edu> |
---|
149 | |
---|
150 | =cut |
---|