1

My laptop is connected to internet via wireless connection (which requires to setup a static IP). However my windows phone does not have this option, and hence I need to share the wireless connection from my PC (Ubuntu 15.04). Is there any way to do this?

user297855
  • 21
  • 2
  • I think this question is already out there : Maybe you should try 1st answer http://askubuntu.com/questions/72989/how-to-share-my-wifi-internet-via-wifi – shreyans800755 Jun 02 '15 at 06:55

1 Answers1

0

Yes, but this will require either buying a second wireless network card (or plugging into ethernet). This is because you will need one card to serve as an input connection. (Most, if not all, WiFi cards can't handle imputing and outputting a wireless signal at the same time.) Then, using hostapd, you can redirect your wireless card to output a WiFi hotspot.

I learned how to do it from this link: https://nims11.wordpress.com/2012/04/27/hostapd-the-linux-way-to-create-virtual-wifi-access-point/

You may need to play with the settings a little bit though to get them working.

Here are my settings and scripts:

hostapd.conf:

interface=wlan0
driver=nl80211
ssid=NETWORK_NAME
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=3
wpa_passphrase=PASSWORD
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

initSoftAp:

#!/bin/bash
#make sure these services aren't running
echo Killing hostapd
killall hostapd >/dev/null 2>&1
echo Killing DHCPD
killall dhcpd >/dev/null 2>&1
#turn off wifi stuffs
rfkill unblock wlan
nmcli nm wifi off
#Initial wifi interface configuration
ifconfig $1 up 10.0.0.1 netmask 255.255.255.0
sleep 2
###########Start DHCP, comment out / add relevant section##########
#Thanks to Panji
#Doesn't try to run dhcpd when already running
if [ "$(ps -e | grep dhcpd)" == "" ]; then
dhcpd $1 &
fi
###########
#Enable NAT
iptables --flush
iptables --table nat --flush
iptables --delete-chain
iptables --table nat --delete-chain
iptables --table nat --append POSTROUTING --out-interface $2 -j MASQUERADE
iptables --append FORWARD --in-interface $1 -j ACCEPT

#Thanks to lorenzo
#Uncomment the line below if facing problems while sharing PPPoE, see lorenzo's comment for more details
#iptables -I FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu

sysctl -w net.ipv4.ip_forward=1
#start hostapd
hostapd hostapd.conf
trap ' ' INT
echo Killing DHCPD
killall dhcpd >/dev/null 2>&1
echo Killing hostapd
killall hostapd >/dev/null 2>&1
echo Exiting