[mythtv-users] convoluted questiom

Stephen Worthington stephen_agent at jsw.gen.nz
Tue Dec 28 15:52:55 UTC 2021


On Tue, 28 Dec 2021 08:43:33 -0600, you wrote:

>James:
>> This does mean that to upgrade I have to temporarily
>> reboot the server onto a different subnet to do any upgrades, etc.
>
>On a Linux system you can add a second IP address to a device to access 
>a second network:
>
>    *Second/Alternate IP address – two network address:*
>
>    sudo ip addr add 192.168.0.199/24 broadcast 192.168.0.199 dev enp1s0
>
>    Temporarily (clears at boot) adds this address to current device.
>    Allows connecting to different LAN. (so  192.168.4.22 and
>    192.168.0.199.)
>
>
>"enp1s0" is my ethernet port per ifconfig.  I am not certain of the 
>'24'; may need a smaller number -- I sort of know what it's for but not 
>enough to start to explain.  *.*.4.* is the original network here; 
>*.*.0.* the alternate.
>
>
>(And I thought I was bowing out of this thread! <g>)
>
>Barry-

With a /24 address, the top 24 bits are the subnet address and the
bottom 8 bits are the device addresses on that subnet.  Normally, the
broadcast address for any subnet is the highest device address, so for
a subnet of 192.168.0.0/24, the broadcast address should be
192.168.0.255.  So the command should be:

sudo ip addr add 192.168.0.199/24 broadcast 192.168.0.255 dev enp1s0

The 192.168.0.0/24 subnet will then contain 254 device addresses:
192.168.0.0 to 192.168.0.254, with 192.168.0.255 as the broadcast
address.

In theory, you can assign any device address as the broadcast address,
and as long as all devices have been told to work the same way it
should work just the same as using the highest device address.  But
the convention of using the highest device address as the broadcast
address is very strong - I have never seen any network using a
different address.  And it is very likely that there is plenty of
software out there that will assume the broadcast address is the
highest device address and will be broken if it is not.

An alternative notation for specifying which address bits are the
subnet address and which bits are the device address is to use a
bitmask, as seen in "netmask" clause in some commands such as
ifconfig.  A /24 is the same as "netmask 255.255.255.0" where the top
24 bits of the netmask value (255.255.255.0 = 0xFFFFFF00) are set to
indicate that those bits are a mask for the network address bits.  The
netmask value is "anded" with an address to get the network address
part.  Some commands allow both notations.

Using the dotted decimal notation for netmasks (and IPv4 addresses)
has always seemed a bit strange to me as it rather obscures how they
work.  It is much more obvious using hex notation.  And I expect that
IPv6 addresses use hex notation for that reason as well as to cut down
on the length of the address when you have to write it down.


More information about the mythtv-users mailing list