Help from scripting folk?

Discussion in 'OT Technology' started by Mikel, Jun 24, 2003.

  1. Mikel

    Mikel .

    Joined:
    May 17, 2000
    Messages:
    227,897
    Likes Received:
    301
    Location:
    38103
    Is it possible to write a script that looks up the IP address of a PPTP interface, then output it to this command-line:

    route add 172.22.1.0 mask 255.255.255.0 <ip address> metric 1

    This is probably mickey mouse for some of you scripting gurus, and I will be indebted to you if you can come up with something. :big grin:
     
  2. Mikel

    Mikel .

    Joined:
    May 17, 2000
    Messages:
    227,897
    Likes Received:
    301
    Location:
    38103
    Pretty please? :big grin:
     
  3. samm

    samm Next in Line

    Joined:
    Dec 22, 2000
    Messages:
    2,630
    Likes Received:
    0
    Location:
    San Jose, CA
    Sound pretty easy to do using perl or awk, what are you having trouble with?
     
  4. Mikel

    Mikel .

    Joined:
    May 17, 2000
    Messages:
    227,897
    Likes Received:
    301
    Location:
    38103
    All of it. I'm just a network guy. :o

    Mind you, this is on a WinXP machine.
     
  5. samm

    samm Next in Line

    Joined:
    Dec 22, 2000
    Messages:
    2,630
    Likes Received:
    0
    Location:
    San Jose, CA
    Then I have no idea. I don't use Windows.

    It would be about a 3 line script using one of the two languages I mentioned earlier.
     
  6. CompiledMonkey

    CompiledMonkey New Member

    Joined:
    Oct 26, 2001
    Messages:
    8,528
    Likes Received:
    0
    Location:
    Richmond, VA
    How did you figure out that IP address? Is it a command or something?
     
  7. Mikel

    Mikel .

    Joined:
    May 17, 2000
    Messages:
    227,897
    Likes Received:
    301
    Location:
    38103
    From ipconfig /all output. Here it is:

    PPP adapter ICS Split:
    Connection-specific DNS Suffix . :
    Description . . . . . . . . . . . : WAN (PPP/SLIP) Interface
    Physical Address. . . . . . . . . : 00-53-45-00-00-00
    Dhcp Enabled. . . . . . . . . . . : No
    IP Address. . . . . . . . . . . . : 172.16.2.92
    Subnet Mask . . . . . . . . . . . : 255.255.255.255
    Default Gateway . . . . . . . . . :
    blah blah
     
  8. CompiledMonkey

    CompiledMonkey New Member

    Joined:
    Oct 26, 2001
    Messages:
    8,528
    Likes Received:
    0
    Location:
    Richmond, VA
    And you only want this to work under Windows? Does it matter which language the script is written in (Java, Perl, etc)?
     
  9. Mikel

    Mikel .

    Joined:
    May 17, 2000
    Messages:
    227,897
    Likes Received:
    301
    Location:
    38103
    Yep, just windows would be great. Doesn't matter what language as long as I have some way of double-clicking it, or launching it right after the PPTP connection is made.
     
  10. CompiledMonkey

    CompiledMonkey New Member

    Joined:
    Oct 26, 2001
    Messages:
    8,528
    Likes Received:
    0
    Location:
    Richmond, VA
    Ok, I'll try and do something for you when I have a moment. If you want an exe, I guess I'll use C# for it. I don't know C/C++ well enough yet and Java or Perl req extra stuff to run. Btw, what does PPTP stand for?
     
  11. Mikel

    Mikel .

    Joined:
    May 17, 2000
    Messages:
    227,897
    Likes Received:
    301
    Location:
    38103
    Thanks. Don't spend too much time on it though, I was hoping it would be a real quick 3-4-liner I could add to if I needed to route other networks through that interface as well (like vbscript I think?).

    PPTP - Point-to-point Tunnelling Protocol. The thing about routing through a PPTP interface is that you have to set the next-hop as the interface itself, which changes every time I reconnect.

    But if you do get a chance, could you also add, "route add 172.24.1.0 mask 255.255.255.0 <ip address> metric 1"?
     
  12. CompiledMonkey

    CompiledMonkey New Member

    Joined:
    Oct 26, 2001
    Messages:
    8,528
    Likes Received:
    0
    Location:
    Richmond, VA
    The only "thing" about this is parsing what is returned when running the command. If there are multiple connections, you've got to go through each until you find PPTP, then go to the IP part and get whatever is there. Not bad, but not 3 or 4 lines.
     
  13. CompiledMonkey

    CompiledMonkey New Member

    Joined:
    Oct 26, 2001
    Messages:
    8,528
    Likes Received:
    0
    Location:
    Richmond, VA
    Sorry man, I haven't had a second to get started on this. I'll try to soon. :hs:
     
  14. Mikel

    Mikel .

    Joined:
    May 17, 2000
    Messages:
    227,897
    Likes Received:
    301
    Location:
    38103
    No problem. This could also be solved if stupid Cisco fixed their VPN client so that it provided a virtual interface. That way I can control routing on the far side of the VPN. :mad:
     
  15. 5Gen_Prelude

    5Gen_Prelude There might not be an "I" in the word "Team", but

    Joined:
    Mar 14, 2000
    Messages:
    14,519
    Likes Received:
    1
    Location:
    Vancouver, BC, CANADA
    Are you having problems with routing outside of the network once you log in via VPN? The easiest way to fix this is to not use the remote gateway on the VPN connection. If you double click the TCP/IP properties there's a checkmark that says Use Remote Gateway. Turn that off and any sites you goto outside of your remote LAN will use your internet gateway.
     
  16. Mikel

    Mikel .

    Joined:
    May 17, 2000
    Messages:
    227,897
    Likes Received:
    301
    Location:
    38103
    Having it unchecked is the problem. I have it unchecked because I don't want all my traffic going through the VPN. Problem is that the resources I want to reach are on other subnets of the corporate network. PPTP doesn't allow me to define interesting traffic at the far end so I need a route statement to each of those subnets. Cisco IPSec VPNs allow this, but doesn't create a virtual interface so my SIP client doesn't see it. Bah.
     
  17. dexedrine

    dexedrine Guest

  18. dexedrine

    dexedrine Guest

    if it doesn't show the ip address it might not be doing something correctly. just double click on your ip and it should run the command.
     
  19. Mikel

    Mikel .

    Joined:
    May 17, 2000
    Messages:
    227,897
    Likes Received:
    301
    Location:
    38103
    Thanks for your help guys. But guess what? Cisco just released a new VPN client on June 23rd that does the job. :big grin:

    Thanks dexedrine. That seems to work too; now I've got 2 options. :cool:
     

Share This Page