Linux box to AP with hostapd/dhcpd/iptables

2 weeks after my last failure, my hands started itching again and I tried to bridge my ethernet connection to a wireless adapter running in AP mode. Some reasons which resulted in my failures in previous occasions

1) Networking on a headless server - When playing with networks, you need to work locally since you will be bringing down interfaces and up again. Finding a head for the server was rather difficult. The cubie had only 1 HDMI port which because of some problems with EDID, only worked with the TV in the living room.I couldn't hog the TV the entire day trying to find what was wrong.

2) Interdependence - hostapd was for the AP mode, dhcpd for allocation of IP and iptables was to set up a NAT between the 2 connections, all 3 needed to work hand in hand and it was quite difficult to get them to play nice together.

Problem 1 was so bad that there was a stage where I attached 3 different network cards so I could bring down 2 interfaces and bridge them while still retaining connection to server from the 3rd connection. While it sounded nice theoretically, connection was still lost once I brought eth0 down.

I then tried mounting the entire fs on my laptop, doing the configuration there and remounting it and booting the server. This was a rather slow process, transferring the SD card from laptop to server and back again every time I needed to test a change. I eventually gave up due to the hassle.

After trying out so many methods, using dnsmasq, routing DHCP requests, and trying out different config files, it finally worked. I now have a 2nd SSID on a different subnet.