Coder Social home page Coder Social logo

Comments (8)

crosson avatar crosson commented on June 2, 2024

The broadcast actually should be 255.255.255.255 on /31 links. The library is correct and I think I asked this same question some time back and a kind gentlemen pointed this out.

Checkout and search for section section 4.3.3.9,

from ipaddress.

virgiledelplace avatar virgiledelplace commented on June 2, 2024

The broadcast actually should be 255.255.255.255 on /31 links. The library is correct and I think I asked this same question some time back and a kind gentlemen pointed this out.

Checkout and search for section section 4.3.3.9,

I don't find your question, can you give me the link pls ?

from ipaddress.

crossonST avatar crossonST commented on June 2, 2024

Yes I looked earlier today. I could be wrong on memory. It was a very long time ago.

At any rate it looks be behaving correctly in line with rfc3021.

from ipaddress.

virgiledelplace avatar virgiledelplace commented on June 2, 2024

Yes I looked earlier today. I could be wrong on memory. It was a very long time ago.

At any rate it looks be behaving correctly in line with rfc3021.

Yes i look this rules, but i dont understand how, it's work for /30 -> output : 46.17.68.79
But with /31, he output 255.255.255.255 ...

from ipaddress.

crosson avatar crosson commented on June 2, 2024

Are you curious where this is done in the library? Or curious why /30 behaves differently? A /30 has 4 addresses so you have an address for a network, two hosts, and a broadcast. It doesn't have the problem defined inrfc3021. So yes /31 and /30 behave differently as they should.

from ipaddress.

msimkins avatar msimkins commented on June 2, 2024

from ipaddress.

virgiledelplace avatar virgiledelplace commented on June 2, 2024

Hello guys,

thank's for your feedback.

Following your response, I discussed it with our network expert.

We use the / 31s with nat IP addresses, and the library works with direct ip addresses if I understood correctly.

So the library just does not work with how we use our IP addresses, I will try to modify the library to respond our needs, I will fork if it can serve.

Thank you.

from ipaddress.

crossonST avatar crossonST commented on June 2, 2024

IDK if this helps at all but instead of using the broadcast object to get the last IP you could use the entries method.

Instead of
net.broadcast.address

Use

irb(main):014:0> net = IPAddress "192.168.1.0/31"
=> #<IPAddress::IPv4:0x00000000b30498 @address="192.168.1.0", @prefix=31, @octets=[192, 168, 1, 0], @u32=3232235776>
irb(main):015:0> net.entries.first.address
=> "192.168.1.0"
irb(main):016:0> net.entries.last.address
=> "192.168.1.1"
irb(main):017:0> net.entries
=> [#<IPAddress::IPv4:0x00000000b07f48 @address="192.168.1.0", @prefix=31, @octets=[192, 168, 1, 0], @u32=3232235776>, #<IPAddress::IPv4:0x00000000b07430 @address="192.168.1.1", @prefix=31, @octets=[192, 168, 1, 1], @u32=3232235777>]
irb(main):019:0> addresses = net.collect { |o| o.address }
=> ["192.168.1.0", "192.168.1.1"]
irb(main):020:0>

Which will return each object in your network inside an array which you can iterate over.

from ipaddress.

Related Issues (20)

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.