GithubHelp home page GithubHelp logo

kioubit / pndpd Goto Github PK

View Code? Open in Web Editor NEW
37.0 1.0 0.0 84 KB

NDP Proxy / Responder daemon (IPv6)

License: GNU General Public License v3.0

Go 94.19% Makefile 1.66% Shell 4.15%
ipv6 icmpv6 ndp ndp-proxy bpf go golang linux berkeley-packet-filter

pndpd's Introduction

PNDPD - NDP Proxy / Responder (IPv6)

Features

  • Efficiently process incoming packets using bpf (which runs in the kernel)
  • Proxy NDP between interfaces with an optional whitelist
  • Optionally determine whitelist automatically based on the IPs assigned to the interfaces
  • Respond to NDP solicitations for all or only whitelisted addresses on an interface
  • Permissions required: root or CAP_NET_RAW
  • Easily expandable with modules

Installing & Updating

  1. Download the latest release from the releases page and move the binary to the /usr/local/bin/ directory under the filename pndpd.
  2. Allow executing the file by running chmod +x /usr/local/bin/pndpd
  3. Install the systemd service unit file:
wget https://raw.githubusercontent.com/Kioubit/pndpd/master/pndpd.service -P /etc/systemd/system/
systemctl enable pndpd.service
  1. Download and install the config file
mkdir -p /etc/pndpd
wget https://raw.githubusercontent.com/Kioubit/pndpd/master/pndpd.conf -P /etc/pndpd/
  1. Edit the config at /etc/pndpd/pndpd.conf and then start the service using service pndpd start

Manual Usage

pndpd proxy <external interface> <internal interface> <[optional] 'auto' to determine filters from the internal interface or whitelist of CIDRs separated by a semicolon>
pndpd responder <external interface> <[optional] 'auto' to determine filters from the external interface or whitelist of CIDRs separated by a semicolon>
pndpd config <path to file>

Example: pndpd proxy eth0 tun0 auto

Find more options and additional documentation in the example config file (pndpd.conf).

Example Scenario

Proxying NDP requests for a /64 IPv6 subnet on a VPS to a VPN tunnel

1) Inspecting the initial IP configuration

root@vultr:~# ip -6 addr show dev enp1s0
2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    inet6 2001:11ff:7400:82f2:5400:4ff:fe53:26cf/64 scope global dynamic mngtmpaddr 
       valid_lft 2591753sec preferred_lft 604553sec
    inet6 fe80::5400:4ff:fe53:26cf/64 scope link 
       valid_lft forever preferred_lft forever

As we can see from the output, a /64 subnet of public IPv6 addresses has been assigned to our VPS on our WAN interface enp1s0: 2001:11ff:7400:82f2:5400:4ff:fe53:26cf/64.

2) Routing the subnet to the VPN interface

To route this subnet to our VPN interface tun0 we need to assign one ip address to the VPS and the rest to the VPN interface.
To do that we edit the /etc/network/interface file (for systems that use ifupdown2):

Initial contents:
allow-hotplug enp1s0

iface enp1s0 inet static 
    #.... IPv4 config here ...

iface enp1s0 inet6 static
    address 2001:11ff:7400:82f2:5400:4ff:fe53:26cf/64
    gateway fe80::fc00:4ff:fe53:26cf
After editing:
allow-hotplug enp1s0

iface enp1s0 inet static 
    #.... IPv4 config here ...

iface enp1s0 inet6 static
    address 2001:11ff:7400:82f2::1/128
    gateway fe80::fc00:4ff:fe53:26cf

On the VPN interface we can now assign the rest of the addresses:

ip addr add 2001:11ff:7400:82f2::1/64 dev tun0

3) Running PNDPD

To proxy NDP requests from the outside interface to the VPN interface we run pndp like this:

sudo pndpd proxy enp1s0 tun0 auto

Note: sudo is not required if you are using the capability as described in the systemd unit file. Optionally confirm that the setup works via ping and tcpdump.

Building PNDPD

For building, the version of go needs to be installed that is specified in the go.mod file. A makefile is available. Optionally adjust the MODULES variable to include or exclude modules from the "modules" directory.

make clean; make release

Find the binaries in the bin/ directory

pndpd's People

Contributors

jlu5 avatar kioubit avatar

Stargazers

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

Watchers

 avatar

pndpd's Issues

[feature request] add option in responder mode to send NS DAD

I'd like to ask for a feature to add an option in responder mode to send NS DAD message with every NA.

My router is connected to my upstream router (from ISP). The NS coming in on eth1 (eth1 is the WAN interface on my router) are correctly answered on my router with pndpd. But it also has to send a NS DAD so that the upstream router learns the IPv6 neighbors.
I can simulate it with "ip -6 addr add xxxx:xxxx:xxxx:xxxx:ff:fe21:d123 valid_lft 1 preferred_lft 0 dev eth1".

Would it be possible to add an option "ns-dad" like
responder { iface eth1 ns-dad } ?
pndpd would then also send an NS packet with every NA. The NS DAD message sources an unspecified IPv6 address ::/128 and a destined solicited-node multicast address of the IPv6 address it intends to use, e.g. from the command above xxxx:xxxx:xxxx:xxxx:ff:fe21:d123.

