FedoraForum.org - Fedora Support Forums and Community
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2006
    Location
    Algeria
    Posts
    828

    Thumbs up Listing IP's from a dhcpd.conf file

    Hy every body,

    Within a dhcpd.conf file, we got some fixed IP adresses from 192.168.0.1 – 192.168.0.254.
    The 192.168.0.0/24 subnet

    Sample:

    #ddns-update-style interim;
    ddns-update-style none;
    ignore client-updates;
    deny client-updates;
    authoritative;

    #### By red for PXE Booting
    allow booting;
    allow bootp;
    ### End by red

    log-facility local6;

    subnet 192.168.0.0 netmask 255.255.255.0 {
    # --- default gateway

    ##### By red for PXE booting
    class "pxeclients" { match if substring(option vendor-class-identifier, 0, 9) = "PXEClient";
    next-server 192.168.0.1;
    filename "linux-install/pxelinux.0"; }
    #### End by red

    option routers 192.168.0.1;
    option subnet-mask 255.255.255.0;
    # option nis-domain "domain.org";
    option domain-name "ensm.intranet";
    option domain-name-servers 192.168.0.1;
    option time-offset -18000;
    range dynamic-bootp 192.168.0.5 192.168.0.239;
    default-lease-time 3600;
    max-lease-time 7200;
    # we want the nameserver to appear at a fixed address

    group {
    use-host-decl-names true;

    host Naoui-EISN1A {
    hardware ethernet 00:71C:6E:A3:33;
    fixed-address 192.168.0.6;
    }

    host Labdazi-EISN1A {
    hardware ethernet C0:38:96:72:8B:5B;
    fixed-address 192.168.0.7;
    }

    host Zair-EISN1A {
    hardware ethernet 08:ED:B9:08:94:09;
    fixed-address 192.168.0.8;
    }

    host Laddi-EISN1A {
    hardware ethernet D0:53:49B:FE:0F;
    fixed-address 192.168.0.9;
    }

    host Zeghar-EISN1A {
    hardware ethernet C4:8E:8F:8F:45:A7;
    fixed-address 192.168.0.10;
    }


    }
    }

    We need a bash script which list all the IP's in one text file in a way that :

    Those Ip's who are part of the dhcpd.conf will be listed one per line and will have a '#' symbol at the begining, such as :

    #192.168.0.6
    #192.168.0.7
    #192.168.0.8
    …….
    …….
    All the other IP's who are not part of the dhcpd.conf will be just listed one per line :


    192.168.0.100
    192.168.0.101
    192.168.0.201
    ………
    ………

    Thanks a lot for your help Linux

    red
    Last edited by hermouche; 9th November 2017 at 08:04 PM.
    IBM ThinkPad z60m

  2. #2
    Join Date
    Oct 2011
    Posts
    1,609

    Re: Listing IP's from a dhcpd.conf file

    Code:
    $ grep "fixed-address" dhcpd.conf | sed -r 's/.*fixed-address ((\b[0-9]{1,3}\.){3}[0-9]{1,3}\b);/#\1/'

Similar Threads

  1. dhcpd.conf file not found in fedora 15
    By magicalshashank in forum Servers & Networking
    Replies: 4
    Last Post: 18th October 2011, 08:38 PM
  2. Cannot find dhcpd.conf file in FC3
    By Shamshir in forum Servers & Networking
    Replies: 3
    Last Post: 15th July 2005, 05:09 PM
  3. where i find DHCPd.conf file ???
    By hanybee in forum Using Fedora
    Replies: 9
    Last Post: 11th June 2005, 09:06 PM

Tags for this Thread

Posting Permissions

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