source: fedkit/static_routing.pl @ dffa585

Last change on this file since dffa585 was 9b03842, checked in by Ted Faber <faber@…>, 12 years ago

Fail on no routing

  • Property mode set to 100644
File size: 753 bytes
Line 
1#!/usr/bin/perl
2
3use strict;
4use IO::File;
5
6my $IFCONFIG = "/sbin/ifconfig";
7my $ROUTE = "/sbin/route";
8my $IPROUTE = "/sbin/ip";
9my $hostname = `hostname`;
10my $routefile = "/usr/local/federation/etc/route/";
11
12$hostname =~ s/\..*//;
13$routefile = "$routefile$hostname";
14
15my $f = new IO::File($routefile) || die "No routing file: $!\n";
16while (<$f>) {
17    chomp;
18    my ($dest, $gw) = split;
19    if (-x $IPROUTE ) {
20        my $cmd = "$IPROUTE route add $dest via $gw";
21        print("$cmd\n");
22        system("$cmd");
23    } elsif (-x $ROUTE ) {
24        system("$ROUTE add $dest $gw");
25    } else {
26        warn "Cannot find a routing command!\n";
27    }
28}
29
30$f = new IO::File(">/proc/sys/net/ipv4/ip_forward") || 
31    die "Can't open sys forwarding file:$!\n";
32print $f "1\n";
33$f->close();
34
Note: See TracBrowser for help on using the repository browser.