Reputation: 31
I am interested in finding the subnet mask of the local host programatically in Linux preferably through the native C api.
Upvotes: 3
Views: 8835
Reputation: 30200
The ifconfig
utility uses ioctl()
with the SIOCGIFNETMASK
command to get the netmask. But I think Duck's answer is more user-friendly.
Upvotes: 2
Reputation: 27542
getifaddrs() will give you a list of your network interfaces and the field ifa_netmask
should be the mask for each.
Upvotes: 8