~ $touch/var/lib/misc/udhcpd.leasesEnable udhcpd permanently , commenting the followingline in /etc/default/udhcpd pi@raspberrypi ~ $nano/etc/default/udhcpd# DHCPD_ENABLED = No Set the udhcpd to start automatically at boot. Usethe command below. pi@raspberrypi ~ $ update-rc.d udhcpd enableEdit /etc/network/interfaces andset the new interface that will be used to access the wireless modem. Inmy case, I used the wlan0 interface, which used static IP or IP 192.168.1.1, thatwas set in the file udhcpd.conf shown above. If there is already adefinition for wlan0, comment and update. Here is how was my interfacesfile. Auto loiface it inet loopbackiface eth0 inet dhcp iface wlan0 inet staticaddress 192.168.1.1netmask 255.255.255.0network 192.168.1.0broadcast 192.168.1.255 # allow-hotplug wlan0#iface wlan0 inet manual#wpa -roam /etc/wpa_supplicant/wpa_supplicant.conf#iface default inet dhcp up iptables-restore</etc/iptables.ap3.2. Configure the server hostapd/etc/hostapd/hostapd.conf Edit the file as follows # interface used by access pointinterface = wlan0 # firmware driverdriver = nl80211 # access point SSIDssid = HotPi # operator mode (a = IEEE 802.11a, b = IEEE 802.11b, g= IEEE 802.11g)hw_mode = g # access point channelchannel = 11 macaddr_acl = 0auth_algs = 1ignore_broadcast_ssid = 0 # key management algorithmwpa_key_mgmt = WPA-PSKwpa_passphrase = <your passkey>WPA 2 = # set cipherswpa_pairwise = TKIPrsn_pairwise = CCMPYou can change the ssid, the channel and wpa_passphraseto values of your choice. Note that the ssid is the wi-fi name that willbe propagated as a hotspot that other devices can connect to internet. Ifyou want to create an open network, simply comment wpa_passphrase parameter.Edit the /etc/default/hostapd and make the following change # DAEMON_CONF = to# DAEMON_CONF = /etc/hostapd/hostapd.conf Set hostapd server for automatic start at boot, which can be done by executingthe command below. pi@raspberrypi ~ $ update-rc.d enable hostapd4. Forwarding via NAT (Network Address Translation)The last part of our project to allow it workis to promote the redirection of external data network (3G modem in ppp0) tointer-access point (wireless modem in wlan0) and vice versa, for all connecteddevices. This can be done by setting specific rules for NAT. EnableIP forwarding for editing the /etc/sysctl.conf pi@raspberrypi ~ $ nanoupdate-rc.d /etc/sysctl.confnet.ipv4.ip_forward = 1 Set up the necessary rules for routing iptables pi@raspberrypi ~ $ iptables -t nat -A POSTROUTING -o ppp0 -jMASQUERADE pi@raspberrypi ~ $ iptables -AFORWARD -i -o ppp0 -m state wlan0 --state RELATED, ESTABLISHED -j ACCEPT pi@raspberrypi ~ $ iptables -AFORWARD -i wlan0 -o ppp0 -j accep Save the rules created in iptables to a file pi@raspberrypi ~ $ sh -ciptables-save> /etc/iptables.ap In each boot is necessary to restore the rules ofiptables. This can be done automatically by adding the interfaces file acommand to restore iptables, which has already made some steps back. pi@raspberrypi ~ $ iptables-restore up</etc/iptables.ap 5. The watchdog As I said in the beginning, I decided to add a watchdogbecause, depending on the modem signal, the hotspot drops and then need to berestarted. The RPi does not have a restart button and so I had to turn off / onthe device all the times that it stopped to work. Using a watchdog, it waspossible to do a more friendly restart automatically and avoiding a completereboot.The watchdog is configured in crontab to check thepppd process each 1 minute and if