473,396 Members | 1,754 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

how to obtain its ip address ?

I'd search a lot ... but i had not found
how can i obtain my ip address (when i'm connected to the www) ?!

thanks a lot for any tips
marco
Jul 18 '05 #1
6 1765
marco wrote:
I'd search a lot ... but i had not found
how can i obtain my ip address (when i'm connected to the www) ?!


You can probably search the archives for this list/newsgroup to
find more complete answers (and hints about how else to solve it),
but the short answer is "you can't".

The longer answer is that (a) machines can have multiple addresses
so you have to take that into account in the general case, (b)
there is no portable way to do it (and you didn't specify what
platform you are on), and (c) it's generally not necessary anyway,
though there are a few valid usecases... you might even have one.

On Windows you would have to parse the output of the "ipconfig"
command using os.popen or something like that. On Linux the
command is "ifconfig", but the output is totally different.

Provide a little more info about your situation and needs and
you might get a more useful answer.

-Peter
Jul 18 '05 #2
marco <ma******@online.fr> wrote:
: I'd search a lot ... but i had not found
: how can i obtain my ip address (when i'm connected to the www) ?!
Hi Marco,
Here's a quicky way to do it:

###
import socket

def getSelfIp():
"""Returns the IP address of the local host."""
return socket.gethostbyname(socket.gethostname())
###
This might not work perfectly. If you want something more
comprehensive, you may want to use something like the localIP()
function in Webware:

http://webware.sourceforge.net/Webwa.../Funcs.py.html

This appears to be a bit more systematic in getting a good local IP
address.
Good luck to you!
Jul 18 '05 #3
On 2004-06-23, marco <ma******@online.fr> wrote:
I'd search a lot ... but i had not found
how can i obtain my ip address (when i'm connected to the www) ?!

Probably it will depend somewhat on your operating system.
This works for me ...
import socket
socket.gethostbyname('localhost') '127.0.0.1' hostname = socket.gethostname()
hostname 'homer' socket.gethostbyname(hostname)

'172.16.0.5'

Jul 18 '05 #4
In article <H-********************@powergate.ca>,
Peter Hansen <pe***@engcorp.com> wrote:
marco wrote:
I'd search a lot ... but i had not found
how can i obtain my ip address (when i'm connected to the www) ?!


You can probably search the archives for this list/newsgroup to
find more complete answers (and hints about how else to solve it),
but the short answer is "you can't".

The longer answer is that (a) machines can have multiple addresses

Jul 18 '05 #5
Cameron Laird wrote:
In article <H-********************@powergate.ca>,
Peter Hansen <pe***@engcorp.com> wrote:
marco wrote:

I'd search a lot ... but i had not found
how can i obtain my ip address (when i'm connected to the www) ?!


You can probably search the archives for this list/newsgroup to
find more complete answers (and hints about how else to solve it),
but the short answer is "you can't".

The longer answer is that (a) machines can have multiple addresses

.
Even more details appear at <URL:
http://wiki.tcl.tk/MyOwnIPAddress >.


Thanks Cameron. That's a pretty good page (especially if you like
TCL), and it doesn't even get into issues relating to SNAT/DNAT,
routers, firewalls, and the like, which many of us are behind these
days...
Jul 18 '05 #6
marco <ma******@online.fr> wrote in message news:<40***********************@news.free.fr>...
I'd search a lot ... but i had not found
how can i obtain my ip address (when i'm connected to the www) ?!

thanks a lot for any tips
marco


In may case on linux this worked:

$ wget -q "http://ipid.shat.net/iponly" -O - |sed -n 3p

This gives your address as seen from outside, which is probably
what you want, whereas other solutions I tried were giving me
my local address on the LAN.

Michele Simionato
Jul 18 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Jeronimo Bertran | last post by:
Hello, We have developed a socket tcpip server in .net that accepts calls from clients. Using the connected socket we are able to use the Socket.RemoteEndPoint to obtain the IP address of the...
1
by: HB2 | last post by:
Is it possible to obtain the IP address of my desktop using a Visual Basic command?
4
by: Ed Willis | last post by:
We have several offices that have a DSL or Cable modem where the IP address is dynamic and changes often. I created a VB app that obtains the IP address but it obtains the IP address within the...
4
by: stuff | last post by:
Is it possible to obtain the client's ip address from a SimpleXMLRPCServer instance or subclass instance? When running SimpleXMLRPCServer with logRequests = 1, the xmlrpc server prints out the...
0
by: ngr | last post by:
I want to be able to retrieve an ip address: At the moment I have to do the following OBTAIN A DOS WINDOW ROUTE PRINT From this I obtain the IP Address from the dos window thus.... Network...
8
by: Paul Bromley | last post by:
Thanks for your tolerance on this list. I asked the question regarding Commercial Copy Protection along with Unique PC Idnetifier and obtaining the active IP address. This was all to identify and...
7
by: Brian Cryer | last post by:
What I'm looking for is a way to tell if two sessions are from the same physical PC or from different PCs (within the same organisation say). This is with the view to possibly enforcing license...
0
by: leonardo.schmidt | last post by:
Due to some connectivity problems with a client's VPN software, I'm developing an app that needs to obtain the current logged user's Exchange server address & add a new route (among other...
3
by: EnglishmaninNY | last post by:
Hi, I am setting up a self service portal that an internal user can visit in order to obtain their system and network information to then copy/paste to the Helpdesk. The information i hope to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.