WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: ifconfig oddly won't respect CIDR  (Read 3286 times)

Offline Јаневски

  • Jr. Member
  • **
  • Posts: 61
ifconfig oddly won't respect CIDR
« on: December 12, 2012, 05: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
« Last Edit: December 12, 2012, 06:18:14 PM by Јаневски »

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: ifconfig oddly won't respect CIDR
« Reply #1 on: December 12, 2012, 08: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).
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11044
Re: ifconfig oddly won't respect CIDR
« Reply #2 on: December 13, 2012, 08:04:02 AM »
Please report this to busybox.
The only barriers that can stop you are the ones you create yourself.

Offline Јаневски

  • Jr. Member
  • **
  • Posts: 61
Re: ifconfig oddly won't respect CIDR
« Reply #3 on: December 13, 2012, 01:40:22 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).
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
« Last Edit: December 13, 2012, 01:42:47 PM by Јаневски »

Offline Јаневски

  • Jr. Member
  • **
  • Posts: 61
Re: ifconfig oddly won't respect CIDR
« Reply #4 on: January 20, 2013, 12:34:48 PM »
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