fastfetch-cli / fastfetch

An actively maintained, feature-rich and performance oriented, neofetch like system information tool.
MIT License
10k stars 397 forks source link

[BUG] IPv6 address not visible on dual-stacked hosts #1319

Closed daryll-swer closed 16 hours ago

daryll-swer commented 1 day ago

Be sure to read the FAQ before submitting a new issue.

General description of bug:

From a quick glance over the source codebase of this project, I do see 'IPv6' being in there, so it must be missing only on the front-end aspect of the code for user output.

CarterLi commented 1 day ago

You should follow the bug report template.

What does fastfetch -s localip --localip-show-ipv6 print?

daryll-swer commented 18 hours ago

You should follow the bug report template.

I must have missed that aspect of the template.

What does fastfetch -s localip --localip-show-ipv6 print?

What it shows isn't correct output, as it shows the link-local addressing instead of the GUA addressing. Tested on v2.27.0.

                     ..'          Local IP (en5): 103.176.189.254/24 fe80::815:807f:96a3:b02d/64
                 ,xNMM.
               .OMMMMo
               lMM"
     .;loddo:.  .olloddol;.
   cKMMMMMMMMMMNWMMMMMMMMMM0:
 .KMMMMMMMMMMMMMMMMMMMMMMMWd.
 XMMMMMMMMMMMMMMMMMMMMMMMX.
;MMMMMMMMMMMMMMMMMMMMMMMM:
:MMMMMMMMMMMMMMMMMMMMMMMM:
.MMMMMMMMMMMMMMMMMMMMMMMMX.
 kMMMMMMMMMMMMMMMMMMMMMMMMWd.
 'XMMMMMMMMMMMMMMMMMMMMMMMMMMk
  'XMMMMMMMMMMMMMMMMMMMMMMMMK.
    kMMMMMMMMMMMMMMMMMMMMMMd
     ;KMMMMMMMWXXWMMMMMMMk.
       "cooc*"    "*coo'"

ifconfig shows the correct GUA (both secured and temporary over SLAAC) addresses.

Curling to a v6 endpoint also works correctly, of course, showing the source address selection for 'temporary' SLAAC address (instead of 'secured'):

curl -s ifconfig.co/json -6
{
  "ip": "2400:7060:2:100:39c8:667c:77c1:e4f8",
  "ip_decimal": 47854487084038604359170347910725494008,
  "country": "India",
  "country_iso": "IN",
  "country_eu": false,
  "region_name": "Karnataka",
  "region_code": "KA",
  "zip_code": "560001",
  "city": "Bengaluru",
  "latitude": 12.9634,
  "longitude": 77.5855,
  "time_zone": "Asia/Kolkata",
  "asn": "AS149794",
  "asn_org": "Daryll Swer",
  "user_agent": {
    "product": "curl",
    "version": "8.7.1",
    "raw_value": "curl/8.7.1"
  }
}

Ideally, Fasfetch would match ifconfig and show inet and inet6 in its entirety (GUA + ULA + link-local in IPv6, and the regular IPv4 single-scope address).

CarterLi commented 18 hours ago
curl -s ifconfig.co/json -6
{
  "ip": "2400:7060:2:100:39c8:667c:77c1:e4f8",
  "ip_decimal": 47854487084038604359170347910725494008,
  "country": "India",
  "country_iso": "IN",
  "country_eu": false,
  "region_name": "Karnataka",
  "region_code": "KA",
  "zip_code": "560001",
  "city": "Bengaluru",
  "latitude": 12.9634,
  "longitude": 77.5855,
  "time_zone": "Asia/Kolkata",
  "asn": "AS149794",
  "asn_org": "Daryll Swer",
  "user_agent": {
    "product": "curl",
    "version": "8.7.1",
    "raw_value": "curl/8.7.1"
  }
}

Isn't it your public IP? You should use fastfetch -s publicip --publicip-ipv6 instead.

daryll-swer commented 18 hours ago

IPv6 is supposed to be 'public IP' up-to the host, that's the whole point of removing RFC1918 and NAT equivalent in IPv6, the host (in this case MacBook) has an IPv6 GUA space assigned to its interface over SLAAC and privacy-extensions, so it has a 'secured' v6 GUA address and a 'temporary' v6 address.

