Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

I found out a software called hostapd 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 (tutorial here) . The problem I have is that I don't have Ethernet connection. The wlan interface is being used to connect to the internet.

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?

UPDATE

Here's what i have been able to do up till now :

1) Create 2 interfaces ( one as station and the other as an access point )

  iw phy phy0 interface add mySta type station
  iw phy phy0 interface add myAcc type __ap

2) Give them seperate Mac ID

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

3) start hostapd on the myAcc interface

4) start dnsmasq to provide ip address to the connecting devices

All of this works. Devices are able to connect to this network and obtain Ip Address. The next step is to provide ip masquerading

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

But the mySta interface now fails to connect to the internet. It is able to obtain the Essid but it cannot obtain the ip address.

The command dhclient mySta doesn't show any message and after some time gives the error :

ls: cannot access /var/run/netconfig//mySta/: No such file or directory

Can someone figure out how to obtain the ip address ?

share|improve this question
    
Have you tried with "Dummy net driver support" (Kernel driver) as module. I can not help you more than that because I do not know openSUSE. But I can see that there are errors reported from version 11 and higher when it is built with Yast. So be careful. –  Diblo Dk Jul 5 '13 at 14:46
    
I can of course help you, if it can be done in the same ways (Kernel config, network setup) as in Gentoo, Debian or Ubuntu. –  Diblo Dk Jul 5 '13 at 14:52
    
Any help will be appreciated. I am not using the Yast tools as such. The configurations were from a tutorial on Ubuntu. The file system and the configurations are almost the same. –  adityap174 Jul 5 '13 at 15:42
    
What is your kernel version? –  Diblo Dk Jul 5 '13 at 18:21
    
Kernel: x86_64 Linux 3.7.10-1.16-desktop –  adityap174 Jul 5 '13 at 20:55
show 2 more comments

3 Answers

up vote 3 down vote accepted

For anyone else facing this problem, 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.

As pointed out by Diblo Dk, you could use virtual and dummy interfaces but hostapd wasn't working with them. I don't know why.

Here are the steps :

  1. turn off network manager service as it interferes with virtual interfaces
  2. turn down wlan0 using ifconfig wlan0 down
  3. create access point interface using iw command (type __ap), assign it a different mac and ip address
  4. turn on hostapd at this access interface
  5. use dnsmasq to assign the connecting clients at this interface, ip addresses and give the default gateway as the ip of the station interface to be created
  6. turn on dnsmasq at the access interface. Now the client will be able to connect to the access point and obtain ip addresses.
  7. create new interface (type station) assign it separate mac address and connect it to the network by assigning essid and using dhclient to obtain ip address.
  8. if necessary perform ip masquerading through iptables command
share|improve this answer
    
to put it bluntly, WTF hostapd :) –  Diblo Dk Jul 7 '13 at 10:43
    
Can you update your answer with the exact steps you made. This is definitely an answer I'd like to save. –  Diblo Dk Jul 7 '13 at 10:53
    
updated :) want more details ? –  adityap174 Jul 7 '13 at 17:49
    
Cool way to get around the problem :) –  Diblo Dk Jul 7 '13 at 20:09
add comment

Setup a dummy network

1 Open the console

su -

2 See if you have a dummy driver

modprobe -l | grep /net/dummy.ko

(!) If you do not have a dummy driver, go to "Create kernel module".

3 Load dummy driver

modprobe dummy

(!) Do not add it to startup if it fails.

4 Test dummy0 by putting it up

ifconfig dummy0 10.246.75.1 netmask 255.255.255.0 broadcast 10.246.75.255 up

ifconfig

It will give you a similar output.

dummy0  Link encap:Ethernet  HWaddr 00:2D:32:3E:39:3B
        inet addr:10.246.75.1  Bcast:10.246.75.255  Mask:255.255.255.0
        ...

5 Add dummy driver to startup

Edit kernel sys file.

nano /etc/sysconfig/kernel

and add "dummy" to MODULES_LOADED_ON_BOOT.

MODULES_LOADED_ON_BOOT = "..."

Ex. MODULES_LOADED_ON_BOOT = "vmcp dummy".

6 Configure the network settings for dummy0

Create ifcfg-dummy0 file.

nano /etc/sysconfig/network/ifcfg-dummy0

Add to ifcfg-dummy0 file:

# Configuration for dummy0
BOOTPROTO=static

# This line ensures that the interface will be brought up during boot.
STARTMODE=onboot

# dummy0 - This is the main IP address that will be used for most outbound connections.
# The address, netmask and gateway are all necessary. The metric is not necessary but
# ensures you always talk to the same gateway if you have multiple public IPs from
# different subnets.
IPADDR=10.246.75.1
NETMASK=255.255.255.0
BROADCAST=10.246.75.255
GATEWAY=10.246.75.1



Create kernel module

1 First installing the necessary things

Open YaST.

Navigate to Software -> Software Management.

Tick:

Development 

[X] Base Development
[X] Linux Kernel Development
[X] C/C++ Development

2 Back to the console and navigate to the kernel source

cd /usr/src/linux

3 Import the current kernel configuration

zcat /proc/config.gz > .config

4 Open kernel menuconfig

make menuconfig

5 Add Dummy net driver support

Navigate to Device Drivers -> Network device support

* Network core driver support
    M Dummy net driver support

(!) If you have an asterisk next to "Network core driver support" you can skip step 7 and 9.

6 Compile the kernel

make -j(n+1)

Where (n+1) = number of CPU cores plus one used to speed up the compile. For four cores use make -j5.

7 Install the new kernel

make install

8 Install modules

make modules_install

9 Load the new kernel

reboot



Defining a VIPA (The part about loading module and ifcfg-dummy0): http://wiki.linuxvm.org/wiki/Defining_a_VIPA
Configure Static IPs: https://www.linode.com/wiki/index.php/Configure_Static_IPs
openSUSE 12.3 and Installing New Linux Kernel Versions from kernel.org: http://forums.opensuse.org/blogs/jdmcdaniel3/opensuse-installing-new-linux-kernel-versions-134/
OpenSUSE 11.2 - How to compile a Kernel for Newbies: http://linuxtweaking.blogspot.dk/2010/04/opensuse-112-how-to-compile-kernel-for.html

share|improve this answer
    
Thanks for such a detailed explanation. I tried this method. I was able to create dummy0 interface and start in on boot. But how do you make it a wireless interface ? iwconfig gives : dummy0 no wireless extensions. hostapd doesn't work with this. It gives error : nl80211 driver initialization failed –  adityap174 Jul 6 '13 at 19:59
    
Yes, the problem is that you have an IP conflict. But it could be done with Pseudo module (Assign multiple IP addresses). Give me some time to look it up for your system. –  Diblo Dk Jul 6 '13 at 21:30
    
You can also look here linode.com/wiki/index.php/Configure_Static_IPs#OpenSUSE It could be that you can see how to do with wlan :) –  Diblo Dk Jul 6 '13 at 21:34
    
, the problem is that you will get an IP conflict* –  Diblo Dk Jul 6 '13 at 22:09
add comment

Create virtual interface

Create ifcfg-wlan0:0 file

nano /etc/sysconfig/network/ifcfg-wlan0:0

Add to ifcfg-wlan0:0 file:

DEVICE=wlan0:0

# Configuration for wlan0:0
ONBOOT=yes

# This line ensures that the interface will be brought up during boot.
BOOTPROTO=static

# wlan0:0 - This is the main IP address that will be used for most outbound connections.
# The address, netmask and gateway are all necessary. The metric is not necessary but
# ensures you always talk to the same gateway if you have multiple public IPs from
# different subnets.
IPADDR=10.246.75.1
NETMASK=255.255.255.0
BROADCAST=10.246.75.255
GATEWAY=10.246.75.1

The commands to activate interface

ifup wlan0:0

Note: Shutting down the main interface also shuts down all its aliases too. Aliases can be shutdown independently of other interfaces.

Check if the interface works

ifconfig

It will give you a similar output.

wlan0:0  Link encap:Ethernet  HWaddr 00:2D:32:3E:39:3B
         inet addr:10.246.75.1  Bcast:10.246.75.255  Mask:255.255.255.0
         ...

http://forums.opensuse.org/english/get-technical-help-here/network-internet/461132-os-11-4-network-manager-default-connection-can-handle-virtual-interfaces.html#post2350426

share|improve this answer
    
even this was not working with hostapd. It gave the same error : Could not open file /sys/class/net/dummy0/phy80211/name: No such file or directory with dummy0 and Could not open file /sys/class/net/wlan0:0/phy80211/name: No such file or directory with the virtual interface. Thanks for all your help. :) The problem was with mac address. I have upvoted your answers and i am posting the solution for others. –  adityap174 Jul 7 '13 at 9:10
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.