Okay, here it is in the common language:

---------------------------------
myadm@mycomp:~$ env LANG=en_US.UTF-8 sudo ifconfig eth0:1 down
myadm@mycomp:~$ env LANG=en_US.UTF-8 sudo ifconfig eth0:1
eth0:1    Link encap:Ethernet  HWaddr 53:bc:81:02:21:bb
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:42 Base address:0xa000

# with everything cleared:

myadm@mycomp:~$ env LANG=en_US.UTF-8 sudo ifconfig eth0:1 netmask
255.255.255.224 broadcast 10.19.201.223 10.19.201.198
SIOCSIFNETMASK: Cannot assign requested address
SIOCSIFBRDADDR: Cannot assign requested address
SIOCSIFFLAGS: Cannot assign requested address

# check it,

myadm@mycomp:~$ env LANG=en_US.UTF-8 sudo ifconfig eth0:1
eth0:1    Link encap:Ethernet  HWaddr 53:bc:81:02:21:bb
          inet addr:10.19.201.198  Bcast:10.255.255.255  Mask:255.0.0.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:42 Base address:0xa000


# and apparently it is
# processing the arguments in the order they are given,
# and applying them to the state at the point they are given,
# which I sort of thought might be the case, but doesn't seem to be
# be clearly stated in the man pages.

# Thus, if you repeat the command as given,

myadm@mycomp:~$ env LANG=en_US.UTF-8 sudo ifconfig eth0:1 netmask
255.255.255.224 broadcast 10.19.201.223 10.19.201.198

# and check again,

myadm@mycomp:~$ env LANG=en_US.UTF-8 sudo ifconfig eth0:1
eth0:1    Link encap:Ethernet  HWaddr 53:bc:81:02:21:bb
          inet addr:10.19.201.198  Bcast:10.19.201.223  Mask:255.255.255.224
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:42 Base address:0xa000

# this time it sets them as intended.

# If the address to be assigned is given first, which I think everyone
# pretty much does:

myadm@mycomp:~$ env LANG=en_US.UTF-8 sudo ifconfig eth0:1 down
myadm@mycomp:~$ env LANG=en_US.UTF-8 sudo ifconfig eth0:1
10.19.201.198 netmask 255.255.255.224 broadcast 10.19.201.223
myadm@mycomp:~$ env LANG=en_US.UTF-8 sudo ifconfig eth0:1
eth0:1    Link encap:Ethernet  HWaddr 53:bc:81:02:21:bb
          inet addr:10.19.201.198  Bcast:10.19.201.223  Mask:255.255.255.224
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:42 Base address:0xa000

# it seems to see the address first and set things as intended in one pass.
---------------------------------

Which is confusing to my middle-aged brain. So I could suggest editing
the man page, something along the lines of the following

---------------------------------
SYNOPSIS
       ifconfig [-v] [-a] [-s] [interface]
{change}
       ifconfig [-v] interface [aftype] options | address ...
{change-to}
       ifconfig [-v] interface [aftype] [ display-options ] [ address
] [ other-options ... ]
{end change}


DESCRIPTION
       Ifconfig  is used to configure the kernel-resident network interfaces.
       It is used at boot time to set up interfaces as necessary.  After
       that, it is usually only needed when debugging or when system tuning
       is needed.

       If  no  arguments  are  given, ifconfig displays the status of the
       currently active interfaces.  If a single interface argument is given,
       it  displays  the  status  of  the  given interface  only;  if  a
       single -a argument is given, it displays the status of all interfaces,
       even those that are down.  Otherwise, it configures an interface.

{move the interface paragraph here:}
interface
      The name of the interface.  This is usually a driver name followed by
      a unit  number, for  example  eth0  for the first Ethernet interface.
      If your kernel supports alias interfaces, you can specify them with
      eth0:0 for the first alias of eth0. You can use them to assign a second
      address. To delete an alias interface use ifconfig eth0:0 down.
      Note: for every scope (i.e. same net  with  address/netmask  combina-
      tion) all aliases are deleted, if you delete the first (primary).
{end move}

Address Families {insert}(aftype){end-insert}
       If the first argument after the interface name is recognized as the
       name  of  a  supported address  family,  that  address  family  is
       used for decoding and displaying all protocol addresses.  Currently
       supported address families include  inet  (TCP/IP,  default),
       inet6 (IPv6), ax25 (AMPR  Packet  Radio), ddp (Appletalk Phase 2),
       ipx (Novell IPX) and netrom (AMPR Packet radio).

{insert}DISPLAY{end-insert} OPTIONS
       -a     display all interfaces which are currently available,
              even if down

       -s     display a short list (like netstat -i)

       -v     be more verbose for some error conditions

{move the address paragraph here:}
address
      The IP address to be assigned to this interface.
{end move}

{insert}OTHER OPTIONS{end-insert}

       up     This  flag  causes the interface to be activated.  It is
              implicitly specified if an address is assigned to the
              interface.

       down   This flag causes the driver for this interface to be shut
              down.

       {...}

       netmask addr
              Set the IP network mask for this interface.  This value
              defaults to the usual class A, B or C network mask (as
              derived from the interface IP address), but  it  can  be
              set to any value.

       {...}

       [-]broadcast [addr]
              If the address argument is given, set  the  protocol
              broadcast  address  for  this interface.  Otherwise,
              set (or clear) the IFF_BROADCAST flag for the interface.

       {...}

NOTES
       The parameters and options are processed in the order given, thus
       if the address appears after the netmask and broadcast address,
       the netmask and broadcast address may be re-interpreted and applied
       to an existing address, or to the state of having no address
       assigned, with unintended results which affect the security state
       of the host.

       {...}
---------------------------------

--
Joel Rees

randomly ranting:
http://reiisi.blogspot.com

Reply via email to