Re: bits from hex

From: Robert Bonomi (bonomi_at_c-ns.)
Date: 07/21/03


Date: Mon, 21 Jul 2003 00:11:08 GMT

In article <olASa.107120$ye4.79477@sccrnsc01>,
ME <trash.trash@comcast.net> wrote:
>I am not a keen on shell scripting so I am asking for some assistance. I
>have a firewall script that I have got to currently find the network mask of
>my main Interface (set to use DHCP). I would like to calculate the number
>of network bits from the mask. The mask I have retrieved from the interface
>is given in HEX. I assume there is probably an easy way to get this
>converted but I have no Idea how to do it. Does any one else have an idea
>(perferably using sh)?
>
>Thanks,
>
>Matt
>
>

run a loop 32 times that does the following:
    if the netmask value is less than zero,
        add one to network_bits_count
    shift netmask left one bit.
      
when you fall out of that loop, you have the number of network bits.
even if they're not contiguous.



Relevant Pages

  • Re: Determining what should be blocked in and out?
    ... mask, the .0, will always make the last byte of the IP address you're ... zero always for the purposes of checking if it's to be blocked. ... IP address you are trying to contact is on the same network as you. ... Since this equals the same network to be blocked, ...
    (comp.security.firewalls)
  • Re: TCP/IP connection problem
    ... that includes routers) but a mask problem. ... These changes depend upon what type network connectivity ... then the mask on the VMS system is not ... With those ranges you can use subnetting which is usually ...
    (comp.os.vms)
  • [SLE] Basic SAMBA Configuration
    ... I have 2 computers I am trying to network. ... directory mask = 0700 ...
    (SuSE)
  • Re: [SLE] SAMBA Problem
    ... _correct_ mask within a network no problem. ... For networks not using CIDR or VLSM, just use the correct mask, and you can ... the subnet mask is used to ...
    (SuSE)
  • Re: Problems setting up DNS, gateway und subnetmask!
    ... >On the LAN side of your router, i.e. the wiring between the router and your ... you are using the private network 10.0.0.x. ... That would also be a 'network' mask, ... However each distribution has their own cute little tool designed to "help" ...
    (comp.os.linux.setup)

Loading