#!/usr/bin/perl use strict; use IO::File; my $IFCONFIG = "/sbin/ifconfig"; my $ROUTE = "/sbin/route"; my $IPROUTE = "/sbin/ip"; my $hostname = `hostname`; my $routefile = "/usr/local/federation/etc/route/"; $hostname =~ s/\..*//; $routefile = "$routefile$hostname"; my $f = new IO::File($routefile) || die "No routing file: $!\n"; while (<$f>) { chomp; my ($dest, $gw) = split; if (-x $IPROUTE ) { my $cmd = "$IPROUTE route add $dest via $gw"; print("$cmd\n"); system("$cmd"); } elsif (-x $ROUTE ) { system("$ROUTE add $dest $gw"); } else { warn "Cannot find a routing command!\n"; } } $f = new IO::File(">/proc/sys/net/ipv4/ip_forward") || die "Can't open sys forwarding file:$!\n"; print $f "1\n"; $f->close();