[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: ulogd saves ipaddr as 32 bit int



On 19 Feb 2005, Jimmy B. wrote:
> I just installed ulogd with MySQL support to use with my iptables 
> firewall to log traffic. Everything works fine but I have one question
> though: ulogd saves the src and dst ipaddr as an integer in the database 
> (a 32 bit unsigned integer according to the docs) and I wonder how can I 
> translate that into a normal ip addr? I'm guessing it shouldn't be too 
> hard in either bash or php (which is my scripting language of choice.) 

A normal IP address /is/ a 32 bit integer;  it just gets printed as:

  first octet  dot  second octet dot ...

So, something like this:

    print $ip >> 3, '.', $ip >> 2 & 0xff, '.', ...

    Daniel
-- 
What we call reality is an agreement that people have arrived at to
make life more livable.
        -- Louise Nevelson



Reply to: