Creating wifi hotspot or access point on a single interface

I am trying to create a WiFi hotspot or an access point on Opensuse Kde 12.3.

I found out a software called hostapd ( http://nims11.wordpress.com/2012/04/27/hostapd-the-linux-way-to-create-virtual-wifi-access-point/ ) which lets you create hotspot but it requires two interfaces. One connected to the internet and the other on which you want to create the access point . The problem I have is that I don’t have Ethernet connection. The wlan interface is being used to connect to the internet.
I even tried the yast tool for masquerading ip and routing but it too requires 2 interfaces ( one in external mode and another in lan )

Is there any way to create the hotspot on the same interface that is connected to the Internet (like the software connectify does on Windows) ?
I was thinking of creating a virtual interface (like the one airmon-ng creates to monitor wifi) and use it as the second interface. Is this possible?

Any help will be appreciated.

I can’t understand what you want to do and what you have. On your PC do you have a 1 hard wired network and 1 Wi-Fi connection? How does your Internet arrive to your PC? How do you expect to provide Ineternet to any other PC’s?

Thank You,

Okay… Basically i am trying to make a wifi client and an access point on the same interface. This works on Windows by using a software called “Connectify”, where you can share internet by creating a hotspot on the same interface which is connected to the Wifi. (Connectify - Turn your PC into a Wi-Fi Hotspot and Get Faster Internet) . So my wlan0 is connected to the wifi. Here is what i have done up till now :
I have created 2 interfaces using iw :

iw phy phy0 interface add mySta type station #to act as station
iw phy phy0 interface add myAcc type __ap #to act as access point

I have given one interface seperate mac address :

ifconfig myAcc hw ether A4:17:FE:6E:00:53
ifconfig myAcc 192.168.27.1 up

Now using the software called Hostapd ( link in orignal post ), I have converted the myAcc into an access point and i have used dnsmasq to provide ip addresses to the connecting clients. At this point, 2 different interfaces are shown in the iwconfig and ifconfig. My client is able to detect the hotspot, connect to it, gain IP address and is even able to ping the host.

Now the main problem i am facing is to connect the other interface to the wifi. After turning the interface up, it is able to scan the networks using iwlist, I am able to set the essid. But still it does not connect to the network. When i use dhclient, it doesn’t show anything for a while and then gives some weird errors like File Not Found. If i don’t start the hostapd software, it connects to the wifi but then i am not able to start hostapd as it says device is busy.

Any suggestions ?

On 07/06/2013 12:16 AM, adityap174 wrote:
>
> jdmcdaniel3;2569733 Wrote:
>> I can’t understand what you want to do and what you have. On your PC do
>> you have a 1 hard wired network and 1 Wi-Fi connection? How does your
>> Internet arrive to your PC? How do you expect to provide Ineternet to
>> any other PC’s?
>>
>> Thank You,
>
> Okay… Basically i am trying to make a wifi client and an access point
> on the same interface. This works on Windows by using a software called
> “Connectify”, where you can share internet by creating a hotspot on the
> same interface which is connected to the Wifi. (‘Connectify - Turn your
> PC into a Wi-Fi Hotspot and Get Faster Internet’
> (http://www.connectify.me/)) . So my wlan0 is connected to the wifi.
> Here is what i have done up till now :
> I have created 2 interfaces using iw :
>
>
> Code:
> --------------------
> iw phy phy0 interface add mySta type station #to act as station
> iw phy phy0 interface add myAcc type __ap #to act as access point
>
> --------------------
>
>
>
> I have given one interface seperate mac address :
>
>
> Code:
> --------------------
> ifconfig myAcc hw ether A4:17:FE:6E:00:53
> ifconfig myAcc 192.168.27.1 up
>
> --------------------
>
>
> Now using the software called Hostapd ( link in orignal post ), I
> have converted the myAcc into an access point and i have used dnsmasq to
> provide ip addresses to the connecting clients. At this point, 2
> different interfaces are shown in the iwconfig and ifconfig. My client
> is able to detect the hotspot, connect to it, gain IP address and is
> even able to ping the host.
>
> Now the main problem i am facing is to connect the other interface to
> the wifi. After turning the interface up, it is able to scan the
> networks using iwlist, I am able to set the essid. But still it does not
> connect to the network. When i use dhclient, it doesn’t show anything
> for a while and then gives some weird errors like File Not Found. If i
> don’t start the hostapd software, it connects to the wifi but then i am
> not able to start hostapd as it says device is busy.

I know what you want to do, but not why. Most users of hostapd do not have an
access point, and they want to create an access point on a computer with a wired
connection. Obviously, you have an access point. Why not connect the client to
it directly?

I think the step you are missing is the forwarding of packets from myAcc to the
external interface, namely wlan0. Similarly, you will probably need to forward
the packets to and from mySta.

@lwfinger
I am avoiding quotation as it has become too long.

I want to connect my android device to the internet. As the signal is is not strong enough and i have a low end device it is not able to detect the signal. I am able to access the net through my laptop. I can’t use adhoc as android devices can’t connect to it. Hence all this.

iptables --table nat --append POSTROUTING --out-interface mySta -j MASQUERADE
iptables --append FORWARD --in-interface myAcc -j ACCEPT

Using these two commands i’ll be able to provide net connection to the clients, through my laptop after both the access point and the station have been established. But the problem is that once the hostapd is started, my station interface is not able to connect to the network. It is able to detect the connections, i am able to set the essid but it fails to acquire ip address. If i connect the station to the internet first, hostapd won’t start as it says the device is busy, failed to set beacon parameters.

On 07/06/2013 02:46 PM, adityap174 wrote:
>
> @lwfinger
> I am avoiding quotation as it has become too long.
>
> I want to connect my android device to the internet. As the signal is
> is not strong enough and i have a low end device it is not able to
> detect the signal. I am able to access the net through my laptop. I
> can’t use adhoc as android devices can’t connect to it. Hence all this.
>
> iptables --table nat --append POSTROUTING --out-interface mySta -j
> MASQUERADE
> iptables --append FORWARD --in-interface myAcc -j ACCEPT
>
> Using these two commands i’ll be able to provide net connection to the
> clients, through my laptop after both the access point and the station
> have been established. But the problem is that once the hostapd is
> started, my station interface is not able to connect to the network. It
> is able to detect the connections, i am able to set the essid but it
> fails to acquire ip address. If i connect the station to the internet
> first, hostapd won’t start as it says the device is busy, failed to set
> beacon parameters.

On my hostapd setup, 3 iptables commands are needed:

$IPTABLES -t nat -A POSTROUTING -o $NET_EXT -j MASQUERADE
$IPTABLES -A FORWARD -i $NET_EXT -o $NET_AP -m state
–state RELATED,ESTABLISHED -j ACCEPT
$IPTABLES -A FORWARD -i $NET_AP -o $NET_EXT -j ACCEPT

Enable packet forwarding

echo 1 > /proc/sys/net/ipv4/ip_forward

You have my first and third. The second one of mine handles the case where an
external site responds to something from an AP client. This would include
getting a web page.

Have you enabled forwarding?

Yes. forwarding is enabled. I forgot to mention it in the post. Actually i don’t have much experience with iptables command. I was just following a tutorial. But all this comes after connecting the station interface to the internet. I am stuck at this step. Once the connection is established, i’ll do all this forwarding so that my clients are able to connect to the station’s internet.

Thanks for all your help :slight_smile:
the problem was with mac address. I started the access point interface, gave it a mac address. Then after running hostapd, added the station interface, gave it a different mac address and connected it to the network and gave the station’s ip address as the default gateway of the clients through dnsmasq. Now everything is working properly.