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