Re: CIDR vs aliases with ifconfig/hostname.if

2020-12-03 Thread Steve Fairhead

On 03/12/2020 13:20, Steve Fairhead wrote:
There's also this, which I wrote to help a student (my daughter) 
understand netmasks and CIDR notation:


http://www.fivetrees.com/netmasks/netmasks.php

It's kinda fun to watch the bit patterns move around...


I can see from my logs that this has proven popular today. It was 
written as a bit of fun; it it's actually useful, please let me know if 
it's missing something, could use a new feature, or if you figure it's 
just plain wrong ;) .


Also: for me, CIDR is the only sane way to describe netmasks. There are 
4,294,967,296 possible values for an IPV4 netmask, but just 33 (or 
fewer, depending on your level of pedantry) of these are valid.


Steve

--

--
  Steve Fairhead
fivetrees ltd - for the complete music service
   www: http://www.fivetrees.com
--



Re: CIDR vs aliases with ifconfig/hostname.if

2020-12-03 Thread Steve Fairhead

Mike Coddington  writes:

> There was a useful tool that someone posted on misc a while back called
> netcalc. I think this is its website:
> 
https://jamsek.dev/posts/2019/Sep/21/ipv4-and-ipv6-cidr-subnet-calculator/

> Check it out if you want to get a better grasp on CIDR notation.

There's also this, which I wrote to help a student (my daughter) 
understand netmasks and CIDR notation:


http://www.fivetrees.com/netmasks/netmasks.php

It's kinda fun to watch the bit patterns move around...

Steve

--

--
  Steve Fairhead
fivetrees ltd - for the complete music service
   www: http://www.fivetrees.com
--



Re: CIDR vs aliases with ifconfig/hostname.if

2020-12-03 Thread Allan Streib
Chris Bennett  writes:

> So, what happens with 104.149.1.112? Does anybody get to actually use
> it? Or is it just a placeholder?

Here is my understanding. View the address 104.149.1.112 in binary
format:

01101000.10010101.0001.0111

The /28 netmask is:

...

So in this case the "host" part is the last four bits. That gives you 16
addresses possible. When the host bits are all zero, that is the network
address. It's the "network" without any specific host. It's used in
routing tables (maybe other things?).

When the host bits are all ones, that's the broadast address. It refers
to all hosts on the network.

Hosts can use any address between these two. So the /28 network has 14
hosts. The first or last host address is typically the gateway but as
far as I know that's just convention.

Allan



Re: CIDR vs aliases with ifconfig/hostname.if

2020-12-02 Thread Stuart Henderson
On 2020-12-03, Greg Thomas  wrote:
> Nope, as mentioned it's the network address, for every subnet you're going
> to get a network address and a broadcast address, and your usable IPs in
> between.

When it's used as an ethernet-type network, yes. If it's routed to you via
another link (for example if you get a /29 from an ISP and it's routed to
you via ppp or via a separate link network) you can often use those
first/last addresses, at least for nat/port forwarding.




Re: CIDR vs aliases with ifconfig/hostname.if

2020-12-02 Thread Chris Bennett
On Wed, Dec 02, 2020 at 10:51:34PM -0800, Greg Thomas wrote:
> Nope, as mentioned it's the network address, for every subnet you're going
> to get a network address and a broadcast address, and your usable IPs in
> between.
> 
OK, that's very clear the way you just said it. That explains really
well why CIDR is so important - clarity.

Thanks,
Chris



Re: CIDR vs aliases with ifconfig/hostname.if

2020-12-02 Thread Greg Thomas
Nope, as mentioned it's the network address, for every subnet you're going
to get a network address and a broadcast address, and your usable IPs in
between.

On Wed, Dec 2, 2020 at 10:45 PM Chris Bennett <
cpb_m...@bennettconstruction.us> wrote:

> On Wed, Dec 02, 2020 at 11:26:15PM -0500, Allan Streib wrote:
> > Mike Coddington  writes:
> >
> > > There was a useful tool that someone posted on misc a while back called
> > > netcalc. I think this is its website:
> > >
> https://jamsek.dev/posts/2019/Sep/21/ipv4-and-ipv6-cidr-subnet-calculator/
> > > Check it out if you want to get a better grasp on CIDR notation.
> >
> > There is also ipcalc in packages and that is one I use frequently,
> > though it's only for IPv4.
> >
> > $ ipcalc 104.149.1.112/28
> > address   : 104.149.1.112
> > netmask   : 255.255.255.240 (0xfff0)
> > network   : 104.149.1.112   /28
> > broadcast : 104.149.1.127
> > host min  : 104.149.1.113
> > host max  : 104.149.1.126
> >
> > Allan
> >
>
> So, what happens with 104.149.1.112? Does anybody get to actually use
> it? Or is it just a placeholder?
>
> I never really paid a lot of attention to CIDR until I started to need a
> lot of IP addresses for websites, email, etc. for TLS/SSL certs.
>
> I stumbled upon this server where I have my other two and I couldn't
> pass up $31 a month. I can't reasonably backup properly at home, too
> slow a connection.
>
> Chris
>
>
>


