--- /dev/null
+package ssh;
+
+use Net::OpenSSH;
+
+my $id = 2;
+
+sub ethernet_bridge_to {
+ my $host = shift;
+
+ warn "# reset local IP address";
+ system "ifconfig virtual 172.16.10.$id";
+
+ warn "# connect to $host";
+ my $ssh = Net::OpenSSH->new( $host,
+ master_opts => [ -w => "$id:$id", -o => 'Tunnel=ethernet' ],
+ );
+
+ foreach my $command ( "ifconfig tap$id up", "brctl addif virtual tap$id" ) {
+ warn "# $command";
+ system $command;
+ $ssh->system( $command ) or die "$command ", $ssh->error;
+ }
+
+ warn "press enter to close tunnel to $host from $id";
+ <STDIN>;
+
+}
+
+1;