Thanks a lot in advance!

1.2.13 break responder?

After upgrade to 1.2.13 from 1.2.8, pndpd is work incorrectly.

pndpd.conf

responder {
    iface ens18
    filter 3333::/112
}

debug log

time=2024-07-10T19:23:48.415Z level=DEBUG source=pndpd/pndp/listener.go:113 msg="Got packet" packet=3333FF000001229B0D5DA2E586DD6000000000203AFFFE80000000000000209B0DFFFE5DA2E5FF0200000000000000000001FF0000018700153000000000260552C00001062644440000000000010101229B0D5DA2E5 interface=ens18 type=1 "source MAC"=22:9B:D:5D:A2:E5 "source IP"=fe80::209b:dff:fe5d:a2e5 "destination IP"=ff02::1:ff00:1 "requested IP"=3333::1
time=2024-07-10T19:23:48.416Z level=DEBUG source=pndpd/pndp/responder.go:90 msg="Responding for whitelisted IP" ip=3333::1
time=2024-07-10T19:23:48.416Z level=DEBUG source=pndpd/pndp/responder.go:109 msg="Sending packet" type=0 dest=ff02::1:ff00:1 interface=ens18
time=2024-07-10T19:23:49.431Z level=DEBUG source=pndpd/pndp/listener.go:113 msg="Got packet" packet=3333FF000001229B0D5DA2E586DD6000000000203AFFFE80000000000000209B0DFFFE5DA2E5FF0200000000000000000001FF0000018700153000000000260552C00001062644440000000000010101229B0D5DA2E5 interface=ens18 type=1 "source MAC"=22:9B:D:5D:A2:E5 "source IP"=fe80::209b:dff:fe5d:a2e5 "destination IP"=ff02::1:ff00:1 "requested IP"=3333::1
time=2024-07-10T19:23:49.431Z level=DEBUG source=pndpd/pndp/responder.go:90 msg="Responding for whitelisted IP" ip=3333::1
time=2024-07-10T19:23:49.431Z level=DEBUG source=pndpd/pndp/responder.go:109 msg="Sending packet" type=0 dest=ff02::1:ff00:1 interface=ens18
time=2024-07-10T19:23:50.451Z level=DEBUG source=pndpd/pndp/listener.go:113 msg="Got packet" packet=3333FF000001229B0D5DA2E586DD6000000000203AFFFE80000000000000209B0DFFFE5DA2E5FF0200000000000000000001FF0000018700153000000000260552C00001062644440000000000010101229B0D5DA2E5 interface=ens18 type=1 "source MAC"=22:9B:D:5D:A2:E5 "source IP"=fe80::209b:dff:fe5d:a2e5 "destination IP"=ff02::1:ff00:1 "requested IP"=3333::1
time=2024-07-10T19:23:50.451Z level=DEBUG source=pndpd/pndp/responder.go:90 msg="Responding for whitelisted IP" ip=3333::1
time=2024-07-10T19:23:50.451Z level=DEBUG source=pndpd/pndp/responder.go:109 msg="Sending packet" type=0 dest=ff02::1:ff00:1 interface=ens18

NS DAD packet: checksum validation failed

Hi,

the NS DAD of one of my LAN devices is dropped because the checksum validation fails.

Wed Apr 26 18:13:36 2023 daemon.info pndpd[1204]: Got packet on eth0 of type 1
Wed Apr 26 18:13:36 2023 daemon.info pndpd[1204]: 33 33 FF 7B 99 DA C0 74 AD 7B 99 DA 86 DD 60 00 00 00 00 18 3A FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF 02 00 00 00 00 00 00 00 00 00 01 FF 7B 99 DA 87 00 CF C2 00 00 00 00 XX XX XX XX XX XX 18 2B C2 74 AD FF FE 7B 99 DA
Wed Apr 26 18:13:36 2023 daemon.info pndpd[1204]: Source mac on ethernet layer:
Wed Apr 26 18:13:36 2023 daemon.info pndpd[1204]: C0 74 AD 7B 99 DA
Wed Apr 26 18:13:36 2023 daemon.info pndpd[1204]: Source IP:
Wed Apr 26 18:13:36 2023 daemon.info pndpd[1204]: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Wed Apr 26 18:13:36 2023 daemon.info pndpd[1204]: Destination IP:
Wed Apr 26 18:13:36 2023 daemon.info pndpd[1204]: FF 02 00 00 00 00 00 00 00 00 00 01 FF 7B 99 DA
Wed Apr 26 18:13:36 2023 daemon.info pndpd[1204]: Requested IP:
Wed Apr 26 18:13:36 2023 daemon.info pndpd[1204]: XX XX XX XX XX XX 18 2B C2 74 AD FF FE 7B 99 DA
Wed Apr 26 18:13:36 2023 daemon.info pndpd[1204]:
Wed Apr 26 18:13:36 2023 daemon.info pndpd[1204]: Received packet checksum validation failed

Wireshark shows the correct checksum, see attached pcap.

I'd be very grateful if you had a look.
Thanks a lot,
meiser

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.