accumulo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ott, Charles H." <CHARLES.H....@saic.com>
Subject RE: Getting the IP Address
Date Wed, 28 Aug 2013 18:50:10 GMT
Not sure if this helps, but this script will give you an IP on all network interfaces that
are not “lo” (loopback). 

 You could customize it by adding adapters you want ignored, or specifying the one you want
as the response. Works on centos 6.2



#! /usr/bin/env bash

for network in $(cat /proc/net/dev | grep ':' | cut -d: -f1 | awk '{ print $1 }'); do

if [ "$network" != "lo" ]

then

echo $(/sbin/ifconfig $network | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}')

fi

done

 

 

 

From: user-return-2955-CHARLES.H.OTT=saic.com@accumulo.apache.org [mailto:user-return-2955-CHARLES.H.OTT=saic.com@accumulo.apache.org]
On Behalf Of Sean Busbey
Sent: Wednesday, August 28, 2013 2:10 PM
To: Accumulo User List
Subject: Re: Getting the IP Address

 

Provided it works with /etc/hosts files, would that matter?

 

on my test CentOS 6.2 VM (with a host-only adapter and /etc/hosts) I properly get my external
facing local IP from hostname -i.

 

Before I set up /etc/hosts to have a name to ip address (and assigned the machine its own
name) hostname -i returned 127.0.0.1 (as I would expect since the name was localhost).

 

This seems like it will work fine for a stand alone VM (the majority of first time users)
and for those setting up clusters without DNS.

 

 

 

On Wed, Aug 28, 2013 at 12:54 PM, John Vines <vines@apache.org> wrote:

We use this similar logic throughout a lot of our scripts for determining the external facing
IP address in a portable manner, it's just that the init.d scripts are a bit more strict about
it. This is the equivalent of using the name defined in the slaves/masters/tracers/etc. files
to determine which port to report as.

 

Switching to a system that depends on DNS to succeed will fail for all first time users, which
is a penalty that will not be worth it. If someone can find a better way to determine outward
facing IP address I would love to have it, but unfortunately networks are hard.

 

On Wed, Aug 28, 2013 at 1:44 PM, Billie Rinaldi <billie.rinaldi@gmail.com> wrote:

Good point.  I don't care if the init.d scripts work on a Mac.  I do care about the other
scripts, though.

 

On Wed, Aug 28, 2013 at 10:32 AM, Christopher <ctubbsii@apache.org> wrote:

But... it shouldn't be a supported platform for init scripts... I imagine.

--
Christopher L Tubbs II
http://gravatar.com/ctubbsii



On Wed, Aug 28, 2013 at 1:03 PM, Billie Rinaldi
<billie.rinaldi@gmail.com> wrote:
> It's a supported development platform.  =)
>
>
> On Wed, Aug 28, 2013 at 9:59 AM, Sean Busbey <busbey@cloudera.com> wrote:
>>
>> hostname -i does not work on a Mac ( 10.8.4 )
>>
>> Is Mac a supported platform?
>>
>>
>> On Wed, Aug 28, 2013 at 11:53 AM, Eric Newton <eric.newton@gmail.com>
>> wrote:
>>>
>>> Does "hostname -i" work on a mac?  Not being a mac user, I can't check.
>>>
>>> -Eric
>>>
>>>
>>>
>>> On Wed, Aug 28, 2013 at 11:38 AM, Ravi Mutyala <ravi@hortonworks.com>
>>> wrote:
>>>>
>>>> Hi,
>>>>
>>>> I see from the accumulo-tracer init.d script that IP is determined by
>>>> this logic.
>>>>
>>>> ifconfig | grep inet[^6] | awk '{print $2}' | sed 's/addr://' | grep -v
>>>> 0.0.0.0 | grep -v 127.0.0.1 | head -n 1
>>>>
>>>>
>>>> Any reason for using this logic instead of a hostname -i and using
>>>> reverse dns lookup? I have a cluster where the order of nics on one of the
>>>> nodes is in a different order and ifconfig returns a IP from a different
>>>> subnet than for other nodes. But DNS and reverse DNS are properly
>>>> configured.
>>>>
>>>> Thanks
>>>>
>>>> CONFIDENTIALITY NOTICE
>>>> NOTICE: This message is intended for the use of the individual or entity
>>>> to which it is addressed and may contain information that is confidential,
>>>> privileged and exempt from disclosure under applicable law. If the reader
of
>>>> this message is not the intended recipient, you are hereby notified that
any
>>>> printing, copying, dissemination, distribution, disclosure or forwarding
of
>>>> this communication is strictly prohibited. If you have received this
>>>> communication in error, please contact the sender immediately and delete
it
>>>> from your system. Thank You.
>>>
>>>
>>
>>
>>
>> --
>> Sean
>
>

 

 





 

-- 

Sean

Mime
View raw message