Re: CIDR vs aliases with ifconfig/hostname.if

2020-12-02 Thread Chris Bennett
On Wed, Dec 02, 2020 at 11:26:15PM -0500, Allan Streib wrote:
> Mike Coddington  writes:
> 
> > There was a useful tool that someone posted on misc a while back called
> > netcalc. I think this is its website:
> > https://jamsek.dev/posts/2019/Sep/21/ipv4-and-ipv6-cidr-subnet-calculator/
> > Check it out if you want to get a better grasp on CIDR notation.
> 
> There is also ipcalc in packages and that is one I use frequently,
> though it's only for IPv4.
> 
> $ ipcalc 104.149.1.112/28
> address   : 104.149.1.112
> netmask   : 255.255.255.240 (0xfff0)
> network   : 104.149.1.112   /28
> broadcast : 104.149.1.127
> host min  : 104.149.1.113
> host max  : 104.149.1.126
> 
> Allan
> 

So, what happens with 104.149.1.112? Does anybody get to actually use
it? Or is it just a placeholder?

I never really paid a lot of attention to CIDR until I started to need a
lot of IP addresses for websites, email, etc. for TLS/SSL certs.

I stumbled upon this server where I have my other two and I couldn't
pass up $31 a month. I can't reasonably backup properly at home, too
slow a connection.

Chris




Re: CIDR vs aliases with ifconfig/hostname.if

2020-12-02 Thread Allan Streib
Mike Coddington  writes:

> There was a useful tool that someone posted on misc a while back called
> netcalc. I think this is its website:
> https://jamsek.dev/posts/2019/Sep/21/ipv4-and-ipv6-cidr-subnet-calculator/
> Check it out if you want to get a better grasp on CIDR notation.

There is also ipcalc in packages and that is one I use frequently,
though it's only for IPv4.

$ ipcalc 104.149.1.112/28
address   : 104.149.1.112
netmask   : 255.255.255.240 (0xfff0)
network   : 104.149.1.112   /28
broadcast : 104.149.1.127
host min  : 104.149.1.113
host max  : 104.149.1.126

Allan



Re: CIDR vs aliases with ifconfig/hostname.if

2020-12-02 Thread Mike Coddington
On Wed, Dec 02, 2020 at 06:49:01PM -0600, Chris Bennett wrote:
> Hi,
> after seeing a post here using CIDR, I re-read some manual pages.
> I have been using aliases, but it looks like using CIDR is the preferred
> method.
> Could someone explain that a little better than the manual pages do?
> An example might help better to explain why aliases are used when
> changing network numbers. Is it a short term fix?
> Is there a downside to using aliases vs CIDR?
 
So, I'm not quite sure what you mean because in hostname.if the term
"alias" refers to giving the interface more than one IP address. For
example, here's my hostname.if file, /etc/hostname.vr0.

inet 192.168.3.25 255.255.255.0
inet6 autoconf
inet6 alias 2001:470:314f:3::25 64

The first line is my IPv4 address, not in CIDR format. I am not sure
that you are even able to specify the address in CIDR, although I could
be wrong. This has been my setup for many iterations of OpenBSD.

The second line allows me to pick up an IPv6 address via my router's
SLAAC setup. Your ISP may or may not provide this. The third line is an
alias, where I am manually specifying which IPv6 address I'd like to
apply in addition to the addresses that are autoconf-ed. I do this
because I run a mail server and I want to make sure that the server does
its communication over a static IP address.

> My other question is what to put for the address.
> I have 104.149.1.112/28. Should I just put this?
> 113 is the gateway. What is 112? It doesn't ping.
> 113 pings even if the rest is inaccessible.

When you are assigned a range of IP addresses from your ISP, you are
given the range in CIDR format like you specify. For example, I have a
static IP address for my mail server and my ISP gave me the CIDR range
of 206.55.191.72/30. .72 is the "network address" and is unusable. .73
is my gateway and .74 is the actual, single IP address that I have
assigned to my server. That's why you can't ping .112. You can probably
give your server 104.149.1.114 and be good to go.

There was a useful tool that someone posted on misc a while back called
netcalc. I think this is its website:
https://jamsek.dev/posts/2019/Sep/21/ipv4-and-ipv6-cidr-subnet-calculator/
Check it out if you want to get a better grasp on CIDR notation.

-Mike

-- 
Put your Nose to the Grindstone!
-- Amalgamated Plastic Surgeons and Toolmakers, Ltd.