github.com/transparency-dev/armored-witness-applet@v0.1.1/third_party/dhcp/README.md (about)

     1  # Provenance 
     2  
     3  This directory contains a partial copy of the Fuscia DHCP package here:
     4  https://fuchsia.googlesource.com/fuchsia/+/4ad0d5717d65/src/connectivity/network/netstack/dhcp/
     5  Only the DHCP client support has been imported.
     6  
     7  Some minor fix-ups were made to the code in order to enable it to compile
     8  against more recent versions of the gVisor API used by this repo.
     9  
    10  Original README contents continue below.
    11  
    12  # Testing against a local DHCP server
    13  
    14  These instructions will run a DHCP server locally on your computer for testing
    15  the DHCP client.
    16  
    17  Run qemu with Fuchsia. We'll give Fuchsia two NICs so that we can test the
    18  interaction between them and DHCP. Make all the tunnels:
    19  
    20      sudo tunctl -u $USER -t qemu
    21      sudo tunctl -u $USER -t qemu-extra
    22      sudo ifconfig qemu up
    23      sudo ifconfig qemu-extra up
    24  
    25  Now build and run Fuchsia with those two ports:
    26  
    27      fx build && fx qemu -kN -- -nic tap,ifname=qemu-extra,model=e1000
    28  
    29  Now install a DHCP server.
    30  
    31      sudo apt-get install isc-dhcp-server
    32      ps aux | grep dhcp
    33  
    34  If dhcpd was started as part of that, kill it:
    35  
    36      sudo systemctl disable isc-dhcp-server.service
    37  
    38  Make a file called /tmp/dhcpd.conf with these contents:
    39  
    40      default-lease-time 3600;
    41      max-lease-time 7200;
    42      authoritative;
    43      subnet 172.18.0.0 netmask 255.255.0.0 {
    44        option routers                  172.18.0.1;
    45        option subnet-mask              255.255.0.0;
    46        option domain-search            "testdomain18.lan";
    47        option domain-name-servers      172.18.0.1;
    48        range   172.18.0.10   172.18.0.100;
    49      }
    50      subnet 172.19.0.0 netmask 255.255.0.0 {
    51        option routers                  172.19.0.1;
    52        option subnet-mask              255.255.0.0;
    53        option domain-search            "testdomain19.lan";
    54        option domain-name-servers      172.19.0.1;
    55        range   172.19.0.10   172.19.0.100;
    56      }
    57  
    58  dhcpd knows which addresses to serve on which nics based on matching the
    59  existing IP address on the NIC so you need to set those:
    60  
    61      sudo ifconfig qemu 172.18.0.1
    62      sudo ifconfig qemu-extra 172.19.0.1
    63  
    64  Now we'll run dhcpd.  You can use the filenames below or modify them.
    65  
    66  If the leases file doesn't already exist, dhcpd might complain.  Go ahead and
    67  create the file first:
    68  
    69      sudo touch /tmp/dhcpd.leases
    70  
    71  Now run:
    72  
    73      sudo dhcpd -4 -f -d -cf /tmp/dhcpd.conf -lf /tmp/dhcpd.leases qemu qemu-extra
    74  
    75  Now Fuchsia should get DHCP addresses and you'll see debug output for each step
    76  in the dhcpd output.