Coder Social home page Coder Social logo

iphone-raspberry-pi's Introduction

Scripts and instructions on how to setup iPhone tethering on Raspberry Pi over USB.

I have the following network setup at my home:

Raspberry Pi

https://www.diyhobi.com/share-iphones-internet-home-network-lan-using-raspberry-pi/ https://web.archive.org/web/20171129092824/http://www.daveconroy.com:80/how-to-tether-your-raspberry-pi-with-your-iphone-5/

sudo apt-get install usbmuxd
sudo apt-get install gvfs ipheth-utils
sudo apt-get install libimobiledevice-utils gvfs-backends gvfs-bin gvfs-fuse 
sudo apt-get install openssh-server dnsmasq

Edit /etc/network/interfaces:

auto eth1
allow-hotplug eth1
iface eth1 inet dhcp

Enable SSH:

sudo systemctl enable ssh

Reset IP tables and set new ones:

# Reset IP tables
sudo iptables -F FORWARD
sudo iptables -F POSTROUTING -t nat

# Setup IP tables
sudo iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
sudo iptables -A FORWARD -i eth1 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i eth0 -o eth1 -j ACCEPT
sudo iptables -L -n -v
sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"

Links

Some useful links which I used to figure out how to set it up properly:

https://ubuntuforums.org/showthread.php?t=2228772 https://www.raspberrypi.org/documentation/configuration/wireless/wireless-cli.md https://www.raspberrypi.org/forums/viewtopic.php?t=18356 https://blog.mattbierner.com/tenome/ https://web.archive.org/web/20171129092824/http://www.daveconroy.com:80/how-to-tether-your-raspberry-pi-with-your-iphone-5/ https://www.howtogeek.com/68999/how-to-tether-your-iphone-to-your-linux-pc/

OpenVPN

Install OpenVPN

sudo apt-get update
sudo apt-get install openvpn

Enable OpenVPN

sudo systemctl enable openvpn

Move *.ovpn files into /etc/openvpn (not really necessary)

Backup IP tables:

sudo iptables-save > iptables-before-vpn

Setup IP tables:

# Allow traffic initiated from internal network
sudo iptables -A FORWARD -i eth0 -o tap0 -j ACCEPT

# Allow traffic from external network for connections initiated from internal network
sudo iptables -A FORWARD -i tap0 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT

# Drop existing connections

# When enabling VPN
sudo iptables -A FORWARD -i eth0 -o eth1 -j DROP
sudo iptables -A FORWARD -i eth1 -o eth0 -j DROP

# When disabling VPN
sudo iptables -A FORWARD -i eth0 -o tap0 -j DROP
sudo iptables -A FORWARD -i tap0 -o eth0 -j DROP

# This basically routes traffic via VPN
sudo iptables -t nat -F POSTROUTING
sudo iptables -t nat -A POSTROUTING -o tap0 -j MASQUERADE

# When disabling VPN
sudo iptables -t nat -F POSTROUTING
sudo iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE

Run OpenVPN as daemon:

sudo openvpn --config "openvpn-config.ovpn" --daemon

Links

Some useful links which I used to figure out how to set it up properly:

https://www.instructables.com/id/Raspberry-Pi-VPN-Gateway/ https://www.booleanworld.com/depth-guide-iptables-linux-firewall/ https://danielmiessler.com/study/iptables/ https://www.pinoylinux.org/tutorial/the-beginners-guide-to-iptables-the-linux-firewall/ https://stuffphilwrites.com/2014/09/iptables-processing-flowchart/ https://www.digitalocean.com/community/tutorials/a-deep-dive-into-iptables-and-netfilter-architecture

iphone-raspberry-pi's People

Contributors

inikolaev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

makr91

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.