here another howto for sharing your internet connection from wired ethernet cable or usb thethering to wifi using your computer as an hotspot
overview :
smartphone android device acting as tethering interface, is usb0
wired or cable ethernet interface is eth0
wireless or wifi lan, as WLAN, is wlan0
first, plug and enable your wan interface then regarding what type of interface...
for an usb tethering, ask for a DHCP lease to your phone, after enabled it on your android device :
udhcpc -i usb0
for a cable/wired rj45 interface, as eth0 on your linux system, just do :
udhcpc -i eth0
Now, setup the LAN side, as using the WLAN (for Wireless or Wifi Lan interface) as a router :
ip l set wlan0 up
ip a add 192.168.55.1/24 dev wlan0
so here we have a wlan interface with ip address on it, now let's enable hotspot on it :
- first install hostapd software
- then in /etc/hostapd/hostapd.conf :
interface=wlan0
driver=nl80211
ssid=myhotspot
hw_mode=g
channel=1
auth_algs=1
wpa=3
wpa_passphrase=0987654321
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
wpa_pairwise=CCMP
beacon_int=100
dtim_period=2
max_num_sta=255
rts_threshold=2347
fragm_threshold=2346
then don't forget to install dnsmasq
then edit /etc/dnsmasq.conf :
interface=wlan0
bind-interfaces
domain=example.com
dhcp-option=3,192.168.55.1
dhcp-option=6,192.168.55.1
dhcp-range=192.168.55.10,192.168.55.30,12h
then dont forget to enable routing :
echo 1 > /proc/sys/net/ipv4/ip_forward
then iptables routing :
iptables -t nat -A POSTROUTING -o usb0 -j MASQUERADE
then to start services !
/etc/init.d/dnsmasq start
/etc/init.d/hostapd start
normally, it shoud work itself