Giter VIP home page Giter VIP logo

ndp's Introduction

ndp Test Status Go Reference Go Report Card

Package ndp implements the Neighbor Discovery Protocol, as described in RFC 4861. MIT Licensed.

The command ndp is a utility for working with the Neighbor Discovery Protocol.

To learn more about NDP, and how to use this package, check out my blog: Network Protocol Breakdown: NDP and Go.

Examples

Listen for incoming NDP messages on interface eth0 to one of the interface's global unicast addresses.

$ sudo ndp -i eth0 -a global listen
$ sudo ndp -i eth0 -a 2001:db8::1 listen

Send router solicitations on interface eth0 from the interface's link-local address until a router advertisement is received.

$ sudo ndp -i eth0 -a linklocal rs

Send neighbor solicitations on interface eth0 to a neighbor's link-local address until a neighbor advertisement is received.

$ sudo ndp -i eth0 -a linklocal -t fe80::1 ns

An example of the tool sending a router solicitation and receiving a router advertisement on the WAN interface of a Ubiquiti router:

$ sudo ndp -i eth1 -a linklocal rs
ndp> interface: eth1, link-layer address: 04:18:d6:a1:ce:b8, IPv6 address: fe80::618:d6ff:fea1:ceb8
ndp rs> router solicitation:
    - source link-layer address: 04:18:d6:a1:ce:b8

ndp rs> router advertisement from: fe80::201:5cff:fe69:f246:
    - hop limit:        0
    - flags:            [MO]
    - preference:       0
    - router lifetime:  2h30m0s
    - reachable time:   1h0m0s
    - retransmit timer: 0s
    - options:
        - prefix information: 2600:6c4a:7002:100::/64, flags: [], valid: 720h0m0s, preferred: 168h0m0s

ndp's People

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

ndp's Issues

The default ControlMessage set on WriteTo causes failures when the connection is bound to link-local on macOS

I've come across an issue that seems to be specific to macOS when binding an ndp connection to the LinkLocal address of an interface. Subsequent Writes using WriteTo will fail with a sendmsg: no route to host error. This problem does not occur when binding the connection to either the Global scoped address or Unspecified.

After some digging and reconstructing the process manually I managed to narrow the issue down to the WriteTo providing a default ControlMessage to the ipv6.PacketConn when nil is passed to the WriteTo method. Specifically it seems that explicitly setting the Src field of the ControlMessage is what causes this to fail. Passing nil or using a ControlMessage without the Src field set avoids the problem

None of this is reproducible on Linux where all versions worked as expected.

custom layer eth mac address

The original mac address of the sent data packet is the mac address of the network card. Can this mac address be changed to the mac address in the na packet?

Add SetDeadline/SetWriteDeadline methods?

Is there any reason *Conn has a SetReadDeadline method but not SetDeadline/SetWriteDeadline methods? The underlying *ipv6.PacketConn provides all three so this seems like it would easy, but I wasn't sure if there was a reason to omit them.

I'd be happy to open a PR creating SetDeadline and SetWriteDeadline methods if you agree that they should be added.

Failed to detect dublicate IPv6 address in the network

I am trying to use this tool to detect duplicate IPv6 address in the network but in case when the address is unique in the network the tool fails with the error below.

image
image

When setting the '-a' option as 'unspecified' I expected that source value in IPv6 packet would be '::' but it is not.
image

OS:
NAME="Rocky Linux"
VERSION="8.7 (Green Obsidian)"

NDP:
VERSION=v1.0.0

s/Dial/Listen/g?

func Dial(ifi *net.Interface, addr Addr) (*Conn, net.IP, error) {...}

ndp.Dial uses (*icmp.PacketConn).SetChecksum which is not implemented on Windows

As far as I am aware, this module cannot be used on Windows because the ndp.Dial method returns errNotImplemented. This error originates from the following call to (*icmp.PacketConn).SetChecksum:

ndp/conn.go

Lines 66 to 70 in 17ab9e3

// Calculate and place ICMPv6 checksum at correct offset in all messages.
const chkOff = 2
if err := pc.SetChecksum(true, chkOff); err != nil {
return nil, nil, err
}

Now, I don't know that much about ndp, however, during my testing, at least sending router advertisements seemed to work just fine when the call to SetChecksum was removed. Disclaimer: I do not know why this call is necessary and what may break if it is removed. However, if it is indeed optional, I would propose the following solutions:

1. Separate ndp.Dial for Windows

Implement a seperate ndp.Dial function with Windows build tags where the lines above are removed.

2. Allowing users to setup the connection themselves

Almost everything in ndp.Dial can be done by the user itself. However, at the end ndp.newConn is used to construct a *ndp.Conn from an *icmp.PacketConn. As ndp.newConn is not exported and as all properties of ndp.Conn are also private, this currently cannot be done by the user. If ndp.newConn was exported, users could work around this issue themselves. This solution would also work fine alongside ndp.Dial as it grants the user more flexibility to work around future issues.

3. Skipping SetChecksum at runtime on Windows

Another less preferable solution would be to just skip the SetChecksum call on Windows at runtime as follows:

if runtime.GOOS != "windows" {
	// Calculate and place ICMPv6 checksum at correct offset in all
	// messages, is is not implemented by x/net/ipv6 on Windows.
	const chkOff = 2
	if err := pc.SetChecksum(true, chkOff); err != nil {
		return nil, nil, fmt.Errorf("set checksum: %w", err)
	}
}

If you decide on a preferred solution, I could also create a PR if you want.

Create release

Can you cut binary releases to allow for easier distribution?

Thanks

Set up Drone Cloud CI using ndp

PR to follow.

Set up Drone Cloud CI, with one or more of the following, as first implemented in Travis CI .travis.yml.

  • Set up Drone Cloud for a repo in the branch
  • Build ndp
  • Test ndp using static tests (golint, staticcheck)
  • Test ndp using "go test"
  • Test ipv6 status

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.