Raizo62/vwifi

What's the right config of TCP connection?

Closed this issue · 16 comments

I have followed the with-tcp part to setup, but got no lucky.

  1. First setup is:
    VM1(Debian):
    Running vwifi-server with IP 192.168.42.254

VM2(Debian): Running ./vwifi-client 192.168.42.254 and hostapd. IP of wlan0 is 10.10.0.1.

VM3(Debian): Running ./vwifi-client 192.168.42.254 and wpa_supplicant . IP of wlan0 is 10.10.0.2.

All three VMs in VMware, same network 192.168.42.0/24.
This set up can not connect to AP.

  1. Second setup is on Live Raizo:
    Host Machine running vwifi-server with IP 192.168.42.254.

    In GNS3:

    VM1(Debian): Running ./vwifi-client 192.168.42.254 (killed the systemd vwifi-client) and create_ap -n wlan0 MYSSID MYPASS

    VM2(Debian): Running ./vwifi-client 192.168.42.254 (killed the systemd vwifi-client) and edit /etc/network/interfaces and ifup wlan0

    VM1, VM2, Live Raizo, connected on a switch, they can ping each other.

    This set up VM2 can not get an IP from DHCP. And Host Machine can not find SSID.

Am I using TCP mode correctly? What's the correct setup of TCP mode? Can you provide some examples?

Hi

Your description seem good.

First setup :

  • On VM2 and VM3, have you load the module mac80211_hwsim ? :

modprobe mac80211_hwsim radios=2

  • Can you print here the output of vwifi-client 192.168.42.254 ?
  • On VM1, does vwifi-server detect the connection of vwifi-client ? (do you see displays ? or vwifi-ctrl ls shows the "CID" of VM2 or VM3 ? )

Second setup :

  • With your Liveraizo, i suppose that vwifi works with VHOST ?
  • On my LiveRaizo, i have tried with TCP without fast-vwifi : it works
  • The /etc/network/interfaces :
iface wlan0 inet dhcp
        wpa-ssid MYSSID
        wpa-psk MYPASS
        wireless-mode managed

Thank you very much for answering. So, basicly those two setups are workable? I will test Liveraizo without fast-vwifi later. My goal is get First setup work, because I cannot change the host machine.

In my First setup. vwifi-client can connect to vwifi-server. And I can see some traffic between server and client, using command tcpdump -ni ens3. Seems like hearbeat. But tcpdump -ni wlan0 shows nothing.

Some logs:

VM1(server):

# modprobe mac80211_hwsim radios=1
# macchanger -a wlan0
# ./vwifi-server                                
CLIENT VHOST : Listener on port : 8211
CLIENT TCP : Listener on port : 8212
SPY : Listener on port : 8213
CTRL : Listener on port : 8214
Size of disconnected : 15
Packet loss : disable
New connection from Client TCP : {[115904](0,0,0)}
New connection from Client TCP : {[115648](0,0,0)}

vwifi-ctrl ls shows like:

[115904](0,0,0)
[115648](0,0,0)

VM2(AP):

# modprobe mac80211_hwsim radios=1
# macchanger -a wlan0
# ./vwifi-client 192.168.42.254
Registered with family MAC80211_HWSIM
nl80211_init
Connection to Server Ok
ID: 115904

And I start AP with hostap tests/hostapd_wpa.conf conf com from vwifi git repo.

VM3(Client):

vwifi-client log same as VM2.

wpa_supplicant -Dnl80211 -iwlan0 -c tests/wpa_supplicant.conf for the client. from here

iw wlan0 link shows no link.

So what should I do to debug this?

I assume this is just like how VPN works. On client, hwsim0 collect traffics and vwifi-client send these traffics to vwifi-server through TCP. Then vwifi-server send to all the others. So vsock is not necessary. Am I right?


By the way, brilliant job!

Does modprobe mac80211_hwsim radios=2 has to be 2? If so why?

basicly those two setups are workable?

yes

My goal is get First setup work, because I cannot change the host machine

I understand

If you want to capture the traffic with tcpdump, you must do before :

sudo ip link set wlan0 down
sudo iw wlan0 set monitor control
sudo ip link set wlan0 up

On the server (VM1), the modprobe (modprobe mac80211_hwsim radios=1) is useless

If you want to use only tcp, the vsock is not necessary

The 2 in modprobe mac80211_hwsim radios=2 is the number of interface to create. You can use 1.

This day, i have tested with success with create_ap and the /etc/network/interfaces.
I will test with the test config. But this worked.

On each VM, you use the same version of vwifi ? (-v)

Yes, same version, VMs are cloned.

On each VM, you use the same version of vwifi ? (-v)

The config (wpa_supplicant.conf and hostapd_wpa.conf) works :

  • Actually, the first try was an echec.
  • Then I have tested with hostapd_wpa.conf and ifup which was an success
  • The second try was also a success

In your case, hostapd (or create_ap) displays nothing when wpa_supplicant (or ifup) is started ?

Succeed in the first setup. I got ping through AP and client. I don't know why for now, but I'm testing what change got me succeed.

It has to be something with the NetworkManager and wpa_supplicant. I can not reproduce it every time, but I can reproduce often.

Just stop & start NetworkManager and wpa_supplicant on client machine. And you will encounter it sometimes: the client cannot connect to AP.

# wpa_supplicant -Dnl80211 -iwlan0 -c tests/wpa_supplicant.conf
Successfully initialized wpa_supplicant

wpa_supplicant stuck here, and hostapd got no output.

I have to reboot client machine to recover.

NetworkManager is like networking. It does this own actions which can be in conflit with others program (yours).
Often, it is advice to stop it if you use others programs (networking,wpa_supplicant...)

Or, you can use NetworkManager and use it to connect to hostapd

does it work, now ?

Tested a lot. Using NetworkManager with GUI on Kali to create AP, works very well. But when using hostapd, client just cannot connect. I don't have much time to test, I have too move on for now. I am using Kali's GUI to create AP. Sorry didn't found the difference between mine and yours. Maybe later, when I have time, I will test again.

And maybe add some debug log will help ? Is there any advice to locate?

client just cannot connect

On AP, you have in the same time NetworkManager and hostapd ?
and on Client, you have NetworkManager and wpa_supplicant ?
or other ?

And maybe add some debug log will help ? Is there any advice to locate?

Debug in vwifi ? :

In Makefile : uncomment the line "MODE= -g -Wall -Wextra -pedantic -D_DEBUG" (and comment the other)
In src/config.h, you can add or remove the level of warning to uncomment "#define _VERBOSE1" or #define _VERBOSE2"

No, I didn't use them on same machine. NetworkManager is on kali, AP and Client are both kali. hostapd is on debian in gns3/vmware.

On AP, you have in the same time NetworkManager and hostapd ?
and on Client, you have NetworkManager and wpa_supplicant ?
or other ?

Maybe we can close this issue now. We can not fix an unknow bug.