ARES\_SET\_LOCAL\_DEV(3) Library Functions Manual ARES\_SET\_LOCAL\_DEV(3)

# [NAME](#NAME)

ares\_set\_local\_dev - Bind to a specific network device when creating sockets.

# [SYNOPSIS](#SYNOPSIS)

```
#include <ares.h>
void ares_set_local_dev(ares_channel_t *channel, const char* local_dev_name)
```

# [DESCRIPTION](#DESCRIPTION)

The **ares\_set\_local\_dev** function causes all future sockets to be bound to this device with SO\_BINDTODEVICE. This forces communications to go over a certain interface, which can be useful on multi-homed machines. This option is only supported on Linux, the interface must not be already bound to the socket or the current effective user must have CAP\_NET\_RAW capability in the current network namespace for the option to work. If SO\_BINDTODEVICE is not supported or the setsockopt call fails (probably because of permissions), the error is silently ignored.

# [SEE ALSO](#SEE_ALSO)

[**ares\_set\_local\_ip4**(3)](/man/os/c-ares/ares_set_local_ip4.3) [**ares\_set\_local\_ip6**(3)](/man/os/c-ares/ares_set_local_ip6.3) [**network\_namespaces**(7)](/man/os/c-ares/network_namespaces.7)

# [NOTES](#NOTES)

This function was added in c-ares 1.7.4

23 September 2024

---

Document: ares_set_local_dev(3) from c-ares 1.34.8-r2 (Chainguard OS)
Source: https://github.com/c-ares/c-ares
