source: fedkit/prep_gateway.pl @ 2edec46

axis_examplecompt_changesinfo-opsversion-3.01version-3.02
Last change on this file since 2edec46 was 2edec46, checked in by Ted Faber <faber@…>, 14 years ago

Factored gateway implementation. Initial import.

  • Property mode set to 100644
File size: 1019 bytes
Line 
1#!/usr/bin/perl
2
3use strict;
4
5use gateway_lib;
6
7use Getopt::Long;
8
9my $ssh_pubkey;
10my $tunnelip;
11my $peer;
12
13exit(20) unless GetOptions('ssh_pubkey=s' => \$ssh_pubkey,
14    'tunnelip' => \$tunnelip,
15    'peer=s' => \$peer,
16);
17
18gateway_lib::set_sshd_params( 
19    { 'GatewayPorts' => 'yes', 'PermitTunnel' => 'yes' } );
20system("/etc/rc.d/sshd restart");
21
22gateway_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.
26system("kldload /boot/kernel/bridgestp.ko") 
27    if -r "/boot/kernel/bridgestp.ko"; 
28system("kldload /boot/kernel/if_bridge.ko");
29system("kldload /boot/kernel/if_tap.ko");
30
31if ( $tunnelip ) {
32    my ($interface, $ip, $netmask, $mac, $router) = 
33        gateway_lib::deter_tunnelip();
34
35    gateway_lib::configure_outgoing_iface($interface, $ip, $netmask, $mac);
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
41exit(0);
Note: See TracBrowser for help on using the repository browser.