Raizo62 / vwifi

Simulator of WiFi (802.11) interfaces to communicate between several Virtual Machines
GNU Lesser General Public License v3.0
57 stars 8 forks source link
linux wifi

What is this ?

Simulate Wi-Fi (802.11) between Linux Virtual Machines on Qemu/VirtualBox/...

Example

Explanations

Install

On Debian-based Linux distributions

Dependencies

sudo apt-get install make g++
sudo apt-get install libnl-3-dev libnl-genl-3-dev

Building

make gitversion # To add the last commit id to the VERSION

make update # To download and update the file mac80211_hwsim.h
make
make tools # To change the file mode bits of tools

sudo make install

On OpenWRT

Configuration

Method 1 : With VHOST

Host

Each Guest

Method 2 : With TCP

Host

vwifi-server

Each Guest

Capture packets from Host

Configure the Spy

sudo modprobe mac80211_hwsim radios=0
sudo vwifi-client -s -n 1

Capture

With tcpdump

With wireshark

Control

Host

Examples of commands to test Wifi

Test 1 : WPA

Packages needed on the guests for this test

sudo apt install hostapd wpasupplicant

Guests

sudo ip a a 10.0.0.1/8 dev wlan0

sudo hostapd tests/hostapd_wpa.conf

sudo ip a a 10.0.0.2/8 dev wlan0 ping 10.0.0.1


* Guest Wifi 3 :
```bash
sudo wpa_supplicant -Dnl80211 -iwlan0 -c tests/wpa_supplicant.conf

sudo ip a a 10.0.0.3/8 dev wlan0
ping 10.0.0.2

Test 2 : Open

Packages needed on the guests for this test

sudo apt install hostapd iw tcpdump

Guests

sudo ip a a 10.0.0.1/8 dev wlan0

sudo hostapd tests/hostapd_open.conf

sudo ip a a 10.0.0.2/8 dev wlan0 ping 10.0.0.1


* Guest Wifi 3 :
```bash
sudo ip link set up wlan0
sudo tcpdump -n -e -I -i wlan0 -w /hosthome/projects/vwifi_capture_wlan0.pcap

Host

tail -f -c +0b /home/user/projects/vwifi_capture_wlan0.pcap | wireshark -k -i -

Test 3 : Ad-Hoc

Packages needed on the guests for this test

sudo apt install iw

Guests

sudo ip a a 10.0.0.1/8 dev wlan0


* Guest Wifi 2 :
```bash
sudo ip link set up wlan0
sudo iw wlan0 set type ibss
sudo iw wlan0 ibss join MYNETWORK 2412 # frequency 2412 is channel 1

sudo ip a a 10.0.0.2/8 dev wlan0
ping 10.0.0.1

Test 4 : WEP

Packages needed on the guests for this test

sudo apt install hostapd

Guests

sudo ip a a 10.0.0.1/8 dev wlan0

sudo hostapd tests/hostapd_wep.conf

iface wlan0 inet static wireless-essid AP_WEP wireless-key 123456789a address 10.0.0.2 netmask 255.255.255.0

EOF sudo ifup wlan0

ping 10.0.0.1



# Others Tools

* start-vwifi-client.sh : do all the commands necessary to start ***vwifi-client*** on a Guest
* fast-vwifi-update.sh : set with ***vwifi-ctrl*** the coordinates of each VMs which has the option `guest-cid=`, found in the open project of GNS3
* client.sh : configure the client wifi with Open or WPA
* Makefile.dependency.sh : generate automatically the file "Makefile.in", include in "Makefile", which contains dependencies for "make"