Git Product home page Git Product logo

danielpgross / friendly_neighbor Goto Github PK

View Code? Open in Web Editor NEW
13.0 2.0 0.0 202 KB

Server that responds to ARP (IPv4) and NDP (IPv6) requests on behalf of neighboring machines. Useful for keeping sleeping machines accessible on the network.

Home Page: https://danielpgross.github.io/friendly_neighbor/howto-sleep-wake-on-demand

License: MIT License

Zig 98.49% Shell 1.51%
arp homeserver ndp networking wake-on-lan

friendly_neighbor's Introduction

Friendly Neighbor

friendly-neighbor

Cartoon showing waving computer in doorway of house

Friendly Neighbor is a network server that responds to ARP and NDP requests on behalf of other LAN devices. Think of it as applying a set of static IP-to-MAC address mappings for all devices on your LAN.

Its main use-case is enabling network packets to be sent to sleeping machines so that they can be woken up on demand using wake-on-unicast. This blog post explains the technique in detail.

Features

  • Super lightweight and performant, built with Zig
  • Built with libpcap for efficient, low-overhead packet filtering
  • Supports different CPU architectures, including x86_64 and Raspberry Pi (ARM64)
  • Distributed as a universal Snap package for easy installation on many Linux distros
  • Can respond on behalf of multiple machines at once
  • IPv4 and IPv6 support

Prerequisites

  • Linux (any distro supporting Snap packages, kernel version 2.6.27+)
  • Wired Ethernet network interface

Installation

Get it from the Snap Store

sudo snap install friendly-neighbor
sudo snap connect friendly-neighbor:hardware-observe
sudo snap connect friendly-neighbor:network-control
# Replace the values for "mac-ip-mappings" and "interface-name" below with your real ones:
sudo snap set friendly-neighbor mac-ip-mappings=AA:BB:CC:DD:EE:FF,10.0.8.3 interface-name=eth0
sudo snap restart friendly-neighbor

The Snap package is configured to run automatically Friendly Neighbor as a network service (daemon). After performing the steps above, the service should be running and should automatically start on subsequent system startups.

Usage

The following usage details are only relevant when running the service directly. If using the Snap package, service parameters are set using snap set friendly-neighbor ...

USAGE
    friendly_neighbor [-hv] [-i <IFACE>] [-m <MAPPING>...] [--mappings <MAPPINGS>]

OPTIONS
    -i, --interface <IFACE>
            Name of network interface on which to listen and send packets

    -m, --mapping <MAPPING>...
            One or more MAC to IP (v4 or v6) address mappings, each in the
            format <MAC address>,<IP address>

        --mappings <MAPPINGS>
            A single string containing one or more mappings in the format <MAC
            address>,<IP address> with mappings separated by a space

    -h, --help
            Display this help and exit

    -v, --version
            Print program version and exit

EXAMPLES
    friendly_neighbor -i eth0 \
        -m 11:22:33:44:55:66,192.168.1.2 \
        -m 11:22:33:44:55:66,fd12:3456:789a:1::1

    friendly_neighbor -i eno1 --mappings \
        "AA:BB:CC:DD:EE:FF,10.0.8.3 AA:BB:CC:DD:EE:FF,fd9a:bc83:57e4:2::1"

Contributing

Contributions are welcome, pull requests and issues can be created at https://github.com/danielpgross/friendly_neighbor

License

MIT

Happy networking, and remember to be a friendly neighbor! ๐ŸŒ๐Ÿ’ป

friendly_neighbor's People

Contributors

danielpgross avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

friendly_neighbor's Issues

Add Snap build for `armhf`/`armv7` architecture

Attempting to build the snap on Snapcraft Cloud for armhf produces the following error:

zig build --global-cache-dir /build/friendly-neighbor/parts/friendly-neighbor/build/zig-cache/
thread 9738 panic: integer overflow
/snap/zig/8738/lib/std/process.zig:1222:22: 0xb6a43 in totalSystemMemoryLinux (build)
    return kilobytes * 1024;
                     ^
/snap/zig/8738/lib/std/process.zig:1164:42: 0xa578b in totalSystemMemory (build)
            return totalSystemMemoryLinux() catch return error.UnknownTotalSystemMemory;
                                         ^
/snap/zig/8738/lib/build_runner.zig:316:48: 0xa1dcb in main (build)
        run.max_rss = process.totalSystemMemory() catch std.math.maxInt(usize);
                                               ^
/snap/zig/8738/lib/std/start.zig:370:37: 0x904e3 in posixCallMainAndExit (build)
            var i: usize = 0;
                                    ^
???:?:?: 0x0 in ??? (???)
error: the following build command crashed:
/build/friendly-neighbor/parts/friendly-neighbor/build/zig-cache/o/4fb5c8308bb66929791e1c0a7a99fb3b/build /snap/zig/8738/zig /build/friendly-neighbor/parts/friendly-neighbor/build /build/friendly-neighbor/parts/friendly-neighbor/build/zig-cache /build/friendly-neighbor/parts/friendly-neighbor/build/zig-cache/
'override-build' in part 'friendly-neighbor' failed with code 1.

Seems to be caused by ziglang/zig#17596.

We should ideally support armhf, since many low-power devices use it, including Raspberry Pi version 2 and earlier.

Universal action instead of magic packet

I would like to "wake" the sleeping machine with powering on through a smart power plug (ESPHome, Tasmota, etc.).

Of course I could sniff that magic packet and do the powering on sequence myself, but it would be nice to have it as a feature.

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.