There's no 'private' IP in IPv6. ULA isn't an equivalent of RFC1918.

Again, ifconfig shows it correctly, no problem:

ifconfig en5
en5: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    options=6464<VLAN_MTU,TSO4,TSO6,CHANNEL_IO,PARTIAL_CSUM,ZEROINVERT_CSUM>
    ether 00:e0:4c:68:19:07
    inet6 fe80::815:807f:96a3:b02d%en5 prefixlen 64 secured scopeid 0xa
    inet 103.176.189.254 netmask 0xffffff00 broadcast 103.176.189.255
    inet6 2400:7060:2:100:a1:1aa1:af11:13a1 prefixlen 64 autoconf secured
    inet6 2400:7060:2:100:39c8:667c:77c1:e4f8 prefixlen 64 autoconf temporary
    nd6 options=201<PERFORMNUD,DAD>
    media: autoselect (1000baseT <full-duplex>)
    status: active

fastfetch -s publicip --publicip-ipv6 doesn't work, only shows IPv4 address:


                     ..'          Public IP: 103.176.189.254 (Bengaluru, IN)
                 ,xNMM.
               .OMMMMo
               lMM"
     .;loddo:.  .olloddol;.
   cKMMMMMMMMMMNWMMMMMMMMMM0:
 .KMMMMMMMMMMMMMMMMMMMMMMMWd.
 XMMMMMMMMMMMMMMMMMMMMMMMX.
