Linux сетевой мост wifi

How to bridge a wireless interface with another wireless interface (both on the same computer)?

Ubuntu 14.04 Basically I am trying to accomplish the following setup — wireless internet —> wlan0 of Ubuntu computer «bridged to» wlan1 of same Ubuntu computer —> device with wifi The reason for this setup is that the wireless internet is a WPA2 Enterprise network which my device with wifi cannot connect to. (The device with wifi also cannot connect to peer-to-peer networks or ad-hoc networks.) Also, the wireless internet source has no whitelist / blacklist and therefore there is no issue with it seeing the device’s MAC address (if necessary), and no issue with it assigning an IP address to the device (if necessary). It is the device that has an issue with WPA2 Enterprise authentication. [EDIT — As the device cannot successfully authenticate, the wireless internet source is NOT likely to assign an IP address to the device, and also likely to take issue with seeing the device’s MAC address.] wlan0 is an Intel wireless chipset / interface which cannot be set to either access point mode or master mode, and therefore is used to connect to the WPA2 Enterprise internet source. wlan1 is to be set to access point mode. Obviously, the «bridge» between wlan0 and wlan1 is not meant to be wireless, as both are on the same computer. (1) I believe brctl cannot bridge a wireless interface ( wlan0 ) to another wireless interface ( wlan1 ). Is this correct? (2) If brctl cannot be used, can I still use hostapd ? (3) If brctl cannot be used, what should I be looking for to accomplish the setup described above? (4) Would any of the following be a part of the solution to my problem — (a) dnsmasq to serve DHCP (b) hostapd (c) static IP address (for wlan1 . ) (for the device connected to wlan1 ??) (d) NAT (Network Address Translation) (e) iptables (f) IP Masquerade (g) sudo iw set dev wlan0 4addr on (h) WDS (wireless distribution system) (i) IP Forwarding ? Thank you.

2 Answers 2

(1) I believe brctl cannot bridge a wireless interface (wlan0) to another wireless interface (wlan1). Is this correct?

The requirement here is that all interfaces must be able to send packets with any source MAC address, and receive packets with any destination MAC (not just the device’s own).

Читайте также:  Юсб вай фай антенна своими руками

Wi-Fi AP interfaces can be bridged just fine (most «wireless routers» in fact have a plain Linux bridge between AP and Ethernet). Station-mode interfaces, however, cannot. So you can bridge wlan1 but not wlan0.

There’s a way around it – the «4addr» mode aka «WDS» mode, which adds an extra MAC address field to Wi-Fi frames. You can enable it via iw , as long as your Wi-Fi driver supports it. Once enabled, you will be able to bridge wlan0 as well.

However, for security reasons, many APs don’t allow 4addr mode by default. (Some have a general toggle, some have a MAC-based whitelist.) Will it work with your university AP? Try it and see.

(Another workaround is «arpnat» – like NAT but applied to MAC addresses – but it can confuse DHCP servers, and it’s not supported by regular Linux anyway. Some APs, like PicoStation, support it in station mode.)

(2) If brctl cannot be used, can I still use hostapd?

Depends on your Wi-Fi driver. Most of them should support AP mode nowadays, but not all do. Use iw phy0 info , iw phy1 info to find out.

(3) If brctl cannot be used, what should I be looking for to accomplish the setup described above?

The most common alternative approach would be IP NAT (masquerading) using iptables.

In some cases, regular routing (without NAT) would also work.

(4) Would any of the following be a part of the solution to my problem

(a) dnsmasq to serve DHCP (b) hostapd (c) static IP address (for wlan1 . ) (for the device connected to wlan1 ??) (d) NAT (Network Address Translation) (e) iptables (f) IP Masquerade (g) sudo iw set dev wlan0 4addr on (h) WDS (wireless distribution system) (i) IP Forwarding ?

yes, no, no, yes, maybe, maybe, what, uh, are you just throwing assorted terms here?

Источник

Настройка сети в Linux с помощью netplan

Обновлено

Обновлено: 16.02.2023 Опубликовано: 31.10.2019

Начиная с Ubuntu 18.04 конфигурирование сети выполняется с помощью утилиты netplan. В других системах на базе deb, например, Debian, она может быть установлена командой:

Конфигурационный файл

Файл для настройки сети находится в каталоге /etc/netplan/. Имя файла может быть любым, на конце должно быть расширение yaml, например:

Читайте также:  Устройства вай фай связи

* чаще всего, это файл 50-cloud-init.yaml или 01-netcfg.yaml. YAML представляет из себя текстовый формат файла. Вложенные параметры должны иметь отступы табуляциями или пробелами, количество которых имеет важное значение (если поставить лишний пробел у одного из нескольких параметров, мы получим сообщение об ошибке «expected mapping»).

Простая настройка сети

Разберем пример настройки 3-х сетевых интерфейсов. Два из них будут с IP-адресами назначенными вручную (static IP), один — по DHCP. Приводим файл к следующему виду:

network:
version: 2
renderer: networkd
ethernets:
ens3:
dhcp4: true
ens7:
dhcp4: no
addresses: [192.168.122.195/24]
routes:
#- to: 0.0.0.0/0
— to: default
via: 192.168.122.1
mtu: 1500
nameservers:
addresses: [8.8.8.8, 77.88.8.8]
search: [ dmosk.local ]
ens9:
dhcp4: no
addresses: [192.168.1.10/24, 192.168.1.20/24]
nameservers:
addresses:
— 8.8.8.8
— 77.88.8.8
search: [ dmosk.local, dmosk.ru ]

  • version — версия YAML. На момент обновления статьи, была 2.
  • renderer — менеджер сети (networkd или NetworkManager).
  • ethernets — настройка сетевых адаптеров ethernet.
  • ens3, ens7, ens9 — настройки для соответствующих сетевых адаптеров. В данном примере мы настраиваем 3 сетевых адаптера.
  • dhcp4 — будет ли получать сетевой адаптер IP-адрес автоматически. Возможны варианты yes/true — получать адрес автоматически; no/false — адрес должен быть назначен вручную.
  • addresses — задает IP-адреса через запятую.
  • routes — настройка маршрутов. Для шлюза по умолчанию используем опцию и значение to: default. Ранее использовалась директива gateway4, но теперь она считается устаревшей (при применении настройки с ней система вернет предупреждение gateway4 has been deprecated, use default routes instead). Также обратите внимание на вариант с 0.0.0.0 — в более ранних версиях системы вариат с default выдаст ошибку, и нужно использовать конфигурацию с четыремя нулями.
  • mtu — при желании, можно задать значение MTU.
  • nameservers — настройка серверов имен (DNS).
  • nameservers addresses — указываем серверы DNS. Обратите внимание на разный формат записи для ens7 и ens9. Приемлемы оба варианта.
  • nameservers search — дописывает окончание домена, если мы обращаемся к узлу сети только по его имени. Стоит обратить внимание, что мы можем указать несколько доменов через запятую.

Применение настроек

Для применения настроек необходимо запустить команду netplan. Ее синтаксис:

Для проверки нашего конфигурационного файла вводим:

Источник

Мост между wifi и ethernet

Это работает, только если компьютер является точкой доступа, или если используется нестандартный 4-адресный режим wi-fi. Причина: конфликт на уровне протокола 802.11.

В обычном Ethernet’е различие mac-адреса официального получателя пакета и mac-адреса сетевой карты, которая его получает по факту (т.е. порта моста), проблемой не является. В wi-fi прием или отправка «чужих» пакетов невозможен, т.к. в заголовке есть место только для трех адресов из четырех (bssid, клиент, отправитель, получатель).

Читайте также:  Wi fi от ростелеком карта покрытия

Подписался. Тоже хочу wifi в мост, только не с ethernet, а с tap, но это не важно наверное. Пробовал делать 4addr on, wifi просто отваливалась. Наверное на стороне точки тоже что-то сделать нужно.

Lavos ★★★★★ ( 02.11.16 13:48:36 MSK )
Последнее исправление: Lavos 02.11.16 13:49:01 MSK (всего исправлений: 1)

Да, на точке тоже надо включить четырехадресный режим.

Альтернативное решение — не делать честный мост, а настроить proxyarp. Копать в сторону parprouted.

У мну openwrt, оно наверное умеет. Но у меня ещё есть телефон с android вместо os, он сможет в 4addr?

с android вместо os, он сможет в 4addr?

Источник

How to create wireless bridge connection with nmcli

Is it possible to create a wireless bridge connection (br0) for any wireless nic (wlan0) using nmcli tool.? End of the day system should have master bridge-connection(br0) that uses wlan0 nic as it’s bridge-slave.

2 Answers 2

If your goal is to create a WiFi Hotspot/Access Point and bridge it to your ethernet connection, you can do that using nmcli .

If your computer is connected to a router via an ethernet cable you will be able to use your computer as a WiFi hotspot, your WiFi AP clients can get their IPs directly from the router and neatly be part of the same network as the other devices.

First create your bridge connection:

nmcli connection add con-name 'My Bridge' ifname br0 type bridge ipv4.method auto ipv6.method disabled connection.autoconnect yes stp no 

Now add your Ethernet card (eth0) as a slave to the bridge:

nmcli connection add con-name 'My Ethernet' ifname eth0 type bridge-slave master 'My Bridge' connection.autoconnect yes 

Now create your WiFi Access Point and add it as a slave to the bridge. The syntax for the WiFi slave is a bit different:

nmcli connection add con-name 'My Hotspot' ifname wlan0 type wifi slave-type bridge master 'My Bridge' wifi.band a wifi.channel 153 wifi.mode ap wifi.ssid my-hotspot-ssid 

It will create a working hotspot without a password.

There is actually a bug under version 1.22.10 shipped with Ubuntu 20.04 that prevents using WPA2. It creates the network but clients are unable to authenticate. This is the bug report. It is reportedly fixed in version 1.30 of NetworkManager, if you have such version, you could try to go for WPA2 with wifi-security.key-mgmt wpa-psk (or maybe WPA3 with wifi-security.key-mgmt sae ) and setting the password with wifi-sec.psk yourpassword .

Источник

Оцените статью
Adblock
detector