linuxmuster / linuxmuster-linbo

Linbo imaging system for linuxmuster.net
23 stars 22 forks source link

Add subnet function to linbo_cmd #155

Closed dorianim closed 3 years ago

dorianim commented 3 years ago

Please add a function to get the current subnet mask of the client to the linbo_cmd. I would like to use this function to prefill the parts of the IP-Address that are known in the client registration UI. For example: Client IP: 10.0.0.145 Subnet Mask: 255.255.0.0 What I would prefill: 10.0. Would be nice to get that added :)

dorianim commented 3 years ago

The function could look something like this:

subnet(){
 local iface
 local subnet
 iface="$(LANG=C route | grep ^default | awk '{ print $8 }' 2> /dev/null)"
 [ -n "$iface" ] && subnet="$(LANG=C ifconfig "$iface" | grep 'Mask:' awk '{ print $4 }')"
 [ -z "$subnet" ] && ip="OFFLINE"
 echo "$subnet"
}
fschuett commented 3 years ago

Is this ip address in registration form necessary at all? It was mentioned, that there are DHCP clients, that don't even have a fixed IP address. In oss_linbo an IP is assigned during import, maybe we can get rid of this input field alltogether? @HappyBasher Thomas, what do you think?

HappyBasher commented 3 years ago

As @fschuett mentioned there are dynamic ip clients. So it should be allowed to enter DHCP optionally instead of a fixed ip address. The subnet mask is not necessary to fill in. The client does not take care of it. Anyway it will be calculated on the server. There we better remain data economical. ;)

dorianim commented 3 years ago

Oh, ok, I didn't consider that. So should I just remove the field? And is there any other functionality that is unnecessary?

HappyBasher commented 3 years ago

So should I just remove the field?

Yep. Just use the fields that exist at the moment.

dorianim commented 3 years ago

I think we kind of misunderstood each other, I don't want to add a field for the subnet mask, I just want to prefill the currently existing field :) For example: Client IP: 10.16.0.101 Client subnet: 255.255.0.0 What the registration dialog looks like when opened: Screenshot from 2020-12-07 19-04-43

HappyBasher commented 3 years ago

There is no currently existing field for the subnet mask, I think. But we can provide subnet information in a client status area on the start page.

dorianim commented 3 years ago

That's true, there is no field for the subnet mask, and I don't want to add one ;) I think we are kind of talking past each other. I just want to use the mask to pre-fill the IP-Adress field. And yes, we could also provide subnet information on a status page. So will you add the function to get the subnet mask? :upside_down_face:

HappyBasher commented 3 years ago

I just want to use the mask to pre-fill the IP-Adress field.

Yes, indeed, I don't understand. Why do you need the subnet mask to pre-fill the ip address field?

And: On the server I use cidr notation for ip addresses and subnets. What about a function that returns the ip address in cidr?

HappyBasher commented 3 years ago

You get the client's ip with _linbocmd ip ....

dorianim commented 3 years ago

I need the subnet mask to know what parts oft the IP Address are actually fixed. For example: Client IP: 10.0.0.145 For the subnetmask 255.255.0.0 I would prefill: 10.0. But with the subnetmask 255.255.255.0 I would prefill: 10.0.0.

The IP in with cidr suffix would be fine as well :)

HappyBasher commented 3 years ago

Example:

~ # linbo_cmd netmask
255.255.255.0
~ # linbo_cmd bitmask
24
dorianim commented 3 years ago

Thank you :)