Results 1 to 2 of 2

Thread: editing dhcpd.conf using shell or perl script

  1. #1
    Join Date
    Apr 2007
    Beans
    3

    editing dhcpd.conf using shell or perl script

    Hi,

    I have setup a network at my workplace. We have around 10 PCs in the network, the dhcp server is running on Ubuntu 8.04 - server edition.

    I want to reserve the ip addresses based on the MAC addresses of clients. I have a list of hostnames and thier MAC addresses ready. We are expecting a few more machines in some time.

    I dont want to spend entire day, writing the same configuration lines over and over again. (not to mention time needed for debugging to correct for a small typo )

    So, can someone help me out in writing a perl/shell script which can read these details from a text/csv file and modify the dhcpd.conf file, in a properly formatted fashion?

    Can someone help me?

    Thanks for your time..

  2. #2
    Join Date
    Feb 2008
    Location
    Minnesota, USA
    Beans
    754
    Distro
    Ubuntu 8.10 Intrepid Ibex

    Re: editing dhcpd.conf using shell or perl script

    The general form of the part of the dhcp.conf file I think you want to look at is:

    Code:
    host atlantis {
      hardware ethernet 00:11:22:33:44:55;
      fixed-address 10.1.1.2;
    }
    So if you had a file of the form:
    Code:
    atlantis,00:11:22:33:44:55,10.1.1.2
    A simple perl script would be like this, off the top of my head:
    Code:
    #/usr/bin/perl -n
    
    chomp; 
    @items = split /,/; 
    print "host $items[0] {
    hardware ethernet $items[1]; 
    fixed-address $items[2]; 
    }";
    Understand that you would still have to set up things like logging, subnets, and ddns updates.

    Hope this helps.
    Hate fighting with Linux? Buy Preinstalled!
    Love fighting with Linux? Try Gentoo!
    __________________________________________________
    Unanswered Posts Team || Connection problems?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •