---
name: "ares_set_local_dev"
section: "3"
platform: "linux"
package: "c-ares"
version: "1.34.9-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/ares_set_local_dev"
---

# ares\_set\_local\_dev(3)

Bind to a specific network device when creating sockets.

## NAME

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

## SYNOPSIS

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

## 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

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

## NOTES

This function was added in c-ares 1.7.4
