Re: Just gimme the IP!

2011-06-15 Thread Jordon Bedwell
On 6/14/2011 2:59 PM, Luke Faraone wrote:
 We could just get an API key from whatismyip.com, or use whatismyip.org

Wouldn't it be much more viable to just create a quick script on a
sub-domain ip.launchpad.net or ip.ubuntu.com or ip.canonical.com and
then curl or wget it? EXP:

curl -s ip.envygeeks.com
wget -q -O - ip.envygeeks.com

No added text, no need to grep, no need to sed, nothing but the IP. You
can even have the script adjust the curl command per interface too
making it so if you have multiple IP's you can get each one.



-- 
ubuntu-devel mailing list
ubuntu-devel@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel


Re: Just gimme the IP!

2011-06-15 Thread Alan Pope
On 14 June 2011 20:59, Luke Faraone l...@faraone.cc wrote:
 On 06/14/2011 12:09 PM, Mathieu Trudel-Lapierre wrote:
 Would it make sense to also have a way to get the current *public* ip
 address?

 That's difficult to determine, without calling on an external service.

 We could just get an API key from whatismyip.com, or use whatismyip.org
 / icanhazip.com.


We already have an app in the default install which does something
similar. The remote desktop server makes a call out to the
author/maintainers website to discover if the Ubuntu install is
remotely accessible via VNC.

Aside: I believe we shouldn't be leaking info like this.
https://bugs.launchpad.net/ubuntu/+source/vino/+bug/608701

Perhaps as Jordon suggests a *.ubuntu.com based service would be
preferable both for IP discovery and VNC connectivity test.

Al.

-- 
ubuntu-devel mailing list
ubuntu-devel@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel


Re: Just gimme the IP!

2011-06-15 Thread Luke Faraone
On 06/15/2011 11:37 AM, Clint Byrum wrote:
 Except that this would fail completely if you don't have access to
 ip.envygeeks.com.

Which would mean that either their host is down, or you don't have a
route to the public Internet.

The unavailability of a single host could be resolved by testing
multiple, with a short timeout.

-- 
Luke Faraone;; Debian  Ubuntu Developer; Sugar Labs, Systems
lfaraone on irc.[freenode,oftc].net -- http://luke.faraone.cc
PGP fprint: 5189 2A7D 16D0 49BB 046B DC77 9732 5DD8 F9FD D506



signature.asc
Description: OpenPGP digital signature
-- 
ubuntu-devel mailing list
ubuntu-devel@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel


Re: Just gimme the IP!

2011-06-15 Thread Clint Byrum
Excerpts from Luke Faraone's message of Wed Jun 15 08:44:52 -0700 2011:
 On 06/15/2011 11:37 AM, Clint Byrum wrote:
  Except that this would fail completely if you don't have access to
  ip.envygeeks.com.
 
 Which would mean that either their host is down, or you don't have a
 route to the public Internet.

Precisely. Corporate networks often don't have a route to the
internet. Especially when talking about complex server setups.

-- 
ubuntu-devel mailing list
ubuntu-devel@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel


Re: Just gimme the IP!

2011-06-15 Thread Clint Byrum
Excerpts from Dustin Kirkland's message of Mon Jun 13 18:58:21 -0700 2011:
 Howdy ubuntu-devel!
 
 I'm seeing quite a bit of code duplication in scripts and packaging in
 Ubuntu around the determination of IP addresses.
 
 Most are permutations of 'ifconfig' or 'ip addr', and four to six
 pipes through awk, grep, sed, and/or cut.  Some others dig through
 /proc.  Some are buggy (ie, more than one ip address on the system,
 foreign locale but does not set LC_ALL=C, etc).  Many of them do their
 job well enough, but I can't help but think there's some room for
 improvement.

First, Dustin, thanks for taking this on. Seeing my hacks on top of
hacks in principia seems to have pushed you to do something positive
about the propagation of this flawed technique, which if nothing else
has accomplished a spirited discussion about the issue.

However, after reading the logs of Dustin's discussion on IRC w/ Keybuk
and cjwatson, I have to think that this is actually something we should
move away from.

The usage of the ifconfig parse hack in principia is actually completely
unnecessary, and stems from a very old distrust of DNS that I have had for
a long time as a sysadmin. The truth of the matter is, DNS is the right
way to resolve this, and any latency concerns should be addressed with
local DNS caches.

You should have an FQDN, and it should always lead a remote host that
can talk to you, to the IP that it needs to use to talk to you. This
isn't always true, but in the use case we have in Ensemble and Principia,
this is precisely the case. Amazon assigns an IP and a FQDN to each host,
and that FQDN resolves inside Amazon to the internal IP that any machine
on the same security group can use to access it.

For anything else, you need more information that isn't available on
the machine anyway (such as your external NAT address or elastic IP in
the EC2 case).

So really, passing what I *think* is my IP isn't nearly as useful as
passing what I *know* is my hostname. This is especially important as
we transition to IPv6.

For the other places where IP is being used, the use should be evaluated,
as its likely hostname would work, and should be used instead.

