Search code examples
clinuxarp

How to add arp addresses into /proc/net/arp in C


I would like to add arp bindings into /proc/net/arp in C. Writing into file is not allowed, so trying to do it some other way. Any suggestions? I already know about net-tools, but havent tryed yet


Solution

  • ip neigh add can do this:

    For example:

    root@refactor:~# ip neigh show
    192.168.1.1 dev wlan0 lladdr 00:1b:da:29:3a:87 REACHABLE
    root@refactor:~# ip neigh add 192.168.1.2 dev wlan0 lladdr 00:1b:da:29:3a:89
    root@refactor:~# ip neigh show
    192.168.1.2 dev wlan0 lladdr 00:1b:da:29:3a:89 PERMANENT
    192.168.1.1 dev wlan0 lladdr 00:1b:da:29:3a:87 REACHABLE
    

    Is this what you want to do?

    If you want to do this directly in C, look at the source of the ip tool, which is part of the iproute2 package.