Re: How to get my own IP address without DNS

From: Jose Maria Lopez Hernandez (jkerouac_at_bgsec.com)
Date: 06/01/05


Date: Wed, 01 Jun 2005 12:05:55 +0200

Kazu wrote:
> Hi.
>
> I am trying to get my own IP address. I know that there is a way to use
> gethostname and gethostbyname, but this has a problem.
> 1. I cannot use this if no DNS is specified.
> 2. If several IP addresses are given for my domain name and
> the ordering is round robin, I cannot tell which one is my real IP address.
>
> Is there any way to get my own IP address in C or C++ without using DNS?
> (such as ifconfig)

The easiest way is to parse the /etc/hosts file, that your system
should use if there's no DNS server.

> Kazuh

Regards.

-- 
Jose Maria Lopez Hernandez
Director Tecnico de bgSEC
jkerouac@bgsec.com
bgSEC Seguridad y Consultoria de Sistemas
http://www.bgsec.com
ESPAŅA
The only people for me are the mad ones -- the ones who are mad to live,
mad to talk, mad to be saved, desirous of everything at the same time,
the ones who never yawn or say a commonplace thing, but burn, burn, burn
like fabulous yellow Roman candles.
                -- Jack Kerouac, "On the Road"


Relevant Pages

  • Re: Monitoring software question
    ... tells port and protocol connected to and what local pc did ... bgSEC Seguridad y Consultoria de Sistemas Informaticos ... The only people for me are the mad ones -- the ones who are mad to live, ... the ones who never yawn or say a commonplace thing, but burn, burn, burn ...
    (comp.security.firewalls)
  • Re: simple question about ip_forward and NAT routing.
    ... can access the internet. ... bgSEC Seguridad y Consultoria de Sistemas Informaticos ... The only people for me are the mad ones -- the ones who are mad to live, ... the ones who never yawn or say a commonplace thing, but burn, burn, burn ...
    (comp.os.linux.networking)
  • Re: IDS, IPS and encrypted traffic
    ... Some people have had success using an squid proxy with the certificates ... bgSEC Seguridad y Consultoria de Sistemas Informaticos ... The only people for me are the mad ones -- the ones who are mad to live, mad to talk, mad to be saved, desirous of everything at the same time, the ones who never yawn or say a commonplace thing, but burn, burn, burn like fabulous yellow Roman candles. ...
    (Focus-IDS)
  • Re: continously running system or not?
    ... > started to switch it off when I don't use it? ... bgSEC Seguridad y Consultoria de Sistemas Informaticos ... The only people for me are the mad ones -- the ones who are mad to live, mad to talk, mad to be saved, desirous of everything at the same time, the ones who never yawn or say a commonplace thing, but burn, burn, burn like fabulous yellow Roman candles. ...
    (comp.os.linux.hardware)
  • Re: how to stop browsing porn sites in school?
    ... >>point of view, there are two techniques, ... bgSEC Seguridad y Consultoria de Sistemas Informaticos ... The only people for me are the mad ones -- the ones who are mad to live, ... the ones who never yawn or say a commonplace thing, but burn, burn, burn ...
    (comp.security.firewalls)