HI all,
I am trying to share my laptop net connection with my android devices
via wi-fi. The set-up used to work in Fedora 17. I am now trying the
same on Fedora 18. I get an IP on the device, but am not able to browse
on the device.
Can anyone suggest what is going wrong? Similar rules for libvirt are
working to allow NAT in virtual machines.
Here is the script that tries to set-up stuff.
#!/bin/bash
#
# setup wlan0 with hostapd and firewall masquerade rules
# to enable devices to use existing internet connection
# is wlan0 usable?
# try to assign the interface an IP address
# if we get an error message and error code,
# prompt for wifi button press
echo "Trying to set up wlan0 interface ... "
echo "+ sudo ifconfig wlan0 192.168.2.1 netmask 255.255.255.0 up "
sudo ifconfig wlan0 192.168.2.1 netmask 255.255.255.0 up
IFCFG_EXIT_CODE="$?"
if [ "IFCFG_EXIT_CODE" -ne 0 ]
then
echo "Please press the wifi button (F12) to activate the wireless
lan interface and try again" 1>&2
exit 1
fi
# still here, then wlan0 has an IP address set then
# our desired IP is on a "net" line of ip command output
VERIFY_IP="$(ip addr show dev wlan0 | grep "net " | cut -c 10-20)"
if [ "$VERIFY_IP" != "192.168.2.1" ]
then
echo "Uh-oh! This script did a boo-boo while setting up IP address
for wlan0!" 1>&2
exit 2
else
echo "... done setting IP address on wlan0."
fi
# Time to start hostap daemon
echo "Trying to start HostAP Daemon ..."
echo "+ sudo systemctl start hostapd.service"
sudo systemctl start hostapd.service
HOSTAPD_STATUS="$?"
if [ $HOSTAPD_STATUS -ne 0 ]
then
echo "Sorry! Could not start HostAP Daemon!" 1>&2
exit 3
else
echo "... done starting HostAP daemon."
fi
# Time to start dhcpd daemon
echo "Trying to start dhcp daemon ..."
echo "+ sudo systemctl start dhcpd.service"
sudo systemctl start dhcpd.service
DHCPD_STATUS="$?"
if [ $DHCPD_STATUS -ne 0 ]
then
echo "Sorry! Could not start dhcpd Daemon!" 1>&2
exit 4
else
echo "... done starting dhcpd daemon."
fi
# Time to set up firewall rules
echo "Setting up firewall to allow internet connection to our client
devices..."
# dhcp
sudo iptables -I INPUT -i wlan0 -p tcp --dport 67 -j ACCEPT
sudo iptables -I INPUT -i wlan0 -p udp --dport 67 -j ACCEPT
# dns
sudo iptables -I INPUT -i wlan0 -p tcp --dport 53 -j ACCEPT
sudo iptables -I INPUT -i wlan0 -p udp --dport 53 -j ACCEPT
# forwards
sudo iptables -I FORWARD -i wlan0 -o wlan0 -j ACCEPT
sudo iptables -I FORWARD -i wlan0 -s 192.168.2.0/24 -j ACCEPT
sudo iptables -I FORWARD -o wlan0 -d 192.168.2.0/24 -m conntrack
--ctstate RELATED,ESTABLISHED -j ACCEPT
# nat
sudo iptables -t nat -I POSTROUTING -s 192.168.2.0/24 ! -d
192.168.2.0/24 -j MASQUERADE
# some firewalld stuff
sudo firewall-cmd --zone=public --add-interface=wlan0
Thanks,
Nandan