eblot / pybootd

A minimalist bootp/dhcp/pxe and tftp server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question: Library Usage

ccscpanici opened this issue · comments

Hello, I'd like to create a script that listens for BOOTP requests, and prints out mac addresses when requests come in. If they are a known host, the script will reply back with the IP address message, that information will also get printed to the console. Could your library be adopted to do this? Could it run on only one interface?

Any information would greatly help me.

Chris

I am looking to do something like this:

if name == 'main':

# network configuration
network = "192.168.1.0"
mask = "255.255.255.0"

known_hosts = {
    "E3:B2:K5:12":"192.168.1.123"
}

# start the infinite loop
while True:

    # wait for a BOOTP request
    #TODO: Get the request from the needed library

    # find the source mac address inside of the request

    # when a request comes in, check if it is in the known hosts
    if a_request.mac in known_hosts:

        # if the mac is in the known host,
        # reply with the ip address message

        pass

    else:

        # print the mac address
        print("UNASSIGNED REQUEST FROM MAC: %s" % a_request.mac)