Comments (8)
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.
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.
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.
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.
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.
from ipaddress.
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.
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)
- Random IPv6 HOT 2
- fix deprecation warning when running on ruby >= 2.3 HOT 1
- support ipv6 summarize HOT 1
- undefined method `link_local?' for #<IPAddress::IPv4:0x007fbd8353e880> HOT 2
- IPv6#split HOT 4
- valid? does not correctly validate ipv4 subnet HOT 3
- Method to compare between public addresses for IPv6
- release a new version of the gem??? HOT 4
- Add maintainers HOT 3
- Ip HOT 1
- A HOT 1
- different result between IPAddress and IPAddr when call to_i HOT 1
- Stuck while trying to get min and max ip for IPV6 range
- Is this library dead? HOT 8
- No validation for non-integer ipv6 prefixes
- Release 1.0 HOT 5
- Exception when trying to set prefix using other ip instance
- /31 prefix: hosts, network and broadcast
- `link_local?` defined twice in `lib/ipaddress/ipv6.rb` HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ipaddress.