Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for CIDR address format #26

Open
dimagafurov opened this issue Feb 23, 2018 · 9 comments
Open

Support for CIDR address format #26

dimagafurov opened this issue Feb 23, 2018 · 9 comments

Comments

@dimagafurov
Copy link

In Debian 9 Stretch it is possible to set up addresses in CIDR format.

Example

iface eth0 inet static
        address 192.168.99.1/24
        gateway 192.168.99.1
        name eth0

instead of:

iface eth0 inet static
        address 192.168.99.1
        netmask 255.255.255.0
        gateway 192.168.99.1
        name eth0

Debinterfaces currently does not support this and it gives ValueError on validating IP addres when trying to parse interfaces file

@nMustaki
Copy link
Owner

nMustaki commented Feb 23, 2018 via email

@dimagafurov
Copy link
Author

Hi,
It doesn't add any useful information, it is absolutely equivalent to format with separate address and netmask.
But it breaks down the cases when we need to parse interface file generated by some other software. For example, Debian Stretch Installer writes interfaces file in CIDR format.

@nMustaki
Copy link
Owner

nMustaki commented Feb 23, 2018 via email

@dimagafurov
Copy link
Author

I think the second solution is just enough - convert CIDR into 'classic' address + netmask, as I don't see any difference in system behavior depending of address format.

Besides, do you know what happens if there are both CIDR and netmask ?

I will test it in an hour or two and write here

@dimagafurov
Copy link
Author

According to the manpage we can use address as dotted quad/netmask and netmask can be dotted quad or CIDR
so valid formats are:

iface eth0 inet static
        address 192.168.99.1/24
iface eth0 inet static
        address 192.168.99.1/255.255.255.0
iface eth0 inet static
        address 192.168.99.1/24
        netmask 255.255.255.0
iface eth0 inet static
        address 192.168.99.1
        netmask 24

If both "classic" and CIDR format present it uses netmask option, but I get it experimentally, I cannot found it documented

@dimagafurov
Copy link
Author

I made quick and ugly workaround for my purposes, it is completely not production-ready but maybe it will be useful

@nMustaki
Copy link
Owner

nMustaki commented Feb 23, 2018 via email

@guedressel
Copy link

The package netaddr has a nice implemenation for CIDR processing.
You might consider using this in debinterface.

@nMustaki
Copy link
Owner

Hi @guedressel , I don't want to add a dependency if I can help it, as this library is used in some places where disk space and internet access is limited. It aso add synchronisation costs with the netaddr library, even if it's quite stable at this point. I'm open to discussion though !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants