Thanks for your fast replies, however I think I should be more  
specific.  I'm using both linux and OS X and the ifconfig output is  
different for each platform (and I suspect it would be different for  
windows as well).  While i could write something that parses the  
ifconfig output for each platform, It would be nice if there was core  
functionality in perl to get this information for me that would know  
the Right Thing to Do based on whatever platform I am using at the  
time.  Is the only way to get this info thru ifconfig?

Also, the netmask idea is good, but I'd still need to pull the IP  
address and mask from ifconfig, right?  I'm trying to avoid parsing  
ifconfig.

Thanks

Jeff

On Jun 5, 2005, at 9:30 PM, John West wrote:

> You can also use Net::Netmask:
>
> use Net::Netmask;
>
> my $block = Net::Netmask->new2('192.168.1.33', '255.255.255.192')  
> or die;
> print $block->broadcast, "\n";
>
> Hope this helps!
>
> --John
>
> On 6/5/05, Bob Rogers <[EMAIL PROTECTED]> wrote:
>
>>   From: J Finn <[EMAIL PROTECTED]>
>>   Date: Sun, 5 Jun 2005 20:26:42 -0400
>>
>>   I've got a quick question I'm hoping someone can answer.
>>
>>   If I've got a server with 3 interfaces on three different  
>> network, Is
>>   there a portable way in perl to get the broadcast addresses of each
>>   of those networks?
>>
>>   for example, if I've got an ip address: 192.168.1.33 and the  
>> netmask
>>   is 255.255.255.192 (range .32-.63), how can I find the broadcast
>>   address (192.168.1.63)?
>>
>>   Thanks
>>
>>   -jf
>>
>> Depends on what you mean by 'portable.'  I just pull the answer  
>> directly
>> from the output of ifconfig.  That is probably safest, as this may  
>> have
>> something different from the value you would compute:
>>
>>    eth1      Link encap:Ethernet  HWaddr 00:90:27:BD:F2:6F
>>              inet addr:24.34.108.24  Bcast:255.255.255.255  Mask: 
>> 255.255.248.0
>>              inet6 addr: fe80::290:27ff:febd:f26f/64 Scope:Link
>>              UP BROADCAST NOTRAILERS RUNNING MULTICAST  MTU:1500   
>> Metric:1
>>              RX packets:30307825 errors:0 dropped:0 overruns:0  
>> frame:0
>>              TX packets:3937613 errors:0 dropped:0 overruns:0  
>> carrier:0
>>              collisions:0 txqueuelen:100
>>              RX bytes:2770021884 (2641.6 Mb)  TX bytes:1617715374  
>> (1542.7 Mb)
>>              Interrupt:11 Base address:0xd000 Memory:eb100000- 
>> eb100038
>>
>> The 'Bcast:' value in this case was supplied by the Comcast DHCP  
>> server;
>> I just now noticed this for the first time.  I wouldn't be  
>> surprised to
>> learn that it violates all kinds of RFCs, though.  It could be that
>> doing it that way makes it easier for them to block broadcasts from
>> noisy Windows clients, but that's just a guess.
>>
>>                                        -- Bob Rogers
>>                                           http://rgrjr.dyndns.org/
>>
>> _______________________________________________
>> Boston-pm mailing list
>> [email protected]
>> http://mail.pm.org/mailman/listinfo/boston-pm
>>
>>
>
>
> -- 
> John West                    [EMAIL PROTECTED]
> -><- 'tis an ill wind that blows no minds -><-
>

 
_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to