-- 
ubuntu-devel mailing list
ubuntu-devel@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel


Re: Just gimme the IP!

2011-06-14 Thread Mathieu Trudel-Lapierre
On Mon, Jun 13, 2011 at 9:58 PM, Dustin Kirkland kirkl...@ubuntu.com wrote:
 Howdy ubuntu-devel!

 I'm seeing quite a bit of code duplication in scripts and packaging in
 Ubuntu around the determination of IP addresses.

 Most are permutations of 'ifconfig' or 'ip addr', and four to six
 pipes through awk, grep, sed, and/or cut.  Some others dig through
 /proc.  Some are buggy (ie, more than one ip address on the system,
 foreign locale but does not set LC_ALL=C, etc).  Many of them do their
 job well enough, but I can't help but think there's some room for
 improvement.

[...]
 In the interest of consistency, I'm wondering if it would make sense
 to create and maintain a stable, definitive utility somewhere in
 Ubuntu's default seed to provide the system's ip address,
 *succinctly*, quickly, and reliably.

Yes, it would. I also think it should be based off 'ip addr' where
possible, since that seems to provide information in the most
manageable way.

 I'd think it should:
  a) default to ipv4, but support a -6|--ipv6 option
  b) default to the interface providing the default route, but support
 an optional interface parameter
  c) be very, very fast (ie, I looked at facter, but it's pretty slow)

 I have what I think is a decent working implementation of the above at:
  * http://people.canonical.com/~kirkland/ipaddr

Looks really nice. I think you could simplify it just a bit with a
slightly different call of ip addr:

mtrudel@artemis ~ % ip -o -f inet addr show
1: loinet 127.0.0.1/8 scope host lo
2: eth0inet 192.168.3.10/24 brd 192.168.3.255 scope global eth0
6: virbr0inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
mtrudel@artemis ~ % ip -o -f inet6 addr show
1: loinet6 ::1/128 scope host \   valid_lft forever
preferred_lft forever
2: eth0inet6 2001:470:1d:356::10/64 scope global \   valid_lft
forever preferred_lft forever
2: eth0inet6 fe80::f24d:a2ff:fec3:96fe/64 scope link \
valid_lft forever preferred_lft forever
14: teredoinet6 2001:0:53aa:64c:2838:4216:9fea:e0a8/32 scope global \

(-o stands for oneline, and output for each device actually is on one
line; in case this doesn't show up properly here)

Would it make sense to also have a way to get the current *public* ip address?

/ Matt

-- 
ubuntu-devel mailing list
ubuntu-devel@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel


Re: Just gimme the IP!

2011-06-14 Thread Scott Ritchie
On 06/13/2011 07:06 PM, Scott Kitterman wrote:
 On Monday, June 13, 2011 09:58:21 PM Dustin Kirkland wrote:
 What do you think?  Have you seen scripts or packaging in Ubuntu that
 would benefit from a solid, recommended ip determination utility?
 Where should it live?  net-tools?  iproute?  Somewhere else?
 
 I'm not sure where it should live, but I think it should have a different 
 name 
 as it's not a generic IP address utility, but one for a single specific 
 purpose.  Maybe sysip?
 
 Scott K
 

My thought was it should be something analogous to whoami -- I don't
want to join in on a naming bikeshed though.  Also this reminds me of
whatismyip.com

Having it by default sounds like a win though.

Thanks,
Scott Ritchie

-- 
ubuntu-devel mailing list
ubuntu-devel@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel


Re: Just gimme the IP!

2011-06-14 Thread Luke Faraone
On 06/14/2011 03:03 PM, Scott Ritchie wrote:
 My thought was it should be something analogous to whoami -- I 
 don't want to join in on a naming bikeshed though.  Also this reminds
 me of whatismyip.com

That only tells you via the default route, and only the public IP as
detected by that site. See below.

On 06/14/2011 12:09 PM, Mathieu Trudel-Lapierre wrote:
 Would it make sense to also have a way to get the current *public* ip
 address?

That's difficult to determine, without calling on an external service.

We could just get an API key from whatismyip.com, or use whatismyip.org
/ icanhazip.com.

-- 
Luke Faraone;; Debian  Ubuntu Developer; Sugar Labs, Systems
lfaraone on irc.[freenode,oftc].net -- http://luke.faraone.cc
PGP fprint: 5189 2A7D 16D0 49BB 046B DC77 9732 5DD8 F9FD D506



signature.asc
Description: OpenPGP digital signature
-- 
ubuntu-devel mailing list
ubuntu-devel@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel


Just gimme the IP!

2011-06-13 Thread Dustin Kirkland
Howdy ubuntu-devel!

I'm seeing quite a bit of code duplication in scripts and packaging in
Ubuntu around the determination of IP addresses.

Most are permutations of 'ifconfig' or 'ip addr', and four to six
pipes through awk, grep, sed, and/or cut.  Some others dig through
/proc.  Some are buggy (ie, more than one ip address on the system,
foreign locale but does not set LC_ALL=C, etc).  Many of them do their
job well enough, but I can't help but think there's some room for
improvement.

Here are a few I've found in some server packages:
  IP=`ifconfig  | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2
| awk '{ print $1}'|head -n 1`
  MYIP=$(ifconfig eth0 | grep inet addr | awk -F: '{print $2}' |
awk '{print $1}')
  addr_withprefix=$(ip addr show label $default_interface scope global
| awk '$1 == inet { print $2 }' | sed s:/.*::)

In the interest of consistency, I'm wondering if it would make sense
to create and maintain a stable, definitive utility somewhere in
Ubuntu's default seed to provide the system's ip address,
*succinctly*, quickly, and reliably.

I'd think it should:
 a) default to ipv4, but support a -6|--ipv6 option
 b) default to the interface providing the default route, but support
