That is the problem, and not something you would want to do even if you could. MAX() is no guarantee of uniqueness, as it is susceptible to race conditions. Use a sequence instead - simplist is just to use the SERIAL datatype. All this is explain in the postgresql manual.
Thanks a lot, it worked when changed the query to:
create table ip_allocations (alloc_id serial not null primary key,userid numeric (8) not null,chunk_id numeric(4) references ip_networks (chunk_id) on delete cascade,ip_net varchar(15) not null, ip_mask numeric (2) not null, constraint ip_mask_check check (ip_mask between 0 and 32));