Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 501bd9d8 authored by autodistries's avatar autodistries
Browse files

remove cron to set interfaces to monitor mode

parent 19b728db
No related branches found
No related tags found
1 merge request!1Refactoring, new features
......@@ -8,11 +8,11 @@ ss2
; s1 ansible_host=192.168.1.184 ansible_ssh_user=user
; s2 ansible_host=192.168.1.231
; s3 ansible_host=192.168.1.239
; s4 ansible_host=192.168.1.246
s4 ansible_host=192.168.1.100
[ss2]
s5 ansible_host=192.168.1.248
s6 ansible_host=192.168.1.247
#s5 ansible_host=192.168.1.248
# s6 ansible_host=192.168.1.247
# rp4 ansible_host=192.168.1.248
......
# **Installing the sniffer manager**
The sniffer manager consists of several configuration components. Each tool used will be discussed below to ensure the succesfull tool implementation.
## **Hardware**
### **Raspberry Pi**
The sniffers use Raspbian Bullseye simplified version installed on the Raspberry Pi 4B. Raspberry PI allows the use of low-cost controllers to enable other functionalities such as GPS.
### **Wireless interfaces**
Each Raspberry Pi is equipped with external TP-Link TL-WN722N wireless interfaces which make available the monitor mode, required for the analysis of captured network traffic in the sniffer.
### **GPS module**
Each Raspberry Pi is equipped with an [u-blox NEO 6M-0-001](https://content.u-blox.com/sites/default/files/products/documents/NEO-6_DataSheet_%28GPS.G6-HW-09005%29.pdf). This module has one timepulse PPS module, in addition to the stand-alone GPS receiver.
<center>
<figure>
<img src="../figures/gps_module.png" alt="gps_module"/>
<figcaption>Figure 1. GPS module.</figcaption>
</figure>
</center>
## **Software**
### **Ansible**
The sniffer manager uses Ansible to configure all the sniffer parameters. This can be used remotely or locally. So, we use our own made Ansible-based tool to configure the sniffers with all the required parameters. Ansible is compatible with Linux distributions Mac OS and Windows. Currently, we use a Macbook as manager for our development.
```
# apt install ansible -y
```
To establish communication with the sniffers, an inventory is defined. Each sniffer is configured with a static IP. Besides that, the sniffers are organized in groups (super-sniffers).
### **Time synchronization and GPS configuration**
We consider to use time synchronization via GPS PPS (Pulse Per Second) signal.
Install **gpsd** for GPS decoding of both time and position; **pps-tools** to verify PPS signals from the GPS; and **chrony** to handle PPS signals.
```
# apt install gpsd gpsd-clients pps-tools chrony
```
Install **pynmea2** for interpretation of messages provided by the GPS based on the NMEA 0183 [1]. NMEA format has different properties, depending on its sentence type and the properties in the message data. For this application, $GPGGA format is udes to extract latitude, longitude and datetime.
```
# pip3 install pynmea2
```
PPS configuration requires intruction definitions in _/boot/config.txt_. For NMEA data from the serial communication, it is necessary to enable UART communication and set the baud rate.
```
# bash -c "echo 'dtoverlay=pps-gpio,gpiopin=18' >> /boot/config.txt"
# bash -c "echo 'enable_uart=1' >> /boot/config.txt"
# bash -c "echo 'init_uart_baud=9600' >> /boot/config.txt"
```
It is also necessary to add PPS in _/etc/modules_.
```
# bash -c "echo 'pps-gpio' >> /etc/modules
```
#### **Pin connections**
| GPS | Raspberry Pi |
| :---: | :---: |
| PPS | Pin 12 (GPIO 18)|
| VCC | Pin 4 |
| GND | Pin 6 |
| RX | Pin 8 |
| TX | Pin 10 |
<center>
<figure>
<img src="../figures/gps_conn.png" alt="gps_connection"/>
<figcaption>Figure 2. Wire up GPS module to Raspberry Pi.</figcaption>
</figure>
</center>
It is needed to make the UART serial port enabled:
```
# raspi-config nonint do_serial 2
```
Configuration of **gpsd** in _/etc/default/gpsd_ to connect before polling whatever GPS must be associated with it. This is used to provide reference clock information to ntpd or chronyd. Moreover, the device argument should be defined as /dev/ttyS0 to /dev/pps0 to monitor the serial data for PPS.
```
# Default settings for the gpsd init script and the hotplug wrapper.
START_DAEMON="true"
USBAUTO="true"
DEVICES="/dev/ttyS0 /dev/pps0"
GPSD_OPTIONS="-n"
GPSD_SOCKET="/var/run/gpsd.sock"
```
Configuration of PPS as time reference for **chrony** server.
```
# bash -c "echo 'refclock SHM 0 delay 0.200 refid NMEA' >> /etc/chrony/chrony.conf"
# bash -c "echo 'refclock PPS /dev/pps0 refid PPS' >> /etc/chrony/chrony.conf"
```
......@@ -25,13 +25,10 @@ Multiple configuration scripts, here called microstasks, have been put into a si
- build and load driver
- `microtask_networking_naming_scheme_udev_setup.yml` (nodes)
- Switch off predictable netfowk interface naming
- set up udev rules for forced interface naming
- send file to set up udev rules for forced interface naming, and put interfaces to monitor mode on connection
- if any interface is named "wlanX", copy current active connection to work with wifi0
- `microtask_networkmanager_un_manager_setup.yml` (nodes)
- set up networkmanager to ignore wifi..8
- `microtask_interfaces_monitor_mode_cron_setup.yml` (nodes)
- copy bash script to set interfaces wifi.8 to monitor mode
- set up a cron task to run this script on reboot
- `microtask_hostname_update.yml` (nodes)
- update device hostname to [group]-[inventory name]: ss1-s1
- `microtask_hosts_update.yml` (nodes)
......
......@@ -6,7 +6,7 @@ ACTION=="add", SUBSYSTEM=="net", SUBSYSTEMS=="sdio", ATTRS{device}=="0x4345", AT
# +-------+-------+
# | wifi6 | wifi8 |
# +---------------+ (RPI physical USB ports distribution)
ACTION=="add", SUBSYSTEM=="net", SUBSYSTEMS=="usb", KERNELS=="3-1", NAME="wifi5"
ACTION=="add", SUBSYSTEM=="net", SUBSYSTEMS=="usb", KERNELS=="1-1", NAME="wifi6"
ACTION=="add", SUBSYSTEM=="net", SUBSYSTEMS=="usb", KERNELS=="1-2", NAME="wifi7"
ACTION=="add", SUBSYSTEM=="net", SUBSYSTEMS=="usb", KERNELS=="3-2", NAME="wifi8"
ACTION=="add", SUBSYSTEM=="net", SUBSYSTEMS=="usb", KERNELS=="3-1", NAME="wifi5", RUN+="/usr/bin/sudo /usr/sbin/ifconfig wifi5 up", RUN+="/usr/bin/sudo /usr/sbin/ifconfig wifi5 down", RUN+="/usr/bin/sudo /usr/sbin/iwconfig wifi5 mode monitor", RUN+="/usr/bin/sudo /usr/sbin/ifconfig wifi5 up"
ACTION=="add", SUBSYSTEM=="net", SUBSYSTEMS=="usb", KERNELS=="1-1", NAME="wifi6", RUN+="/usr/bin/sudo /usr/sbin/ifconfig wifi6 up", RUN+="/usr/bin/sudo /usr/sbin/ifconfig wifi6 down", RUN+="/usr/bin/sudo /usr/sbin/iwconfig wifi6 mode monitor", RUN+="/usr/bin/sudo /usr/sbin/ifconfig wifi6 up"
ACTION=="add", SUBSYSTEM=="net", SUBSYSTEMS=="usb", KERNELS=="1-2", NAME="wifi7", RUN+="/usr/bin/sudo /usr/sbin/ifconfig wifi7 up", RUN+="/usr/bin/sudo /usr/sbin/ifconfig wifi7 down", RUN+="/usr/bin/sudo /usr/sbin/iwconfig wifi7 mode monitor", RUN+="/usr/bin/sudo /usr/sbin/ifconfig wifi7 up"
ACTION=="add", SUBSYSTEM=="net", SUBSYSTEMS=="usb", KERNELS=="3-2", NAME="wifi8", RUN+="/usr/bin/sudo /usr/sbin/ifconfig wifi8 up", RUN+="/usr/bin/sudo /usr/sbin/ifconfig wifi8 down", RUN+="/usr/bin/sudo /usr/sbin/iwconfig wifi8 mode monitor", RUN+="/usr/bin/sudo /usr/sbin/ifconfig wifi8 up"
......@@ -11,11 +11,10 @@
- import_playbook: ./microtask_network_drivers_update.yml
# - import_playbook: ./microtask_network_drivers_update.yml
- import_playbook: ./microtask_networking_naming_scheme_udev_setup.yml
- import_playbook: ./microtask_networkmanager_un_manager_setup.yml
- import_playbook: ./microtask_interfaces_monitor_mode_cron_setup.yml
- import_playbook: ./microtask_hostname_update.yml
- import_playbook: ./microtask_hosts_update.yml
......
- name: Make cron set connected interfaces to monitor mode on reboot
hosts: sniffers
become: no
become_user: root
tasks:
- name: Copy setInterfacesToMonitorMode.sh to ~/setInterfacesToMonitorMode.sh
tags: device-setup nodes
copy:
src: "../files/setInterfacesToMonitorMode.sh"
dest: "~/setInterfacesToMonitorMode.sh"
mode: '0770'
- name: Crontab - set interfaces to monitor mode on reboot
ansible.builtin.cron:
name: "setInterfacesToMonitorMode.sh"
special_time: reboot
job: "~/setInterfacesToMonitorMode.sh"
......@@ -6,6 +6,9 @@
become: yes
become_user: root
tasks:
- name: Install git if necessary
shell: type git || sudo apt update && apt install git -y
- ansible.builtin.git:
repo: https://mitik-sens-mod:glpat-F9S1EPn2KKts_a8syNWu@gitlab.inria.fr/gfarhiri/mitik-sens-mod
dest: ./mitik-sens-mod
......
......@@ -6,16 +6,17 @@
tasks:
- name: Switch off predictable naming mechanism
command: ls -nfs /dev/null /etc/systemd/network/99-default.link
command: ls -nfs /dev/null /etc/systemd/network/99-default.link
- name: Copy UDEV rules to set interface names based on physical USB positions
copy:
copy:
src: "../files/72-wlan-geo-dependent.rules"
dest: /etc/udev/rules.d/72-wlan-geo-dependent.rules
- name: Query current interface names
shell: "ip a | grep wlan"
ignore_errors: yes
register: any_wlans
- name: Query active connections
shell: "nmcli -t -f name,uuid con show --active | grep -v lo"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment