Создание точки доступа WiFi на едином интерфейсе в Linux

27278
adityap174

Я пытаюсь создать точку доступа WiFi или точку доступа на моем ноутбуке с Linux. Я использую Opensuse Kde 12.3.

Я обнаружил программное обеспечение, hostapdкоторое позволяет вам создавать точки доступа, но требует двух интерфейсов. Один подключен к Интернету, а другой - для создания точки доступа ( учебное пособие здесь ). У меня проблема в том, что у меня нет соединения Ethernet. wlanИнтерфейс используется для подключения к Интернету.

Есть ли способ создать точку доступа на том же интерфейсе, который подключен к Интернету (как программное обеспечение connectctify в Windows)? Я думал о создании виртуального интерфейса (как тот, который airmon-ngсоздается для мониторинга Wi-Fi) и использовать его в качестве второго интерфейса. Это возможно?

ОБНОВИТЬ

Вот что я смог сделать до сих пор:

1) Создайте 2 интерфейса (один как станция, а другой как точка доступа)

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

2) Дайте им отдельный Mac ID

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

3) запустите hostapd на интерфейсе myAcc

4) запустите dnsmasq для предоставления IP-адреса подключаемым устройствам

Все это работает. Устройства могут подключиться к этой сети и получить IP-адрес. Следующим шагом является предоставление ip маскарадинга

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

Но интерфейс mySta теперь не может подключиться к Интернету. Он может получить Essid, но не может получить IP-адрес.

Команда dhclient mySta не показывает никаких сообщений и через некоторое время выдает ошибку:

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

Может кто-нибудь выяснить, как получить IP-адрес?

13
Вы пробовали с "поддержкой фиктивного сетевого драйвера" (драйвер ядра) в качестве модуля. Я не могу помочь вам больше, потому что я не знаю openSUSE. Но я вижу, что есть ошибки от версии 11 и выше, когда она собирается с Yast. Так что будьте осторожны. Diblo Dk 10 лет назад 0
Конечно, я могу вам помочь, если это можно сделать теми же способами (настройка ядра, настройка сети), что и в Gentoo, Debian или Ubuntu. Diblo Dk 10 лет назад 0
Любая помощь будет оценена. Я не использую инструменты Yast как таковые. Конфигурации были из учебника по Ubuntu. Файловая система и конфигурации практически одинаковы. adityap174 10 лет назад 0
Какая у вас версия ядра? Diblo Dk 10 лет назад 0
Ядро: x86_64 Linux 3.7.10-1.16-рабочий стол adityap174 10 лет назад 0
Вы должны помнить, чтобы рассказать, какие проблемы вы решили самостоятельно, поэтому ответ может быть обновлен. :) Diblo Dk 10 лет назад 0
Снова тот же вопрос: http://superuser.com/questions/639479/linux-share-wireless-connection-through-the-same-wireless-interface/639496#639496 И снова: http://superuser.com/questions/ 649220 / A-WiFi-ар-с-одной NIC / 656574 # 656574 imz -- Ivan Zakharyaschev 10 лет назад 0

3 ответа на вопрос

8
adityap174

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
прямо скажем, WTF hostapd :) Diblo Dk 10 лет назад 0
Можете ли вы обновить свой ответ с точными шагами, которые вы сделали. Это определенно ответ, который я хотел бы сохранить. Diblo Dk 10 лет назад 0
обновил :) хочешь больше подробностей? adityap174 10 лет назад 0
Классный способ обойти проблему :) Diblo Dk 10 лет назад 0
Какой ключ / чипсет вы использовали? Alvin 9 лет назад 0
@ adityap174 Привет, я все еще не уверен, как ты настроил? Можете ли вы проверить мой вопрос https://unix.stackexchange.com/questions/411478/hostapd-on-single-interface Veerendra 6 лет назад 0
2
Diblo Dk

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

Спасибо за такое подробное объяснение. Я попробовал этот метод. Я смог создать интерфейс dummy0 и начать загрузку. Но как сделать беспроводной интерфейс? iwconfig дает: dummy0 никаких беспроводных расширений. hostapd не работает с этим. Выдает ошибку: сбой инициализации драйвера nl80211 adityap174 10 лет назад 0
Да, проблема в том, что у вас конфликт IP. Но это можно сделать с помощью псевдо-модуля (назначить несколько IP-адресов). Дайте мне немного времени, чтобы найти его для вашей системы. Diblo Dk 10 лет назад 0
Вы также можете посмотреть здесь https://www.linode.com/wiki/index.php/Configure_Static_IPs#OpenSUSE Возможно, вы увидите, как это сделать с wlan :) Diblo Dk 10 лет назад 0
проблема в том, что вы получите конфликт IP * Diblo Dk 10 лет назад 0
1
Diblo Dk

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

даже это не работало с hostapd. Это выдало ту же ошибку: не удалось открыть файл / sys / class / net / dummy0 / phy80211 / name: нет такого файла или каталога с dummy0 и не удалось открыть файл / sys / class / net / wlan0: 0 / phy80211 / name: Нет такого файла или каталога с виртуальным интерфейсом. Спасибо за вашу помощь. :) Проблема была с Mac-адресом. Я проголосовал за ваши ответы, и я публикую решение для других. adityap174 10 лет назад 0

Похожие вопросы