Tiny Core Linux

Tiny Core Base => TCB Talk => Topic started by: Јаневски on December 12, 2012, 02:23:26 PM

Title: ifconfig oddly won't respect CIDR
Post by: Јаневски on December 12, 2012, 02:23:26 PM
Hello,

It appears that if i try to assign an IP with ifconfig within a subnet of the 192.168.0.0/16 subnet my CIDR is respected and i have no problems:
----
ifconfig eth4 up 192.168.1.1/24
ifconfig eth4
eth4      Link encap:Ethernet  HWaddr 00:00:E8:XX:XX:XX 
          inet addr:192.168.1.1  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: XXXX::XXX:XXXX:XX:XX/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:266 errors:0 dropped:0 overruns:0 frame:0
          TX packets:41 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:22874 (22.3 KiB)  TX bytes:4338 (4.2 KiB)
          Interrupt:18 Base address:0xba00
----

However if I try to assign an IP within a subnet within the subnets 172.16.0.0/12 and 10.0.0.0/8 ranges my CIDR notation won't be accepted:
ifconfig eth4 up 172.16.2.1/24
ifconfig eth4
eth4      Link encap:Ethernet  HWaddr 00:00:E8:XX:XX:XX
          inet addr:172.16.2.1  Bcast:172.16.255.255  Mask:255.255.0.0
          inet6 addr: XXXX::XXX:XXXX:XX:XX/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:296 errors:0 dropped:0 overruns:0 frame:0
          TX packets:41 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:24674 (24.0 KiB)  TX bytes:4338 (4.2 KiB)
          Interrupt:18 Base address:0xba00
ifconfig eth4 up 10.0.0.1/24
eth4      Link encap:Ethernet  HWaddr 00:00:E8:XX:XX:XX 
          inet addr:10.0.0.1  Bcast:10.255.255.255  Mask:255.0.0.0
          inet6 addr: XXXX::XXX:XXXX:XX:XX/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:296 errors:0 dropped:0 overruns:0 frame:0
          TX packets:41 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:24674 (24.0 KiB)  TX bytes:4338 (4.2 KiB)
          Interrupt:18 Base address:0xba00
----

I've tried the exact same configuration on Debian 6.0.5 and it works without any problems.
Am i doing something wrong?

Any help is greatly appreciated.

PS: Actually it looks like this happens with other subnets too i've tried to assign 1.1.1.1/24 and got 1.1.1.1/8 instead.

Best Regards,
Jovan
Title: Re: ifconfig oddly won't respect CIDR
Post by: tinypoodle on December 12, 2012, 05:42:54 PM
If you desire a behavior akin to Debian GNU/Linux, you might want to consider installing inetutils.tcz.

Also, you might want to have a look at "ipcalc" (incl. in base).
Title: Re: ifconfig oddly won't respect CIDR
Post by: curaga on December 13, 2012, 05:04:02 AM
Please report this to busybox.
Title: Re: ifconfig oddly won't respect CIDR
Post by: Јаневски on December 13, 2012, 10:40:22 AM
If you desire a behavior akin to Debian GNU/Linux, you might want to consider installing inetutils.tcz.

Also, you might want to have a look at "ipcalc" (incl. in base).
Thank You for You advice, i do find ipcalc quite useful. :)

Please report this to busybox.
Thanks a lot, I've reported it to busybox: :)
https://bugs.busybox.net/show_bug.cgi?id=5786

I've found that the only way to get the proper IP and subnet assignment per interface while
using busybox is - instead of using:
----
ifconfig eth4 up 172.16.2.1/24
----
i could use:
----
ifconfig eth4 172.16.2.1 netmask 255.255.255.0 broadcast 172.16.2.255
----
And then i get the propper IP and subnet assignment.

We shall wait for resolving of the busybox bug.

Best Regards,
Jovan
Title: Re: ifconfig oddly won't respect CIDR
Post by: Јаневски on January 20, 2013, 09:34:48 AM
The busybox bug report has been answered.

Busybox ifconfig won't accept the slash CIDR notation format, it will support the ip address, netmask, broadcast address format.
Not accepted: ifconfig eth0 up 1.2.3.4/17
Accepted: ifconfig eth4 172.16.2.1 netmask 255.255.255.0 broadcast 172.16.2.255

For more details, check https://bugs.busybox.net/show_bug.cgi?id=5786

Best Regards,
Jovan