Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.user > #256534
| From | Emanuel Berg <incal@dataswamp.org> |
|---|---|
| Newsgroups | linux.debian.user |
| Subject | Re: what's the right way to resolve localhost's IPs |
| Date | 2023-03-30 07:50 +0200 |
| Message-ID | <GeTkB-g5IZ-3@gated-at.bofh.it> (permalink) |
| References | <GbViV-ebLW-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
fh wrote:
> In my shell script, how to get the localhost's IPs (eth0 and
> eth1) correctly? I know I can run 'ifconfig' and grep etc,
> but it's maybe not that graceful.
Here is what I do, now idea if it's a good idea but maybe it
can help:
#! /bin/zsh
#
# this file:
# https://dataswamp.org/~incal/conf/.zsh/ip
public-ip () {
local name=$funcstack[1]
local url='http://checkip.amazonaws.com'
local open_dns=opendns.com
echo $(curl --no-progress-meter $url) "($name)"
dig +short myip.${open_dns} @resolver1.${open_dns}
}
inet () {
local name=$funcstack[1]
echo $(hostname -I | awk '{print $1}') "($name)"
ifconfig $net | awk '/mask/{print $2}'
ip addr show $net | awk '/inet /{print $2}' | cut -d '/' -f 1
}
list-ip () {
public-ip
inet
}
alias lip=list-ip
# $ lip
# 92.34.142.23
# 92.34.142.23
# 192.168.10.224
# 192.168.10.224
# 192.168.10.224
--
underground experts united
https://dataswamp.org/~incal
Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
what's the right way to resolve localhost's IPs fh@dnsbed.com - 2023-03-22 02:20 +0100
Re: what's the right way to resolve localhost's IPs Jeremy Ardley <jeremy@ardley.org> - 2023-03-22 03:10 +0100
Re: what's the right way to resolve localhost's IPs fh@dnsbed.com - 2023-03-22 03:40 +0100
Re: what's the right way to resolve localhost's IPs Gregory Seidman <gsslist+debian@anthropohedron.net> - 2023-03-22 21:40 +0100
Re: what's the right way to resolve localhost's IPs Tom Furie <tom@furie.org.uk> - 2023-03-22 22:20 +0100
Re: what's the right way to resolve localhost's IPs Greg Wooledge <greg@wooledge.org> - 2023-03-22 22:50 +0100
Re: what's the right way to resolve localhost's IPs Jeremy Ardley <jeremy@ardley.org> - 2023-03-23 00:10 +0100
Re: what's the right way to resolve localhost's IPs Greg Wooledge <greg@wooledge.org> - 2023-03-23 00:40 +0100
Re: what's the right way to resolve localhost's IPs Jeremy Ardley <jeremy@ardley.org> - 2023-03-23 01:00 +0100
Re: what's the right way to resolve localhost's IPs Nicolas George <george@nsup.org> - 2023-03-23 08:50 +0100
Re: what's the right way to resolve localhost's IPs Jeremy Ardley <jeremy@ardley.org> - 2023-03-23 09:00 +0100
Re: what's the right way to resolve localhost's IPs Lee <ler762@gmail.com> - 2023-03-23 12:00 +0100
Re: what's the right way to resolve localhost's IPs Emanuel Berg <incal@dataswamp.org> - 2023-03-30 07:50 +0200
Re: what's the right way to resolve localhost's IPs fh@dnsbed.com - 2023-03-30 10:10 +0200
csiph-web