[Tutor] Detecting my own IP address?
Simon Gerber
nequeo at gmail.com
Sun Jun 5 09:39:16 CEST 2005
G'day,
I'm currently blundering through a script that will let me configure and
then connect to PPTP VPNs from a Linux box. Just a text-based front-end
to pptp-client, really.
Adding in new VPN configurations was simple. Connecting is a little
harder. From the command-line I would normally type: "sudo pon $TUNNEL",
where TUNNEL is the name of the connection.
This is followed by "sudo route add -net 192.168.1.0 netmask
255.255.255.0 dev ppp0" (as an example), once the tunnel was established.
What I would really like the script to be able to do is detect when the
tunnel connects, grab the IP address, and then create an appropriate
route. At present, the only thing I can think of is to redirect the
output of 'ifconfig' into a temporary file, then read it back in and use
Python and regular expressions to try and extract the IP info from that.
I could *probably* make that work... but I wouldn't feel very proud
about it.
Does anyone have any clues? I do prefer to figure things out for myself
*cough*google*cough*, but in this case I'm not really sure where to
start looking.
Any help would be appreciated.
Regards,
More information about the Tutor
mailing list