1822525 Members
2635 Online
109642 Solutions
New Discussion юеВ

sorting ip addresses

 
SOLVED
Go to solution
anang bohra
Occasional Contributor

sorting ip addresses

hi there,
i have a linux DHCP server and i want to assign only odd ip addresses to the machines.
i am using class B address.

thanx in advance.
hi! everybody
5 REPLIES 5
Bill Thorsteinson
Honored Contributor

Re: sorting ip addresses

This is a very strange request, and doesn't seem
to match the subject heading.

However you can do it like this

subnet 10.0.1.0 netmask 255.255.255.0 {
range 10.0.1.1;
range 10.0.1.3;
range 10.0.1.5;
range 10.0.1.7;
range 10.0.1.9;
}
anang bohra
Occasional Contributor

Re: sorting ip addresses

thanx Bill,
but i wanted to know if we could write any script for this; otherwise it requires large no. of entries.
any help will be appreciated.
hi! everybody
Vincent Fleming
Honored Contributor
Solution

Re: sorting ip addresses

awk '{for( i=1; i < 256; i+=2 ) { printf( "range 10.0.1.%d\n", i ) } }'

Hit enter, and all the entries will spit out. Redirect this to a file, paste it into the proper config file.
No matter where you go, there you are.
anang bohra
Occasional Contributor

Re: sorting ip addresses

hi vincent,
may i know which conf. file do i need to enter
thanks in advance
hi! everybody
Vincent Fleming
Honored Contributor

Re: sorting ip addresses

I haven't actually set dhcp up on linux before, but I think it's /etc/dhcp.conf (that's what it is on FreeBSD)
You should just check the man page for that.
No matter where you go, there you are.