an optional interface parameter
 c) be very, very fast (ie, I looked at facter, but it's pretty slow)

I have what I think is a decent working implementation of the above at:
 * http://people.canonical.com/~kirkland/ipaddr

$ ipaddr
192.168.1.109

$ ipaddr virbr0
192.168.122.1

$ time ./ipaddr tap0
10.13.17.92
real0m0.011s

What do you think?  Have you seen scripts or packaging in Ubuntu that
would benefit from a solid, recommended ip determination utility?
Where should it live?  net-tools?  iproute?  Somewhere else?

-- 
:-Dustin

Dustin Kirkland
Ubuntu Core Developer

-- 
ubuntu-devel mailing list
ubuntu-devel@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel


Re: Just gimme the IP!

2011-06-13 Thread Scott Kitterman
On Monday, June 13, 2011 09:58:21 PM Dustin Kirkland wrote:
 Howdy ubuntu-devel!
 
 I'm seeing quite a bit of code duplication in scripts and packaging in
 Ubuntu around the determination of IP addresses.
 
 Most are permutations of 'ifconfig' or 'ip addr', and four to six
 pipes through awk, grep, sed, and/or cut.  Some others dig through
 /proc.  Some are buggy (ie, more than one ip address on the system,
 foreign locale but does not set LC_ALL=C, etc).  Many of them do their
 job well enough, but I can't help but think there's some room for
 improvement.
 
 Here are a few I've found in some server packages:
   IP=`ifconfig  | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2
 
 | awk '{ print $1}'|head -n 1`
 
   MYIP=$(ifconfig eth0 | grep inet addr | awk -F: '{print $2}' |
 awk '{print $1}')
   addr_withprefix=$(ip addr show label $default_interface scope global
 
 | awk '$1 == inet { print $2 }' | sed s:/.*::)
 
 In the interest of consistency, I'm wondering if it would make sense
 to create and maintain a stable, definitive utility somewhere in
 Ubuntu's default seed to provide the system's ip address,
 *succinctly*, quickly, and reliably.
 
 I'd think it should:
  a) default to ipv4, but support a -6|--ipv6 option
  b) default to the interface providing the default route, but support
 an optional interface parameter
  c) be very, very fast (ie, I looked at facter, but it's pretty slow)
 
 I have what I think is a decent working implementation of the above at:
  * http://people.canonical.com/~kirkland/ipaddr
 
 $ ipaddr
 192.168.1.109
 
 $ ipaddr virbr0
 192.168.122.1
 
 $ time ./ipaddr tap0
 10.13.17.92
 real0m0.011s
 
 What do you think?  Have you seen scripts or packaging in Ubuntu that
 would benefit from a solid, recommended ip determination utility?
 Where should it live?  net-tools?  iproute?  Somewhere else?

I'm not sure where it should live, but I think it should have a different name 
as it's not a generic IP address utility, but one for a single specific 
purpose.  Maybe sysip?

Scott K

-- 
ubuntu-devel mailing list
ubuntu-devel@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel


Re: Just gimme the IP!

2011-06-13 Thread Evan Broder
On Mon, Jun 13, 2011 at 6:58 PM, Dustin Kirkland kirkl...@ubuntu.com wrote:
 In the interest of consistency, I'm wondering if it would make sense
 to create and maintain a stable, definitive utility somewhere in
 Ubuntu's default seed to provide the system's ip address,
 *succinctly*, quickly, and reliably.

 I'd think it should:
  a) default to ipv4, but support a -6|--ipv6 option
  b) default to the interface providing the default route, but support
 an optional interface parameter
  c) be very, very fast (ie, I looked at facter, but it's pretty slow)

I think the ifdata program in moreutils is a good start on this:

mingo:~ evan$ time ifdata -pa eth0
172.16.4.140

real0m0.008s
user0m0.000s
sys 0m0.000s

It seems to have only the most basic of IPv6 support, and lacks the
ability to enumerate interfaces or default to the interface providing
the default route, but it's explicitly designed to cover the use case
of getting information about interfaces in shell scripts - it seems
like trying to enhance it to fill in the gaps would be a better plan
than adding more utilities.

- Evan

-- 
ubuntu-devel mailing list
ubuntu-devel@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel