Raspberry Pi network ad-hoc mode

Devices using Raspberry Pi 3b +, itself comes with a wireless card, if you do not monitor raspberry pie, is to want to log controlled by ssh, so we need to have two of each wireless card:

1. A connector for wifi, raspberry sent by the control device remotely ssh

2. A used for networking with other raspberry pie.

 

Raspberry Pi comes with a card, you need to purchase a usb card.

The antenna can buy with or without, the difference is not big, but better with an antenna signal, you can plug in general use, you do not need to install the driver.

    

 

 

After the device is ready

Assuming you have a good job ssh connection

We log on Raspberry Pi

 

sudo vim /etc/wpa_supplicant/wpa_supplicant.conf     

Open wifi connection profile

Here I was mainly due to a router has two interfaces, so with the two, sometimes an article which will not help, so that he can write the automatic selection can be used.

Next, configure the interfaces file

sudo vim /etc/network/interfaces

 

Add the following:

auto wlan0
allow-hotplug wlan0
iface wlan0 inet static
address 192.168.1.249
netmask 255.255.255.0
gateway 192.168.1.1
wpa_conf /etc/wpa_supplicant/wpa_supplicant.conf

auto wlan1
iface wlan1 inet static
address 10.0.0.1
netmask 255.255.255.0
network 10.0.0.0
broadcast 10.0.0.255
wireless-channel 3
wireless-essid mypi
wireless-mode ad-hoc

We used to connect wlan0 wifi, here we use the static fixed ip address so ssh connection

wlan1 we used to networking

Raspberry Pi several addresses to be set within a subnet, such as 10.0.0.1/24 10.0.0.2/24 10.0.0.3/24. . .

And the need to pay attention to more than one raspberry pie wireless-essid to be consistent, it can be network, which is equivalent to the identification adhoc network

wireless-mode is set to ad-hoc

 

After configuring restart raspberry pie, validate the configuration.

Enter the following command to confirm the configuration is to take effect

sudo ifconfig 

sudo iwconfig

 

 

 

Note, wireless essid if the set is the same, nothing else, each iwconfig Raspberry Pi will be the same in the cell, it can be a network

 

At this time, and if it can not ping

My personal understanding is, adhoc network is no center network, arp agreement is likely running up, so it can not determine the physical address, also ping illogical

 

We can configure the look arp table

First check to see if the arp table arp -v lack of entries

Command configured for

sudo arp -s 10.0.0.3(目的主机ip) xx:xx:xx:xx:xx:xx(目的主机的物理地址)

Configuration at both ends, so to be able to pass ping

 

 

Guess you like

Origin blog.csdn.net/Lin_QC/article/details/90717218