vuptt / ppp-wifi-hotspot2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Note

  • Install:
sudo apt-get install -y hostapd dnsmasq ppp minicom iptables

To install:

  • For RPI3, RPI4, RPI zero2w
cd WifiHotspotDevices
chmod +x setup-ap-rpi-zero2w.sh
sudo ./setup-ap-rpi-zero2w.sh
  • For orangepi zero2(h616) :
    • If you want just burn and run without any setup, burn this image 30-09-2022 by Belena Etcher.

      • Add to SSE server sent event in web/index.html to dial from web
    • If you want just burn and run without any setup, burn this image 28-09-2022 by Belena Etcher.

      • g_ether (use_eem=0) using ecm mode through usb0 otg. H616 will play as hotspot and assign ip to the plugin phone or pc through dnsmasq
      • dnsmasq.conf : only allow to resolve IP of some domain specific in this file, otherwise to route 172.0.0.1
      • ppp0 script control by webapi. please access the domain pppdial.net:5099/dial to dial
      • iptable nat usb0(input iface)-------->pppp0(out put iface)
    • If you want to setup yourself from beginnig, use the following image and follow the instruction to install.

    • if you want option usb0-->ppp0 :

      cd ppp-wifi-hotspot2/UsbHotspotDevices/OrangePIZero2
      chmod +x *.sh
      sudo ./install-all.sh
    • if you want option wlan0(ap) ---> ppp0

      cd WifiHotspotDevices
      chmod +x setup-ap-orangepi-zero2.sh
      sudo ./setup-ap-orangepi-zero2.sh

Problem


dnsmasq: failed to create listening socket for port 53: Address already in use

#https://askubuntu.com/questions/191226/dnsmasq-failed-to-create-listening-socket-for-port-53-address-already-in-use #check sudo ss -lp "sport = :domain"

stop systemd-resolved on port 53

sudo systemctl stop systemd-resolved sudo systemctl disable systemd-resolved sudo systemctl mask systemd-resolved


iptables v1.8.2 (nf_tables): Chain 'MASQUERADE' does not exist

pivpn/pivpn#751

update-alternatives --config iptables

selected the legacy version. Re-ran the debug command and the script was able to auto-fix.

[1] Hostapd: 'wlan0: STA 24:43:e2:50:31:ff IEEE 802.11: disassociated'

That may cause wlan0 was already in STA mode and can not start AP mode.In STA the wlan0 is controlled by wpa_supplicant ==> To solve just kill wpa_supplicant and try to start hostapad on wlan0 :

# kill wpa_supplicant to release wlan0
sudo killall wpa_supplicant
# start AP on wlan0 ( configured by hostapd.conf)
sudo hostapd /etc/hostapd/hostapd.conf

This will temporary disable wpa_supplicant, to forbid wpa_supplicant run at next boot up --> disable wpa_supplicant service

sudo systemctl stop wpa_supplicant
sudo systemctl disable wpa_supplicant

[2]. pppd dont replace defaultroute

This problem is a known bug of pppd at link

That cause the system don't use ppp0 as default routing for ethernet. By default system may use eth0 or wlan0 as default route for ethernet.

  • To check route
ip route show

IF we want to use ppp0 as default internet source of system in case :

                  |--------------Raspbery PI------------|
                  |                                     | 
client-phone ---->| Wifi AP ( wlan0) -----nat----> ppp0 |---> Dial UP Ethernet
                  |                                     |
                  |-------------------------------------|

we need to set ppp0 as default internet route

sudo ip route add default dev ppp0

Note that: this command can only work if the interface ppp0 is established and availble. When dial OK and setup the pppd OK. Otherwise it will show the error can not find ppp0 interface

  • As a workaraound, create executable shell script at the end of: /etc/ppp/ip-up:
    route add default dev ppp0

and and at the end of /etc/ppp/ip-down

   route del default dev ppp0

Reference

#Other requirement is about permission levels. To properly execute the provided methods the application that uses the module must have the proper sudo privileges. One way to do it could be by adding a custom user to the system:

sudo adduser --no-create-home <user-run-sudo-without-password>

#then add its permissions at /etc/sudoers file:

<user-run-sudo-without-password> ALL=NOPASSWD: /sbin/iptables, /sbin/ip6tables, /sbin/ipset

# here : /sbin/iptables, /sbin/ip6tables, /sbin/ipset can run with sudo without password
  • Automatically re-apply the iptable rule on system reboot
sudo apt-get install iptables-persistent
sudo /etc/init.d/iptables-persistent save

About


Languages

Language:Makefile 38.6%Language:Shell 20.6%Language:Batchfile 17.7%Language:C 17.2%Language:JavaScript 4.3%Language:Python 0.9%Language:HTML 0.7%