;MMMMMMMMMMMMMMMMMMMMMMMM:
:MMMMMMMMMMMMMMMMMMMMMMMM:
.MMMMMMMMMMMMMMMMMMMMMMMMX.
 kMMMMMMMMMMMMMMMMMMMMMMMMWd.
 'XMMMMMMMMMMMMMMMMMMMMMMMMMMk
  'XMMMMMMMMMMMMMMMMMMMMMMMMK.
    kMMMMMMMMMMMMMMMMMMMMMMd
     ;KMMMMMMMWXXWMMMMMMMk.
       "cooc*"    "*coo'"```
CarterLi commented 18 hours ago

So you want fastfetch -s localip --localip-show-ipv6 --localip-show-all-ips

CarterLi commented 18 hours ago

Isn't fe80:xxx a local IP? Additionally, the loopback address ::1 can also be seen as a local IP

CarterLi commented 18 hours ago

What I meant public ip is ips assigned by ISP. local ip is ips assigned by others (router or locally). A local ip does not necessary mean it is private but usually does.

daryll-swer commented 18 hours ago

So you want fastfetch -s localip --localip-show-ipv6 --localip-show-all-ips

This works, yes.

Can we implement it for 'fastfetch default' to show properly show IPv4 address of local interface + IPv6 address matching address scope GUA/ULA of local interfaces? Typically, for average users, they don't check link-local.

Isn't fe80:xxx a local IP?

Link-local address is a link-scoped address, limited to a single broadcast domain, it's not forward-able nor route-able, largely used for NDP/RA purposes and some limited applications of mDNS on a single broadcast domain. The average user wants to know their local interface GUA/ULA scoped addresses.

Link-local on IPv6 is auto-config on most end-user operating systems and kernels (Windows, Linux, macOS, iOS, Android etc), so it makes little sense to pollute this in 'fastfetch default' output, just v4 local-interface IP and v6 local-interface GUA/ULA scoped addresses are sufficient as these are delegated by your underlay network/router.

What I meant public ip is ips assigned by ISP. local ip is ips assigned by your computer locally.

In IPv6, the ISP routes a prefix to the CE (Customer Edge), the CE then delegates/assign a global address to your local computer/iPhone etc over Wi-Fi/LAN.

I'd suggest reading my IPv6 architecture guide to get an idea, IPv6 is 'public' (Global) IP end-to-end of any properly architected ISP network.

Additionally, the loopback address ::1 can also be seen as a local IP

The Loopback IPv6 address is an IP local to the host, not a local-interface IP for egress back into the network underlay.

Fasfetch is already correctly detecting egress interface, I'm assuming by checking the default route preferences of the routing table, but it will get messy if the host has multiple egress interfaces. For example, on a Linux production server connected to two leave switches on layer 3, each with a unique gateway, but perhaps the host is doing ECMP or even just failover, then the fastfetch needs to check for all interfaces that matches multiple default routes. This is for cases where ESI-LAG with EVPN for example isn't in-use with LACP bonding on the host side.

Or in the case of my MacBook, I have two interfaces that are live, wired/USB and Wi-Fi, the default route (set by service order) is en5>en0, but fastfetch only detects en5 IPs instead of both valid egress interfaces, simply due to different route activeness (macOS doesn't support ECMP).

ifconfig en0 && ifconfig en5
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    options=6460<TSO4,TSO6,CHANNEL_IO,PARTIAL_CSUM,ZEROINVERT_CSUM>
    ether 50:a6:d8:d7:68:ef
    inet6 fe80::1cd1:80d3:c1f6:4945%en0 prefixlen 64 secured scopeid 0xc
    inet6 2400:7060:2:100:a1:1aa1:af11:13a1 prefixlen 64 autoconf secured
    inet6 2400:7060:2:100:ec6f:be25:7883:3a0e prefixlen 64 autoconf temporary
    inet 103.176.189.253 netmask 0xffffff00 broadcast 103.176.189.255
    nd6 options=201<PERFORMNUD,DAD>
    media: autoselect
    status: active
en5: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    options=6464<VLAN_MTU,TSO4,TSO6,CHANNEL_IO,PARTIAL_CSUM,ZEROINVERT_CSUM>
    ether 00:e0:4c:68:19:07
    inet6 fe80::815:807f:96a3:b02d%en5 prefixlen 64 secured scopeid 0xa
    inet 103.176.189.254 netmask 0xffffff00 broadcast 103.176.189.255
    inet6 2400:7060:2:100:b1:1ba1:bf11:13b1 prefixlen 64 autoconf secured
    inet6 2400:7060:2:100:39c8:667c:77c1:e4f8 prefixlen 64 autoconf temporary
    nd6 options=201<PERFORMNUD,DAD>
    media: autoselect (1000baseT <full-duplex>)
    status: active

netstat -r -f inet && netstat -r -f inet6
Routing tables

Internet:
Destination        Gateway            Flags               Netif Expire
default            103.176.189.1     UGScg                 en5
default            103.176.189.1     UGScIg                en0

Internet6:
Destination        Gateway            Flags               Netif Expire
default            fe80::d601:c3ff:fe UGcg                  en5
default            fe80::d601:c3ff:fe UGcIg                 en0
CarterLi commented 18 hours ago

You should read fastfetch -h | grep localip first. --localip-default-route-only false does what you need

daryll-swer commented 17 hours ago

You should read fastfetch -h | grep localip first. --localip-default-route-only false does what you need

Doesn't work correctly, it shows even non-route-able address space of IPv4 (169.254.113.29/16) of en12 and still does not show IPv6. But ifconfig has no problems.

Link-local addressing makes little sense to be displayed to most end-users on an end-user friendly app like Fastfetch, as most end-users aren't network engineers troubleshooting link-local addressing anyway (if they were then, they'd use regular ifconfig or iproute2).

                     ..'          daryllswer@Daryll-Swer-MacBook-Air-M3
                 ,xNMM.           -------------------------------------
               .OMMMMo            OS: macOS Sequoia 15.0.1 arm64
               lMM"               Host: MacBook Air (13-inch, M3, 2024)
     .;loddo:.  .olloddol;.       Kernel: Darwin 24.0.0
   cKMMMMMMMMMMNWMMMMMMMMMM0:     Uptime: 1 day, 2 hours, 1 min
 .KMMMMMMMMMMMMMMMMMMMMMMMWd.     Packages: 28 (brew), 6 (brew-cask)
 XMMMMMMMMMMMMMMMMMMMMMMMX.       Shell: zsh 5.9
;MMMMMMMMMMMMMMMMMMMMMMMM:        Display (Color LCD): 2940x1912 @ 60 Hz (as 1470x956) in 14" [Built-in]
:MMMMMMMMMMMMMMMMMMMMMMMM:        DE: Aqua
.MMMMMMMMMMMMMMMMMMMMMMMMX.       WM: Quartz Compositor
 kMMMMMMMMMMMMMMMMMMMMMMMMWd.     WM Theme: Multicolor (Dark)
 'XMMMMMMMMMMMMMMMMMMMMMMMMMMk    Font: .AppleSystemUIFont [System], Helvetica [User]
  'XMMMMMMMMMMMMMMMMMMMMMMMMK.    Cursor: Fill - Black, Outline - White (32px)
    kMMMMMMMMMMMMMMMMMMMMMMd      Terminal: Warp v0.2024.09.24.08.02.stable_01
     ;KMMMMMMMWXXWMMMMMMMk.       Terminal Font: Hack (13.0pt)
       "cooc*"    "*coo'"         CPU: Apple M3 (8) @ 4.06 GHz
                                  GPU: Apple M3 (10) @ 1.34 GHz [Integrated]
                                  Memory: 10.28 GiB / 16.00 GiB (64%)
                                  Swap: Disabled
                                  Disk (/): 327.83 GiB / 460.43 GiB (71%) - apfs [Read-only]
                                  Local IP (en0): 103.176.189.253/24
                                  Local IP (en12): 169.254.113.29/16
                                  Local IP (en5): 103.176.189.254/24 *
                                  Battery (bq40z651): 90% [AC connected]
                                  Power Adapter: 70W USB-C Power Adapter
                                  Locale: C

Basically I'm suggesting for fastfetch default to at least show IPs for default egress interface to an effect of this:

Local IPv4 (en5): 103.176.189.254/24 Local IPv6 (en5) Secured: 2400:7060:2:100:b1:1ba1:bf11:13b1/64 Local IPv6 (en5) Temporary: 2400:7060:2:100:39c8:667c:77c1:e4f8/64

CarterLi commented 17 hours ago

CAN YOU PLEASE COMBINE THESE FLAGS???

daryll-swer commented 17 hours ago

This is my key point, instead of combining multiple flags for a simple effect, if I run fastfetch it should display like this, in base output, without any flag:

Local IPv4 (en5): 103.176.189.254/24 Local IPv6 (en5) Secured: 2400:7060:2:100:b1:1ba1:bf11:13b1/64 Local IPv6 (en5) Temporary: 2400:7060:2:100:39c8:667c:77c1:e4f8/64

Besides, why does the flags have differentiation between v4/v6 instead of dual-stacked single output like ifconfig?

CarterLi commented 17 hours ago

Local ip was designed for sharing ips in a LAN.

For example, In a company or a house, everyone connects to one same router. You set up a Web server, and you want to share your IP to your workmates so that they can connect your service.

Another case is that you installed some VMs that all use NAT. You want to transfer files between VMs and host.

daryll-swer commented 17 hours ago

Why does 'Local IP' show only IPv4 by default? Why is IPv6 GUA/ULA scoped addresses, on the LAN not shown?

CarterLi commented 17 hours ago

As I said, Local IP was designed for LAN sharing. If everyone connects to the same LAN, the default route of IPv4 is usually enough.

Maybe I should have named this module as LAN IP

daryll-swer commented 17 hours ago

That's IPv4-centric thinking. The LAN can be an IPv6-only LAN, so 'local IP' should show both by default. Many global enterprises are deploying IPv6-only LANs, inter-host comms works only via IPv6, v4 is only for internet/legacy translation over MAP-T/464xlat etc.

CarterLi commented 17 hours ago

If you dont like the default, you can always customize your requirement in the config file. Lets stop arguing this meaningless topic.

CarterLi commented 17 hours ago

No. There are always privacy concern about this module. People think a ipv4 192.168.x.x can leak their privacy. As you said there is no private ipv6. People will complain about it more if ipv6 is shown bu default.

https://github.com/fastfetch-cli/fastfetch?tab=readme-ov-file#q-fastfetch-shows-my-local-ip-address-it-leaks-my-privacy

Another reason is that there are usually multiple ipv6 ips bound to the same interface. Display them all may be too verbose. As fastfetch dont know which ip is what users want, it shows the first ip by default. It may not be useful.