![]() ![]() I also needed to get the name of my network interfaces and I'll be using the arp one on my instances that don't know their single network device as well as their whole existance is entirely abstracted. 3) Finds the line with the correct MAC address and gets the IP address from that line. Nobody is paying me so, that is all I have time for today. I only tested my commands on my Kubuntu laptop. Also, find, arp, awk, sed, and sort are generally on every linux device already. ![]() spaces, newlines, other weird characters.). Good chance network interfaces are not named in ways that break stuff the usual way (i.e. With a "clean list" of names, you can plug them into most other commands and test for the MAC address of all zeroes or a virtual attribute. It for sure includes my wifi network interface. I am not sure if that gets rid of the "virtual devices". With the arp command, you can specify "ethernet" devices. (explanation: gimme the arp table info | don't print if line 1, which are arp table headers | only print the fifth column | delete empty lines | aphabetize and remove duplicates) find /sys/class/net -type l -execdir basename '' | sed '/^$/d'| sort -u The whole code can be found at the bottom. I have spent most of yesterday writing the code, so I decided to describe it here. The information on the internet is not very good, and the process is quite complicated. I came up with two ways I thought were "okay". Getting IP, IPv6 and MAC addresses on Linux is no easy task if you do not use ifconfig. We need a "clean list of interfaces" that doesn't have the loopback. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |