define(`TITLE', `DHCP server on a MacBook') define(`DATE', `2013-11-07') define(`CONTENT', ` When working with the Arduino I almost have the Ethernet Shield attached or directly make use of the Arduino Ethernet board. Nearly everything I'`m playing around with is network-attached. Once it is done, I connect it to my home network, where a DHCP server provides network configuration. But while developing software for the beast, it is on the table in front of me with no network cables around, my laptop is connected via WLAN. A while a was using a small Mikrotik 750 with only the DHCP server enabled to connect my MacBook Air via the USB adapter and the Arduino. The problem: so much stuff and more over, the DHCP server of the Mikrotik overwrites the default gateway of my home network. So the MacBook has access to the home network, but when accessing the Internet it tries to route via the Mikrotik, which has no Internet connection. Bad! To solve this issue I considered to start a DHCP server on the MacBook, attaching it only to the USB network adapter. Since the related interface has no other connection, particularly hasn'`t received a network configuration from another DHCP server (the one in the home network has configured the WLAN interface), first an IP address has to be assigned to the interface. Actually, Mac OS X comes with a DHCP server, which just needs some configuration: /etc/bootptab (this is the MAC-address of the Arduino, just to know which IP address is assigned to it):

    %%
    due     1       DE:AD:BE:EF:FE:ED   192.168.75.20

/etc/bootpd.plist:

    <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
      <dict>
        <key>bootp_enabled</key>
        <false/>
        <key>dhcp_enabled</key>
        <array>
           <string>en2</string>
        </array>
        <key>Subnets</key>
        <array>
          <dict>
            <key>name</key>
            <string>internal</string>
            <key>net_mask</key>
            <string>255.255.255.0</string>
            <key>net_address</key>
            <string>192.168.75.0</string>
            <key>net_range</key>
            <array>
              <string>192.168.75.20</string>
              <string>192.168.75.29</string>
            </array>
            <key>allocate</key>
            <true/>
          </dict>
        </array>
      </dict>z
    </plist>

And finally a small script to assign the address and start the server:

    #!/bin/sh

    INTF=en2

    ifconfig $INTF alias 192.168.75.1
    /usr/libexec/bootpd -D -d -i $INTF
    ifconfig $INTF -alias 192.168.75.1

Done. Once the script is started, it assigns the IP address and starts the booted (the DHCP server). The server will not detach from the terminal and does not fork into background. So, it can simply be stopped using Ctrl-C. However, Ctrl-C also interrupts the script and the unassigning of the address is not executed. This unfortunately needs to be done manually. Now I can connect the Adruino Ethernet directly to my MacBook and it will receive the network configuration from it. ')