I finally managed to setup an access point on my WiFi card using hostapd and dnsmasq. I did it in this order:
1) Configure hostapd and dnsmasq:
nano /etc/hostapd/hostapd.conf
nano /etc/dnsmasq.conf
Contents of hostapd.conf:
interface=wlan1mon driver=nl80211 ssid=o2wlan69 hw_mode=g channel=6 macaddr_acl=0 ignore_broadcast_ssid=0
Contents of dnsmasq.conf:
interface=wlan1mon dhcp-range=192.168.1.2,192.168.1.30,255.255.255.0,12h dhcp-option=3,192.168.1.1 dhcp-option=6,192.168.1.1 server=8.8.8.8 log-queries log-dhcp listen-address=127.0.0.1
2) These are two of the four lines which I don't know exactly what they do:
ifconfig wlan1mon up 192.168.1.1 netmask 255.255.255.0
route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.1
3) Start the services:
dnsmasq -C /etc/dnsmasq.conf -d
hostapd /etc/hostapd/hostapd.conf
4) And here are lines 3 and 4 which I don't know exactly what they do:
iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE
iptables --append FORWARD --in-interface wlan1mon -j ACCEPT
I know that iptables is used to alter block or reroute traffic coming to and from the device and I know that you can assign netmasks and IP addresses to networking devices with ifconfig. I also know how a netmask affects the local IP range but it is not clear to me how these commands help my access point share an internet connection between my wlan1mon and eth0 interface. In addition, why do I have to run the ifconfig and the route command?