Network
Addressing
You can easily get the IP Addresses assigned to adapters on the system
- Q: addresses whose (it as string != "0.0.0.0") of ip interfaces whose (loopback of it = false) of network as string
- A: 192.168.1.102
- A: 9.80.109.49
You can also get Mac Addresses of network adapters:
- Q: (mac addresses of it, addresses of it) of ip interfaces of network as string
- A: 3c-15-c2-b7-c7-1a, 192.168.1.102
And you can get the names of the network adapters:
- Q: names of adapters of network
- A: bridge0
- A: en0
- A: en1
- A: en2
- A: fw0
- A: gif0
- A: lo0
- A: p2p0
- A: stf0
- A: vmnet1
- A: vmnet8
Or the names of the active network adapters:
- Q: friendly names of adapters whose (up of it = true) of network
- A: bridge0
- A: en0
- A: en1
- A: en2
- A: lo0
- A: p2p0
- A: vmnet1
- A: vmnet8
Finally, you can get the names and IP addresses of the adapters that are online:
- Q: addresses of ipv4 interfaces whose (exists address of it) of adapters whose (up of it = true) of network
- A: 192.168.44.92
- A: 127.0.0.1
- A: 192.168.235.1
- A: 192.168.181.1
Some adapters don't have associated ipv4 interfaces so you must check to make sure that they exist using a whose-it statement.
Finally, you can get the names and addresses of all adapters:
- Q: (name of adapter of it, addresses of it) of ipv4 interfaces of adapters whose (up of it = true) of network
- A: en1, 192.168.44.92
- A: lo0, 127.0.0.1
- A: vmnet1, 192.168.235.1
- A: vmnet8, 192.168.181.1
You can also get the cidr strings of your connected networks:
- Q: (name of adapter of it, cidr string of it) of ipv4 interfaces of adapters whose (up of it = true) of network
- A: en1, 192.168.44.0/24
- A: lo0, 127.0.0.0/8
- A: vmnet1, 192.168.235.0/24
This is particularly useful for checking if an endpoint is on a certain network (Note one of the interfaces is on the 192.168.44.0/24 subnet):
- Q: exists (ipv4 interfaces of adapters whose (up of it = true) of network) whose (cidr string of it = "192.168.44.0/24")
- A: True