Ip address

Steve Holden steve at holdenweb.com
Sun Jan 28 09:09:48 EST 2007


Adam wrote:
> Hey,
> 
> This will get your IP address:
> 
> #######Code########
> print socket.gethostbyaddr(socket.gethostname())
> ('compname', [], ['192.168.1.2'])
> ########End Code########
> 
> If you are wanting to to communicate over the internet you will have 
> to get the IP of you rounter. So you will have to either find a way to 
> talk to your router or try and use an online service like these other 
> guys suggest.

There is absolutely no need to know the IP address of "your router" to 
communicate with Internet devices. Either your IP layer is configured to 
know the addresses of one or more routers, or it has discovered those 
address by dynamic means, or you can't get off-net because there aren't 
any routers.

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd          http://www.holdenweb.com
Skype: holdenweb     http://del.icio.us/steve.holden
Blog of Note:          http://holdenweb.blogspot.com
See you at PyCon?         http://us.pycon.org/TX2007




More information about the Python-list mailing list