Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.user > #256258 > unrolled thread
| Started by | fh@dnsbed.com |
|---|---|
| First post | 2023-03-22 02:20 +0100 |
| Last post | 2023-03-30 10:10 +0200 |
| Articles | 14 — 8 participants |
Back to article view | Back to linux.debian.user
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
| From | fh@dnsbed.com |
|---|---|
| Date | 2023-03-22 02:20 +0100 |
| Subject | what's the right way to resolve localhost's IPs |
| Message-ID | <GbViV-ebLW-5@gated-at.bofh.it> |
Hello, 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. Thanks Corey
[toc] | [next] | [standalone]
| From | Jeremy Ardley <jeremy@ardley.org> |
|---|---|
| Date | 2023-03-22 03:10 +0100 |
| Message-ID | <GbW5j-ech4-1@gated-at.bofh.it> |
| In reply to | #256258 |
On 22/3/23 09:12, fh@dnsbed.com wrote:
> Hello,
>
> 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.
On Debian the preferred command is
root@debian12:~# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel
state UP group default qlen 1000
link/ether 08:00:27:18:b6:ac brd ff:ff:ff:ff:ff:ff
inet 10.31.40.166/24 brd 10.31.40.255 scope global dynamic enp0s3
valid_lft 81816sec preferred_lft 81816sec
inet6 2403:5800:c101:b700:a00:27ff:fe18:b6ac/64 scope global
dynamic mngtmpaddr
valid_lft 6667sec preferred_lft 3066sec
inet6 fe80::a00:27ff:fe18:b6ac/64 scope link
valid_lft forever preferred_lft forever
You can also output in .json format
root@debian12:~# ip -j a
[{"ifindex":1,"ifname":"lo","flags":["LOOPBACK","UP","LOWER_UP"],"mtu":65536,"qdisc":"noqueue","operstate":"UNKNOWN","group":"default","txqlen":1000,"link_type":"loopback","address":"00:00:00:00:00:00","broadcast":"00:00:00:00:00:00","addr_info":[{"family":"inet","local":"127.0.0.1","prefixlen":8,"scope":"host","label":"lo","valid_life_time":4294967295,"preferred_life_time":4294967295},{"family":"inet6","local":"::1","prefixlen":128,"scope":"host","valid_life_time":4294967295,"preferred_life_time":4294967295}]},{"ifindex":2,"ifname":"enp0s3","flags":["BROADCAST","MULTICAST","UP","LOWER_UP"],"mtu":1500,"qdisc":"fq_codel","operstate":"UP","group":"default","txqlen":1000,"link_type":"ether","address":"08:00:27:18:b6:ac","broadcast":"ff:ff:ff:ff:ff:ff","addr_info":[{"family":"inet","local":"10.31.40.166","prefixlen":24,"broadcast":"10.31.40.255","scope":"global","dynamic":true,"label":"enp0s3","valid_life_time":81787,"preferred_life_time":81787},{"family":"inet6","local":"2403:5800:c101:b700:a00:27ff:fe18:b6ac","prefixlen":64,"scope":"global","dynamic":true,"mngtmpaddr":true,"valid_life_time":6638,"preferred_life_time":3037},{"family":"inet6","local":"fe80::a00:27ff:fe18:b6ac","prefixlen":64,"scope":"link","valid_life_time":4294967295,"preferred_life_time":4294967295}]}]
and if you write a script like this (and make it write protected and
executable)
cat ipv4_addresses.py
#!/usr/bin/env python3
import json
import sys
data = sys.stdin.read()
interfaces = json.loads(data)
for interface in interfaces:
ifname = interface['ifname']
for addr_info in interface['addr_info']:
if addr_info['family'] == 'inet':
ipv4 = addr_info['local']
print(f"{ifname}: {ipv4}")
you can do
ip -j a | ./ipv4_addresses.py
lo: 127.0.0.1
enp7s0: 10.31.40.68
or on a fancier setup
ip -j a | ./ipv4_addresses.py
lo: 127.0.0.1
eth0: 10.31.40.4
eth0: 10.31.40.5
eth0: 10.31.40.101
docker0: 172.17.0.1
> --
Jeremy
(Lists)
[toc] | [prev] | [next] | [standalone]
| From | fh@dnsbed.com |
|---|---|
| Date | 2023-03-22 03:40 +0100 |
| Message-ID | <GbWyl-ecqj-3@gated-at.bofh.it> |
| In reply to | #256259 |
On 2023-03-22 10:06, Jeremy Ardley wrote:
> On 22/3/23 09:12, fh@dnsbed.com wrote:
>> Hello,
>>
>> 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.
>
> On Debian the preferred command is
>
> root@debian12:~# ip a
> 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
> group default qlen 1000
> link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
> inet 127.0.0.1/8 scope host lo
> valid_lft forever preferred_lft forever
> inet6 ::1/128 scope host
> valid_lft forever preferred_lft forever
> 2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel
> state UP group default qlen 1000
> link/ether 08:00:27:18:b6:ac brd ff:ff:ff:ff:ff:ff
> inet 10.31.40.166/24 brd 10.31.40.255 scope global dynamic enp0s3
> valid_lft 81816sec preferred_lft 81816sec
> inet6 2403:5800:c101:b700:a00:27ff:fe18:b6ac/64 scope global
> dynamic mngtmpaddr
> valid_lft 6667sec preferred_lft 3066sec
> inet6 fe80::a00:27ff:fe18:b6ac/64 scope link
> valid_lft forever preferred_lft forever
>
> You can also output in .json format
>
> root@debian12:~# ip -j a
>
[{"ifindex":1,"ifname":"lo","flags":["LOOPBACK","UP","LOWER_UP"],"mtu":65536,"qdisc":"noqueue","operstate":"UNKNOWN","group":"default","txqlen":1000,"link_type":"loopback","address":"00:00:00:00:00:00","broadcast":"00:00:00:00:00:00","addr_info":[{"family":"inet","local":"127.0.0.1","prefixlen":8,"scope":"host","label":"lo","valid_life_time":4294967295,"preferred_life_time":4294967295},{"family":"inet6","local":"::1","prefixlen":128,"scope":"host","valid_life_time":4294967295,"preferred_life_time":4294967295}]},{"ifindex":2,"ifname":"enp0s3","flags":["BROADCAST","MULTICAST","UP","LOWER_UP"],"mtu":1500,"qdisc":"fq_codel","operstate":"UP","group":"default","txqlen":1000,"link_type":"ether","address":"08:00:27:18:b6:ac","broadcast":"ff:ff:ff:ff:ff:ff","addr_info":[{"family":"inet","local":"10.31.40.166","prefixlen":24,"broadcast":"10.31.40.255","scope":"global","dynamic":true,"label":"enp0s3","valid_life_time":81787,"preferred_life_time":81787},{"family":"inet6","local":"2403:5800:c101:
b700:a00:27ff:fe18:b6ac","prefixlen":64,"scope":"global","dynamic":true,"mngtmpaddr":true,"valid_life_time":6638,"preferred_life_time":3037},{"family":"inet6","local":"fe80::a00:27ff:fe18:b6ac","prefixlen":64,"scope":"link","valid_life_time":4294967295,"preferred_life_time":4294967295}]}]
>
> and if you write a script like this (and make it write protected and
> executable)
>
> cat ipv4_addresses.py
> #!/usr/bin/env python3
> import json
> import sys
>
> data = sys.stdin.read()
>
> interfaces = json.loads(data)
>
> for interface in interfaces:
> ifname = interface['ifname']
> for addr_info in interface['addr_info']:
> if addr_info['family'] == 'inet':
> ipv4 = addr_info['local']
> print(f"{ifname}: {ipv4}")
>
> you can do
>
> ip -j a | ./ipv4_addresses.py
> lo: 127.0.0.1
> enp7s0: 10.31.40.68
>
> or on a fancier setup
>
Thanks a lot. Now I prefer this way:
$ ip -j a|python3 -mjson.tool
regards.
[toc] | [prev] | [next] | [standalone]
| From | Gregory Seidman <gsslist+debian@anthropohedron.net> |
|---|---|
| Date | 2023-03-22 21:40 +0100 |
| Message-ID | <Gcdpv-emR7-3@gated-at.bofh.it> |
| In reply to | #256259 |
On Wed, Mar 22, 2023 at 10:06:40AM +0800, Jeremy Ardley wrote:
>
> On 22/3/23 09:12, fh@dnsbed.com wrote:
> > Hello,
> >
> > 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.
>
> On Debian the preferred command is
>
> root@debian12:~# ip a
[...]
> You can also output in .json format
>
> root@debian12:~# ip -j a
[...]
>
> and if you write a script like this (and make it write protected and
> executable)
[...]
For those of us who like using jq for this kind of thing:
#!/bin/sh
ip -j a | jq -r '
.[] | {
"name": .ifname,
"addr": .addr_info |
map(select(.family == "inet")) |
.[0].local
} |
select(.addr) |
.name + ": " + .addr'
> you can do
>
> ip -j a | ./ipv4_addresses.py
> lo: 127.0.0.1
> enp7s0: 10.31.40.68
>
> or on a fancier setup
>
> ip -j a | ./ipv4_addresses.py
> lo: 127.0.0.1
> eth0: 10.31.40.4
> eth0: 10.31.40.5
> eth0: 10.31.40.101
> docker0: 172.17.0.1
>
> > --
>
> Jeremy
> (Lists)
--Gregory
[toc] | [prev] | [next] | [standalone]
| From | Tom Furie <tom@furie.org.uk> |
|---|---|
| Date | 2023-03-22 22:20 +0100 |
| Message-ID | <Gce2d-enkx-7@gated-at.bofh.it> |
| In reply to | #256259 |
[Multipart message — attachments visible in raw view] — view raw
On Wed, Mar 22, 2023 at 10:06:40AM +0800, Jeremy Ardley wrote:
> You can also output in .json format
>
> root@debian12:~# ip -j a
> [{"ifindex":1,"ifname":"lo","flags":["LOOPBACK","UP","LOWER_UP"],"mtu":65536,"qdisc":"noqueue","operstate":"UNKNOWN","group":"default","txqlen":1000,"link_type":"loopback","address":"00:00:00:00:00:00","broadcast":"00:00:00:00:00:00","addr_info":[{"family":"inet","local":"127.0.0.1","prefixlen":8,"scope":"host","label":"lo","valid_life_time":4294967295,"preferred_life_time":4294967295},{"family":"inet6","local":"::1","prefixlen":128,"scope":"host","valid_life_time":4294967295,"preferred_life_time":4294967295}]},{"ifindex":2,"ifname":"enp0s3","flags":["BROADCAST","MULTICAST","UP","LOWER_UP"],"mtu":1500,"qdisc":"fq_codel","operstate":"UP","group":"default","txqlen":1000,"link_type":"ether","address":"08:00:27:18:b6:ac","broadcast":"ff:ff:ff:ff:ff:ff","addr_info":[{"family":"inet","local":"10.31.40.166","prefixlen":24,"broadcast":"10.31.40.255","scope":"global","dynamic":true,"label":"enp0s3","valid_life_time":81787,"preferred_life_time":81787},{"family":"inet6","local":"2403:5800:c101:b700:a00:27ff:fe18:b6ac","prefixlen":64,"scope":"global","dynamic":true,"mngtmpaddr":true,"valid_life_time":6638,"preferred_life_time":3037},{"family":"inet6","local":"fe80::a00:27ff:fe18:b6ac","prefixlen":64,"scope":"link","valid_life_time":4294967295,"preferred_life_time":4294967295}]}]
>
> and if you write a script like this (and make it write protected and
> executable)
Or...
ip -o a | awk '{print $2, $4}'
Cheers,
Tom
--
My mother is a fish.
-- William Faulkner
[toc] | [prev] | [next] | [standalone]
| From | Greg Wooledge <greg@wooledge.org> |
|---|---|
| Date | 2023-03-22 22:50 +0100 |
| Message-ID | <Gcevg-env1-5@gated-at.bofh.it> |
| In reply to | #256278 |
On Wed, Mar 22, 2023 at 09:16:48PM +0000, Tom Furie wrote:
> Or...
>
> ip -o a | awk '{print $2, $4}'
I think they wanted to restrict it to IPv4 (inet) addresses, and omit
the netmask (/8 or whatever CIDR suffix), so:
ip -o a | awk -F '[ /]*' '$3 == "inet" {print $2, $4}'
But... again... why the hell would someone WANT THIS OUTPUT? What is
it going to be use-- wait. I remember now. One of the posters in
this thread, I think not the OP, had the word "docker" in their
results. So, there's no point asking any further. Docker questions
that involve shell programming are never to be entertained. It leads
only to increased misery, and never increased understanding.
[toc] | [prev] | [next] | [standalone]
| From | Jeremy Ardley <jeremy@ardley.org> |
|---|---|
| Date | 2023-03-23 00:10 +0100 |
| Message-ID | <GcfKG-eoue-45@gated-at.bofh.it> |
| In reply to | #256279 |
On 23/3/23 05:47, Greg Wooledge wrote:
> On Wed, Mar 22, 2023 at 09:16:48PM +0000, Tom Furie wrote:
>> Or...
>>
>> ip -o a | awk '{print $2, $4}'
> I think they wanted to restrict it to IPv4 (inet) addresses, and omit
> the netmask (/8 or whatever CIDR suffix), so:
>
> ip -o a | awk -F '[ /]*' '$3 == "inet" {print $2, $4}'
>
> But... again... why the hell would someone WANT THIS OUTPUT? What is
> it going to be use-- wait. I remember now. One of the posters in
> this thread, I think not the OP, had the word "docker" in their
> results. So, there's no point asking any further. Docker questions
> that involve shell programming are never to be entertained. It leads
> only to increased misery, and never increased understanding.
>
I am the guilty party who had docker. I have not raised any issue about it. The instance is not used any more and was an experiment in running nextcloud on an arm server
docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
56a238ff2cbf arm64v8/nextcloud "/entrypoint.sh apac…" 2 years ago Exited (0) 2 years ago nextcloud
In rare circumstances I will use a docker version of a package if the Debian verion is not up to date, or I don't want the pain of compiling it, or if there is no easy way to compile a specific version to use with my version of Debian.
If I have to use a packaged application I will try and use an appimage
--
Jeremy
(Lists)
[toc] | [prev] | [next] | [standalone]
| From | Greg Wooledge <greg@wooledge.org> |
|---|---|
| Date | 2023-03-23 00:40 +0100 |
| Message-ID | <GcgdH-eoEk-1@gated-at.bofh.it> |
| In reply to | #256282 |
On Thu, Mar 23, 2023 at 07:06:55AM +0800, Jeremy Ardley wrote: > I am the guilty party who had docker. I have not raised any issue about it. The instance is not used any more and was an experiment in running nextcloud on an arm server Then perhaps you can enlighten me: why does anyone (Docker user or otherwise) need to write a shell script to list the IPv4 addresses of the local system's network interfaces? I can't think of any reasons other than "I want to update dynamic DNS" (for which a dhclient hook is better suited, with the new IP address being supplied in the environment), or "I need to use it to set up firewall rules", a topic with which I'll admit I'm not very experienced, but which doesn't seem particularly important on exposed servers. I would think you'd simply shut down all the services you don't want running, rather than leaving them in place but trying to block them with a firewall.
[toc] | [prev] | [next] | [standalone]
| From | Jeremy Ardley <jeremy@ardley.org> |
|---|---|
| Date | 2023-03-23 01:00 +0100 |
| Message-ID | <Gcgx3-eoLh-1@gated-at.bofh.it> |
| In reply to | #256283 |
On 23/3/23 07:33, Greg Wooledge wrote: > On Thu, Mar 23, 2023 at 07:06:55AM +0800, Jeremy Ardley wrote: >> I am the guilty party who had docker. I have not raised any issue about it. The instance is not used any more and was an experiment in running nextcloud on an arm server > Then perhaps you can enlighten me: why does anyone (Docker user or > otherwise) need to write a shell script to list the IPv4 addresses > of the local system's network interfaces? > > I can't think of any reasons other than "I want to update dynamic DNS" > (for which a dhclient hook is better suited, with the new IP address > being supplied in the environment), or "I need to use it to set up > firewall rules", a topic with which I'll admit I'm not very experienced, > but which doesn't seem particularly important on exposed servers. I > would think you'd simply shut down all the services you don't want > running, rather than leaving them in place but trying to block them > with a firewall. > I am not the op. I mistakenly used an old server to illustrate how to extract ip addresses and it just happened it had been used once to run nextcloud in docker. On your second topic I don't usually run firewalls on my cloud severs. In the AWS case they do it for you and in the linode case I just run the minimum services required. -- Jeremy (Lists)
[toc] | [prev] | [next] | [standalone]
| From | Nicolas George <george@nsup.org> |
|---|---|
| Date | 2023-03-23 08:50 +0100 |
| Message-ID | <GcnRT-etsO-7@gated-at.bofh.it> |
| In reply to | #256285 |
Jeremy Ardley (12023-03-23): > On your second topic I don't usually run firewalls on my cloud severs. But surely on a server the network configuration is static, including the firewall rules, isn't it? (Please imagine this mail set up on the Anakin/Padme meme template.) Regards, -- Nicolas George
[toc] | [prev] | [next] | [standalone]
| From | Jeremy Ardley <jeremy@ardley.org> |
|---|---|
| Date | 2023-03-23 09:00 +0100 |
| Message-ID | <Gco1A-etxe-7@gated-at.bofh.it> |
| In reply to | #256288 |
On 23/3/23 15:42, Nicolas George wrote: > Jeremy Ardley (12023-03-23): >> On your second topic I don't usually run firewalls on my cloud severs. > But surely on a server the network configuration is static, including > the firewall rules, isn't it? > On AWS the firewall rules are set by AWS themselves, though there is a console to adjust them. I normally only open up the incoming ports I am using. For ssh I only allow it from my personal IPv4 and IPv6 ranges On Linode I just run bare with no firewall and only trusted services listening on a few ports. Linode do block outgoing port 25 and 485. In a better world, in case my server were to be compromised, I'd set up to manage my outgoing such as rate limiting outgoing DNS requests and blocking other destination ports entirely. I'm sure there is a list of destination ports this applies to? -- Jeremy (Lists)
[toc] | [prev] | [next] | [standalone]
| From | Lee <ler762@gmail.com> |
|---|---|
| Date | 2023-03-23 12:00 +0100 |
| Message-ID | <GcqPL-evk6-3@gated-at.bofh.it> |
| In reply to | #256288 |
On 3/23/23, Nicolas George <george@nsup.org> wrote: > Jeremy Ardley (12023-03-23): >> On your second topic I don't usually run firewalls on my cloud severs. > > But surely on a server the network configuration is static, including > the firewall rules, isn't it? Consider the IP addressing info coming from DHCP. The network configuration stays the same but the IP(v6)? address might change. For example, Verizon is my ISP; they delegate a /56 to my router and the router delegates /64's to the LANs. I've got DHCP configured to give out static host addresses to the various machines but the network portion of the ipv6 address does change at Verizon's whim .. which requires firewall rule changes because I haven't figured out how to automatically plug in the newly delegated /64 into the firewall rules for that lan :( Regards, Lee
[toc] | [prev] | [next] | [standalone]
| From | Emanuel Berg <incal@dataswamp.org> |
|---|---|
| Date | 2023-03-30 07:50 +0200 |
| Message-ID | <GeTkB-g5IZ-3@gated-at.bofh.it> |
| In reply to | #256258 |
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
[toc] | [prev] | [next] | [standalone]
| From | fh@dnsbed.com |
|---|---|
| Date | 2023-03-30 10:10 +0200 |
| Message-ID | <GeVw5-g7bC-1@gated-at.bofh.it> |
| In reply to | #256534 |
On 2023-03-30 13:38, Emanuel Berg wrote:
> 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
i like the JSON output just b/c I am a programmer knowing JSON pretty
well. :)
[toc] | [prev] | [standalone]
Back to top | Article view | linux.debian.user
csiph-web