1. The Setup
My router is hidden away and not near a screen. Connecting my RPi direct to the router is not convenient. I would still like network (and internet access occasionally) so have set my laptop up to share it's internet connection via the LAN network (A standard CAT5 cable, no need for crossover cable as the Pi can deal with this):
Ubuntu 12.04 laptop <==== Network cable =====> RPi
2. Setup the Raspberry Pi
The first stage is to give the RPi a static IP address. Do this by following the steps on the video to change your interfaces file:
http://www.youtube.com/watch?v=kcqQwBpB3Rw&feature=plcp
Code: Select all
cd /etc/network
sudo nano interfaces
Code: Select all
address 10.50.0.10
netmask 255.255.255.0
network 10.50.0.0
broadcast 10.50.0.255
gateway 10.50.0.1
Code: Select all
sudo nano /etc/resolv.conf
Code: Select all
nameserver 208.67.222.222
nameserver 208.67.220.220
From the drop down network menu next to the clock, click "Edit Connections..." and edit the details on the "IPv4 Settings" tab of your RPi wired network to:
* Method = Manual
* Address = 10.50.0.1
* Netmask = 255.255.255.0
* Gateway = 0.0.0.0
* DNS servers = 208.67.222.222, 208.67.220.220
Click "Routes..." and tick the box "Use this connection only for resources on its network".
Finally open a terminal window in Ubuntu and type the following 3 lines*:
Code: Select all
sudo iptables --table nat --append POSTROUTING --out-interface wlan0 -j MASQUERADE
sudo iptables --append FORWARD --in-interface eth0 -j ACCEPT
sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
* : I believe you can get away with just the 1st and 3rd but hopefully someone will confirm.
Note: These last 3 lines will need executing after each reboot of your Ubuntu machine. To avoid this hassle you can add the lines to you /etc/rc.d/rc.local file (see http://www.linuxsolved.com/forums/index.php?topic=115.0)
Cheers,
Rob
p.s. you may need to disable the firewall in Ubuntu to allow this (or set up forwarding) - unverified.