in reply to Is it possible to take the IP address from a file and assign it to LAN interface for certain period of time

Short answer: yes!

Do you really need 253 configuration files with predictable name/contents mapping? If these files are required by an external tool to set the IP, then it would be smarter to generate a temporary config file on demand by the Perl program.

Furthermore, some questions to ask (yourself) to improve your specification:

Because, it's Sunday, here's a template to fiddle with... ;-)

use strict; use warnings; use constant { START_IP_BYTE4 => 2, MAX_IP_BYTE4 => 254, SLEEP => 12 * 3600 }; my @ip = qw(192 168 10 2); $ip[3] = shift || START_IP_BYTE4; while ( 'true' ) { set_ip( @ip ); $ip[3]++; $ip[3] = START_IP_BYTE4 if $ip[3] > MAX_IP_BYTE4; print "Next change: " . localtime( time() + SLEEP ) . "\n"; sleep SLEEP; # floating! } die "oops! $! / $@"; sub set_ip { my @ip = @_; my $ip = join( '.', @ip ); print "Setting local IP to $ip...\n"; print "Load file 'ip$ip[3].txt' ???\n"; #TODO: set local IP }

CPAN-search-terms-of-interest: cron, daemon, ifconfig, ...

  • Comment on Re: Is it possible to take the IP address from a file and assign it to LAN interface for certain period of time
  • Download Code