Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to create wifi hotspots with raspberry pie

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

Many novices are not very clear about how to create wifi hotspots in raspberry pie. In order to help you solve this problem, the following editor will explain it in detail. People with this need can come and learn. I hope you can get something.

1. USB wireless network card driver

If you connect the USB wireless card and use the ifconfig command to see the wlan0 directly, congratulations, you can skip this step directly.

If not, please check the USB wireless card models supported by raspberry pie, please refer to the following website:

Http://elinux.org/RPi_VerifiedPeripherals#USB_Wi-Fi_Adapters

2. Change wlan0 to static IPsudo vim / etc/network/interfaces

Add the following:

Allow-hotplug wlan0iface wlan0 inet staticaddress 10.10.10.1netmask 255.255.255.0gateway 10.10.10.1

Restart is required after completion.

3. Install hostapd

The official hostapd does not support 8188CUS, so you need to reuninstall and install the new

According to the author's test, it seems that the old ones must be installed here first, and then the new ones must be unloaded later, otherwise they can't be used.

Sudo apt-get install hostapd

1) Edit the hostapd default configuration file:

Sudo vim / etc/default/hostapd

Find # DAEMON_CONF= "" and change it to:

DAEMON_CONF= "/ etc/hostapd/hostapd.conf"

2) then edit:

Sudo vim / etc/hostapd/hostapd.conf

Add the following code:

# Basic configuration interface=wlan0 ssid=RaspberryPi_Wifichannel=1 # bridge=br0 # WPA and WPA2 configuration macaddr_acl=0 auth_algs=1 ignore_broadcast_ssid=0 wpa=3 wpa_passphrase=12345678 wpa_key_mgmt=WPA-PSK wpa_pairwise=TKIP rsn_pairwise=CCMP # Hardware configuration driver=rtl871xdrv ieee80211n=1 hw_mode=g device_name=RTL8192CU manufacturer=Realtek

3) Save exit, and then restart the service:

Sudo service hostapd restart# or sudo hostapd-dd / etc/hostapd/hostapd.conf

4) if the network card you use prompts for information

Configuration file: / etc/hostapd/hostapd.conf

Nl80211: 'nl80211' generic netlink not found

Failed to initialize driver 'nl80211'

Rmdir[ctrl _ interface]: No such file or directory

In that case, you should still use a third-party hostapd.

4. Install the new hostapd

1) Delete the original hostapd

Sudo apt-get autoremove hostapd

2) download the third-party driver and install it

Link: http://share.weiyun.com/783e42c87ca22c458cebd2456b067de6 (password: kZHA) Note: if it has expired, please comment on the notice below

Tar-zxvf v1.1.tar.gz

3) compile:

Cd RTL8188-hostapd-1.1/hostapdsudo makesudo make install

4) then restart the service, which should indicate that it is successful:

$sudo service hostapd restart [ok] Stopping advanced IEEE 802.11 management: hostapd. [ok] Starting advanced IEEE 802.11 management: hostapd.

5) add hostapd to boot self-startup

Sudo service hostapd startsudo update-rc.d hostapd enable5, install DHCP service

The above steps set up the wifi hotspot, but cannot get the ip automatically. The following steps are required

Sudo apt-get install udhcpd

1) Edit the configuration file:

Sudo vim / etc/udhcpd.conf# modifies the following information. Start and end are allowed to start and end automatically. Note that start 10.10.10.10end 10.10.10.100interface wlan0 is in the same network segment as the static ip in the first step.

2) next, edit / etc/default/udhcpd and comment out the following line to make DHCP Server work properly:

# DHCPD_ENABLED= "no"

3) start the dhcp server

Sudo service udhcpd startsudo update-rc.d udhcpd enable

After this step, the mobile phone can access the wifi network and obtain ip automatically.

6. Configure routing forwarding

In theory, after this step, the mobile phone can surf the Internet through the wireless network that shares raspberry pie, but the author has not been successful.

1) set route map rules

Sudo iptables- Fsudo iptables- Xsudo iptables- t nat-A POSTROUTING-o eth0-j MASQUERADEsudo iptables- A FORWARD-I eth0-o wlan0-m state-- state RELATED,ESTABLISHED-j ACCEPTsudo iptables- A FORWARD-I wlan0-o eth0-j ACCEPTsudo bash-c iptables-save > / etc/iptables.up.rules

2) Editing:

Sudo vim / etc/network/if-pre-up.d/iptables

Add these two lines of code:

#! / bin/bash/sbin/iptables-restore < / etc/iptables.up.rules

Save the exit, then modify the iptables permissions:

Sudo chmod 755 / etc/network/if-pre-up.d/iptables

4) enable kernel forwarding:

Sudo vim / etc/sysctl.conf

Find the following two lines:

# Uncomment the next line to enable packet forwarding for IPv4#net.ipv4.ip_forward=1

Remove the # in front of net.ipv4.ip_forward and save and exit.

Then:

Sudo sysctl-p7, other questions

If wlan0 cannot set ip, modify the content of / etc/default/ifplugd as follows:

INTERFACES= "eth0" HOTPLUG_INTERFACES= "eth0" ARGS= "- Q-f-U0-D10-w-I" SUSPEND_ACTION= "stop" is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report