#!/usr/bin/perl use strict; use IO::File; use IO::Pipe; my $IFCONFIG = "/sbin/ifconfig"; my @GATEDS= ("/usr/sbin/gated", "/sbin/gated" ); my $GATED; my $fn = "/usr/local/federation/etc/gated.conf"; my @live_ones; chomp (my $cif = `/usr/local/etc/emulab/control_interface`); my $ifp = new IO::Pipe(); $ifp->reader("$IFCONFIG"); while (<$ifp>) { /^(eth\d+)/ && do { push(@live_ones, $1) unless $1 eq $cif; }; } $ifp->close(); foreach my $g (@GATEDS) { if (-x $g ) { $GATED = $g; last; } } die "Can't find gated in " . join(",", @GATEDS) . "\n" unless $GATED; my $f = new IO::File(">$fn") || die "Can't open $fn: $!\n"; print $f <close(); $f = new IO::File(">/proc/sys/net/ipv4/ip_forward") || die "Can't open sys forwarding file:$!\n"; print $f "1\n"; $f->close(); system("$GATED -f $fn");