VintageNet how to put interface into monitor mode

Hi I am trying to setup wfb-ng on my rpi0_2.

To get it working I need to put wifi interface into monitor mode.

I have managed to build custom driver for Wi-Fi card and get it working and showing up as wlan1.

iex(3)> ifconfig
lo: flags=[:up, :loopback, :running]
    inet 127.0.0.1  netmask 255.0.0.0
    inet ::1  netmask ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
    hwaddr 00:00:00:00:00:00

wlan0: flags=[:up, :broadcast, :running, :multicast]
    inet 192.168.178.141  netmask 255.255.255.0  broadcast 192.168.178.255
    inet 2a02:8108:96c0:5a77:e65f:1ff:fe45:e52  netmask ffff:ffff:ffff:ffff::
    inet fe80::e65f:1ff:fe45:e52  netmask ffff:ffff:ffff:ffff::
    hwaddr e4:5f:01:45:0e:52

wlan1: flags=[:broadcast, :multicast]
    hwaddr 1c:a7:70:77:f2:76

Usual next steps are on standard linux systems is putting interface in unmanaged state. Currently iw on my nerves config says itā€™s managed.

iex(4)> cmd("iw dev wlan1 info")
Interface wlan1
	ifindex 3
	wdev 0x100000001
	addr 1c:a7:70:77:f2:76
	type managed
	wiphy 1
	txpower 18.00 dBm

I am using following VintageNet config:

config :vintage_net,
  regulatory_domain: "DE",
  config: [
    {"usb0", %{type: VintageNetDirect}},
    {"eth0",
     %{
       type: VintageNetEthernet,
       ipv4: %{method: :dhcp}
     }},
    {"wlan0",
     %{
       type: VintageNetWiFi,
       vintage_net_wifi: %{networks: [network]},
       ipv4: %{method: :dhcp}
     }},
    {"wlan1", type: VintageNet.Technology.Null}
  ]

Next step would involve running following commands as root to set interface into monitor mode:

ip link set <interface> down
iw dev <interface> set monitor otherbss
ip link set <intreface up

I cannot run all of that commands. Reason might be that inferface is still managed or that I am not allowed because of some linux rules setup for the shell. They return following:

iex(9)> cmd("ip link set wlan1 up")
ip: SIOCSIFFLAGS: Operation not permitted
2
iex(10)> cmd("ip link set wlan1 down")
0
iex(11)> cmd("iw dev wlan1 set monitor otherbss")
command failed: Operation not permitted (-1)
255
iex(12)> cmd("ip link set wlan1 up")
ip: SIOCSIFFLAGS: Operation not permitted
2
iex(13)>
1 Like

Not sure how the Null technology actually operates. But VintageNet runs ip commands for you and for wifi would run stuff like wpa_supplicant.

If you want custom control you can probably just remove your interface from VintageNet. Then when you are happy with how it works you could implement your own VintageNet.Technology for having it configurable and running the commands you want or need for you.

Edit: Not sure about the permission problems. Have never used iw and am fairly new at this part of networking.

I am digging though how VintageNet.Wifi controls wpa_supplicant. I tried removing it and it still stays managed.

ChatGPT says that wpa_supplicant automatically runs on all interfaces and that I should be able to terminate it with sudo wpa_cli -i wlan1 terminate so I am trying to add wpa_cli to my nerves system and see if I can get it to unmanaged state.

I tried configuring it normally in VintageNet to use it as normal wifi adapter, and it is failing so I guess it is driver issue still.

Here is log snippet:

14:29:25.789 [warn] RouteManager: new set_connection_status wlan1 -> :disconnected (Elixir.VintageNet.Interface.start_configuring/3([file: ~c"lib/vintage_net/interface.ex", line: 669]))

14:29:26.354 [debug] ip:ip: SIOCSIFFLAGS: Operation not permitted

14:29:26.355 [error] Nonzero exit from ip, ["link", "set", "wlan1", "up"]: 2

%VintageNet.Interface.OutputLogger{prefix: "ip:"}


14:29:26.356 [debug] VintageNet(wlan1): :configuring -> done error: retrying after 30000 ms

It seems to be power. Rpi zero doesnā€™t provide enough power to the WiFi board over usb. Currently it doesnā€™t show up directly on boot, only after I unplug it and replug it, after that it everything seems to work normally and I am able to put into monitor mode using iw.

1 Like

Iā€™m a little late to this. Iā€™m glad you got it working!

Just to clarify things if others stumble on this thread, VintageNet.Technology.Null does the same thing as not listing a network interface in your configuration. Sometimes itā€™s useful to be explicit that a network interface is not to be managed by VintageNet. Also, ChatGPT should have mentioned that you can limit what network interfaces wpa_supplicant will handle. VintageNet does that so if you have multiple WiFi network interfaces, thereā€™s a wpa_supplicant instance for each one.

Amazingly, this power issue comes up periodically. I sure wish there were a better error message.

1 Like

Summary to complete the thread so it matches the title.

If you want to use wifi card that supports it in monitor mode:

  • create custom nerves system
  • if you need special driver add custom buildroot package, you will also need to enable usb and usb_net in kernel config
  • add iw buildroot package
  • make sure that your wifi card is properly powered otherwise buggy behavior is possible

I will link PR on my nerves system when I clean it up.

5 Likes

PR that adds custom Wi-Fi driver

2 Likes