Ok. I was able to get it to work.
Things to note:
- With current version of Raspbian (JESSE/LITE), the use of
/etc/network/interfaces
is obsolete. But keep it as it is used byif-up
andif-down
scripts.
My Setup
- Gave Raspberry Pi's eth0 a static IP address, connected to router's WAN port.
- Gave router a static IP address on the same network with the Raspberry Pi as the gateway.
- Installed dnsmasq [
sudo apt-get install dnsmasq
] on the Raspberry Pi. - Configured packet forwarding [
net.ipv4.ip_forward = 1
] in/etc/sysctl.conf
- Configured routing using
iptables
sudo iptables -t nat -A POSTROUTING -o usb0 -s 192.168.2.0/24 -j MASQUERADE
. usb0 is the source interface. One can add apost-up
script in /etc/network/interfaces to automate this.
Configuring the static IP address static in /etc/dhcpcd.conf
interface eth0
static ip_address=192.168.0.10/24
static routers=192.168.0.1
static domain_name_servers=192.168.0.1