Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more details about each IpAddr for interface #28

Open
mortenlj opened this issue Jun 2, 2023 · 0 comments
Open

Add more details about each IpAddr for interface #28

mortenlj opened this issue Jun 2, 2023 · 0 comments

Comments

@mortenlj
Copy link

mortenlj commented Jun 2, 2023

I have an interface with multiple IP-addresses, where I need to pick the "primary" IP assigned to the interface.
As it is, I get both IP-addresses, but there is no way to tell which is which from the data returned.

Unfortunately, I don't know enough about these things to know where to start on a PR.

To show my use case more clearly:

In the below output, I need a way to differentiate between 192.168.68.125 (the one I want), and 192.168.68.91 (the secondary):

$ ip address show dev wlan0
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether b8:27:eb:e2:f1:35 brd ff:ff:ff:ff:ff:ff
    inet 192.168.68.125/24 brd 192.168.68.255 scope global dynamic wlan0
       valid_lft 5035sec preferred_lft 5035sec
    inet 192.168.68.91/24 brd 192.168.68.255 scope global secondary wlan0
       valid_lft forever preferred_lft forever
    inet6 fe80::ba27:ebff:fee2:f135/64 scope link
       valid_lft forever preferred_lft forever

When using if_addrs, this is as far as I get:

Got list of interfaces
[
    Interface {
        name: "wlan0",
        addr: V4(
            Ifv4Addr {
                ip: 192.168.68.125,
                netmask: 255.255.255.0,
                broadcast: Some(
                    192.168.68.255,
                ),
            },
        ),
        index: Some(
            3,
        ),
    },
    Interface {
        name: "wlan0",
        addr: V4(
            Ifv4Addr {
                ip: 192.168.68.91,
                netmask: 255.255.255.0,
                broadcast: Some(
                    192.168.68.255,
                ),
            },
        ),
        index: Some(
            3,
        ),
    },
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant