Como posso definir o modo de dispositivo via networkd

5

Como posso definir o modo para o dispositivo (por exemplo, monitor / ap para wlan) via networkd deamon no arquivo .link ???

Porque eu quero colocar bridge na rede do dispositivo wlan e não posso fazê-lo até configurá-lo no modo específico.

##################################
# /etc/systemd/network/eth0.link # 
##################################
[Match]
MACAddress=xxxxxxxxxx

[Link]
Description=Top Ethernet Port
Type=ether
Name=eth0
#MACAddressPolicy=persistent 
MACAddress= rewrite mac 
WakeOnLan=off

#####################################
# /etc/systemd/network/eth0.network #
#####################################
[Match]
Name=eth0

[Address]
Address=192.168.0.101/24
Broadcast=192.168.0.101

[Network]
Bridge=br0

###################################
# /etc/systemd/network/br0.netdev #
###################################
[NetDev]
Name=br0
Kind=bridge
MACAddress=set mac

####################################
# /etc/systemd/network/br0.network #
####################################
[Match]
Name=br0

[Address]
Address=192.168.0.100/24
Broadcast=192.168.0.100

[Network]
Description=Default network through bridge
Gateway=192.168.0.1
DHCP=ip4
IPv6PrivacyExtensions=true
DNS=8.8.8.8
DNS=8.8.4.4

[DHCP]
UseDNS=false

[Bridge]

[Route]
#Gateway=192.168.0.1
#Destination=192.168.0.0/24
#Scope=link

###################################
# /etc/systemd/network/at0.link   #
###################################
[Match]
# See: udevadm info /sys/class/net/at0
Type=wlan
OriginalName=wlan0
#MACAddress=
Driver=ath9k

[Link]
Description=Top Wireless Lan Port
Name=at0
Type=wlan
MACAddress= rewrite mac
BitsPerSecond=100M
WakeOnLan=off

####################################
# /etc/systemd/network/at0.network #
####################################
[Match]
Name=at0

[Address]
Address=192.168.0.102/24
Broadcast=192.168.0.102

[Network]
Bridge=br0            <---- THIS FAILS 

#

$ networkctl 
IDX LINK             TYPE               OPERATIONAL SETUP     
  1 lo               loopback           carrier     configured
  2 eth0             ether              routable    configured
  3 at0              wlan               no-carrier  configured
  4 br0              ether              routable    configured


$ networkctl status 
●      State: routable
     Address: 192.168.0.101 on eth0
              192.168.0.102 on at0
              192.168.0.100 on br0
              fe80::cb4:a1ff:fea2:111 on eth0
              fe80::cb4:a1ff:fea2:110 on br0
     Gateway: 192.168.0.1 (Cisco SPVTG) on br0
         DNS: 8.8.4.4
              8.8.8.8

ps.

Eu sei como criar pontes e interfaces através do networkd e como adicionar interfaces para interligar - mas o que eu não sei é como alterar o modo de interface particularmente (nic sem fio) para outro modo sem usar o suplicante wpa ou iw / iwconf

de: link

Wireless adapter

In order to connect to a wireless network with systemd-networkd, a wireless adapter configured with another service such as wpa_supplicant is required. In this example, the corresponding systemd service file that needs to be enabled is [email protected].

Mas eu não quero me conectar! Eu quero fazer ad-hoc - ap

então eu quero:

  • definido para o modo de exemplo para ap / monitor (modo promíscuo)
  • definir wpa essid
  • definir chave wpa

sério, não há como configurar um ponto de acesso sem:

  • solicitante de wpa
  • hostapd

ps. Eu só encontrei maneira de usar o wpa_supplicant como unidade

# create wpa supplicant config for interface at0 
#
    $ nano / cat /etc/wpa_supplicant/wpa_supplicant_at0.conf 

    ctrl_interface=/var/run/wpa_supplicant
    eapol_version=1
    ap_scan=1
    fast_reauth=1
    network={
        ssid="..."
    #psk="..."
    }

# create unit
#
    $ nano /etc/systemd/system/[email protected] 

[Unit]
Description=WPA supplicant (%i)
After=systemd-networkd.service
Requires=systemd-networkd.service
Before=network-online.target
ConditionPathIsSymbolicLink=/sys/class/net/%i

[Service]
Type=forking
ExecStartPre=/sbin/ip link set %i up
ExecStart=/sbin/wpa_supplicant -s -i %i -D nl80211,wext -c/etc/wpa_supplicant/wpa_supplicant_%i.conf -B -P /run/wpa_supplicant.%i.pid
ExecStopPost=/sbin/ip addr flush %i
ExecStopPost=/sbin/ip link set %i down
PIDFile=/run/wpa_supplicant.%i.pid

[Install]
WantedBy=multi-user.target

# reload systemctl daemon 
#
   $ systemctl daemon-reload 

# enable supplicant on interface on boot 
# 
   $ systemctl enable wpa_supplicant@at0

ps2. Eu descobri isso:

link

básico:

Network Topologies

There are two popular network topologies in 802.11 wireless networks. The first topology I discuss is Infrastructure BSS mode, which is the most popular. You encounter Infrastructure BSS wireless >networks in home wireless networks and offices. Later I discuss the IBSS (Ad Hoc) mode. Note that IBSS is not Infrastructure BSS; IBSS is Independent BSS, which is an ad hoc network, discussed later in this section.

Infrastructure BSS

When working in Infrastructure BSS mode, there is a central device, called an Access Point (AP), and some client stations. Together they form a BSS (Basic Service Set). These client stations must first perform association and authentication against the AP to be able to transmit packets via the AP. On many occasions, client stations perform scanning prior to authentication and association, in order to get details about the AP. Association is exclusive: a client can be associated with only one AP in a given moment. When a client associates with an AP successfully, it gets an AID (association id), which is a unique number (to this BSS) in the range 1–2007. An AP is in fact a wireless network device with some hardware additions (like Ethernet ports, LEDs, a button to reset to manufacturer defaults, and more). A management daemon runs on the AP device. An example of such software is the hostapd daemon. This software handles some of the management tasks of the MLME layer, such as authentication and association requests. It achieves this by registering itself to receive the relevant management frames via nl80211. The hostapd project is an open source project which enables several wireless network devices to operate as an AP. Clients can communicate with other clients (or to stations in a different network which is bridged to the AP) by sending packets to the AP, which are relayed by the AP to their final destination. To cover a large area, you can deploy multiple APs and connect them by wire. This type of deployment is called Extended Service Set (ESS). Within ESS deployment, there are two or more BSSs. Multicasts and broadcasts sent in one BSS, which may arrive on a nearby BSS, are rejected in the nearby BSS stations (the bssid in the 802.11 header does not match). Within such a deployment, each AP usually uses a different channel to minimize interference.

IBSS, or Ad Hoc Mode

IBSS network is often formed without preplanning, for only as long as the WLAN is needed. An IBSS network is also called ad hoc network. Creating an IBSS is a simple procedure. You can set an IBSS by running from a command line this iw command (note that the 2412 parameter is for using channel 1):

 iw wlan0 ibss join AdHocNetworkName 2412

Or when using the iwconfig tool, with these two commands:

iwconfig wlan0 mode ad-hoc
iwconfig wlan0 essid AdHocNetworkrName

This triggers IBSS creation by calling the ieee80211_sta_create_ibss() method (net/mac80211/ibss.c). Then the ssid (AdHocNetworkName in this case) has to be distributed manually (or otherwise) to everyone who wants to connect to the ad hoc network. When working with IBSS, you do not have an AP. The bssid of the IBSS is a random 48-bit address (based on calling the get_random_bytes() method). Power management in Ad Hoc mode is a bit more complex than power management in Infrastructure BSS; it uses Announcement Traffic Indication Map (ATIM) messages. ATIM is not supported by mac802.11 and is not discussed in this chapter. The next section describes power save mode, which is one of the most important mechanisms of the mac80211 network stack...

Wireless Modes

You can set a wireless network interface to operate in several modes, depending on its intended use and the topology of the network in which it is deployed. In some cases, you can set the mode with the iwconfig command, and in some cases you must use a tool like hostapd for this. Note that not all devices support all modes. See www.linuxwireless.org/en/users/Drivers for a list of Linux drivers that support different modes. Alternatively, you can also check to which values the interface_modes field of the wiphy member (in the ieee80211_hw object) is initialized in the driver code. The interface_modes are initialized to one or more modes of the nl80211_iftype enum, like NL80211_IFTYPE_STATION or NL80211_IFTYPE_ADHOC (see: include/uapi/linux/nl80211.h). The following is a detailed description of these wireless modes:

  • Modo AP: Neste modo, o dispositivo atua como um AP (NL80211_IFTYPE_AP). O AP mantém e gerencia uma lista de estações associadas. O nome da rede (BSS) é o endereço MAC do AP (bssid). Há também um nome legível para o BSS, chamado de SSID.
  • Modo de infraestrutura da estação: uma estação gerenciada em um modo de infra-estrutura (NL80211_IFTYPE_STATION).
  • Modo de monitor: todos os pacotes de entrada são entregues não filtrados no modo monitor (NL80211_IFTYPE_MONITOR). Isso é útil para cheirar. Geralmente, é possível transmitir pacotes no modo monitor. Isso é chamado de injeção de pacotes; esses pacotes são marcados com um sinalizador especial (IEEE80211_TX_CTL_INJECTED).
  • Modo Ad Hoc (IBSS): uma estação em uma rede ad hoc (IBSS) (NL80211_IFTYPE_ADHOC). Com Modo Ad Hoc, não há dispositivo AP na rede.
  • Modo de sistema de distribuição sem fio (WDS): uma estação em uma rede WDS (NL80211_IFTYPE_WDS).
  • Modo de malha: Uma estação em uma rede Mesh (NL80211_IFTYPE_MESH_POINT), discutida na seção “Rede de malha (802.11s)” mais adiante neste capítulo.

fonte: link

    
por ceph3us 28.03.2016 / 18:58

1 resposta

2

De acordo com Systemd-networkd você precisa criar uma interface de bridge virtual com

nano /etc/systemd/network/MyBridge.netdev

após o seguinte conteúdo

[NetDev]
Name=br0
Kind=bridge

, em seguida, reinicie o systemd-networkd.service

para verificar o tipo ip a

A próxima etapa cria um perfil de rede para o Bridge com

 nano /etc/systemd/network/MyBridge.network

e além do seguinte conteúdo:

[Match]
Name=br0

[Network]
DHCP=ipv4

Editar

Para definir um ponto de acesso, você pode usar create_ap github_create_ap

Instalação

yaourt -S create_ap

Para outros distro

git clone https://github.com/oblique/create_ap
cd create_ap
make install

Exemplos

Sem passphrase (rede aberta):

 create_ap wlan0 eth0 MyAccessPoint

Senha WPA + WPA2:

 create_ap wlan0 eth0 MyAccessPoint MyPassPhrase

AP sem compartilhamento de Internet:

 create_ap -n wlan0 MyAccessPoint MyPassPhrase

Compartilhamento de Internet com ponte:

 create_ap -m bridge wlan0 eth0 MyAccessPoint MyPassPhrase

Compartilhamento de Internet com ponte (interface de ponte pré-configurada):

 create_ap -m bridge wlan0 br0 MyAccessPoint MyPassPhrase

Compartilhamento da Internet na mesma interface Wi-Fi:

 create_ap wlan0 wlan0 MyAccessPoint MyPassPhrase

Escolha um driver de adaptador WiFi diferente

 create_ap --driver rtl871xdrv wlan0 eth0 MyAccessPoint MyPassPhrase

Sem passphrase (rede aberta) usando pipe:

 echo -e "MyAccessPoint" | create_ap wlan0 eth0

Frase com senha WPA + WPA2 usando pipe:

 echo -e "MyAccessPoint\nMyPassPhrase" | create_ap wlan0 eth0

Ativar o IEEE 802.11n

  create_ap --ieee80211n --ht_capab '[HT40+]' wlan0 eth0 MyAccessPoint MyPassPhrase

Isolamento do cliente:

 create_ap --isolate-clients wlan0 eth0 MyAccessPoint MyPassPhrase

Serviço Systemd

Usando o serviço systemd persistente

Iniciar o serviço imediatamente:

systemctl start create_ap

Iniciar na inicialização:

systemctl enable create_ap
    
por 28.03.2016 / 20:29