Skip to content

Instantly share code, notes, and snippets.

@halfd
Forked from ChickenProp/gist:3037292
Last active December 14, 2015 07:28
Show Gist options
  • Save halfd/5050406 to your computer and use it in GitHub Desktop.
Save halfd/5050406 to your computer and use it in GitHub Desktop.

** This is the super chopped down version that worked between my Ubuntu laptop and my Arch Rasp ** This isn't peristent after reboot, but it works for now :)

Step zero: plug everything in.

Step one, on the laptop:

sudo ip addr add 192.168.1.1/24 dev eth0

Step two, again on the laptop:

sudo iptables -A FORWARD -o wlan0 -i eth0 -s 192.168.1.0/24 -m conntrack --ctstate NEW -j ACCEPT
sudo iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
sudo iptables -A POSTROUTING -t nat -j MASQUERADE

Step three: enable IP forwarding, again on the laptop.

echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward

Step four: sudo ifconfig eth0 up on the laptop makes sure it's listening for packets.

Step five: on the Pi, get an IP address.

sudo ip addr add 192.168.1.2/24 dev eth0

Step six: again on the Pi, tell it where to find the internet

sudo ip route add default via 192.168.1.1

Step seven: to get DNS working, I ignored what the Ubuntu wiki was saying about dhcp. Just edit /etc/resolv.conf and add the line

nameserver 89.233.43.71 89.104.194.142
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment