Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Perl script to run ipconfig command command prompt, fetch the ip address assign to specific network interface and add a route in command prompt for this ip?

by Anonymous Monk
on Jun 24, 2015 at 11:55 UTC ( [id://1131791]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Perl script to run ipconfig command command prompt, fetch the ip address assign to specific network interface and add a route in command prompt for this ip?

i have 3 NIC card connected to windows PC.

IP of one NIC card is getting ip from DHCP, so ip is changing when ever i m rebooting.

i have to add a route for this IP in command prompt.

So need a perl script to add a route for this new ip through script.

IPCONFIG output is like this

Ethernet adapter Local Area Connection 2:</P> <p> Connection-specific DNS Suffix . : </P> <p> IP Address. . . . . . . . . . . . : 135.250.192.101</P> <p> Subnet Mask . . . . . . . . . . . : 255.255.255.0</P> <p> IP Address. . . . . . . . . . . .fe80::200:21ff:fe5c:8629%4</P> <p> Default Gateway . . . . . . . . . : 125.250.192.254</P> <p>Ethernet adapter Local Area Connection:</P> <p> Connection-specific DNS Suffix . : </P> <p> IP Address. . . . . . . . . . . . : 172.1.2.13</P> <p> Subnet Mask . . . . . . . . . . . : 255.255.255.0</P> <p> IP Address. . . . . . . . . . . .fe80::221:9bff:feea:b45c%5</P>

the route command is like this

add route 192.168.254.2 mask 255.255.255.255 <IP of Ethernet adapter L +ocal Area Connection>
  • Comment on Perl script to run ipconfig command command prompt, fetch the ip address assign to specific network interface and add a route in command prompt for this ip?
  • Select or Download Code

Replies are listed 'Best First'.
Re: Perl script to run ipconfig command command prompt, fetch the ip address assign to specific network interface and add a route in command prompt for this ip?
by marto (Cardinal) on Jun 24, 2015 at 11:59 UTC
Re: Perl script to run ipconfig command command prompt, fetch the ip address assign to specific network interface and add a route in command prompt for this ip?
by trippledubs (Deacon) on Jun 24, 2015 at 12:11 UTC
    Does the -p flag in your route command make any difference? Makes route persistent across reboots.

      gateway ip is changing , that why -p option not helpfull

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1131791]
Approved by jellisii2
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2024-04-18 09:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found