1

I have three Raspberry Pi's connected to Linux machines and one computer connected to a router which is connected to the Internet. My goal is to configure each Raspberry Pi so that they can communicate with each other, but also automatically route any Internet requests through the main computer's router so I can ping actual websites and get a response.

So far, I have used:

sudo ifconfig eth0 192.168.1.X netmask 255.255.255.0 up
sudo route add default gw 192.168.1.254 eth0

Where X is 10, 11, and 12 respectively for each of the Linux machines. The IP address of the machine with access to the Internet is 192.168.1.254, but I now need to configure NAT so that the IP tables properly forward Internet requests from the Linux machines using the Raspberry Pi's.

As of now, the IP table of the Internet-connected machine is:

Kernel IP routing table
Destination    Gateway       Genmask         Flags    Metric    Ref    Use    Iface
192.168.0.0    *             255.255.255.0   U        1         0      0      eth1
default        192.168.0.1   0.0.0.0         UG       0         0      0      eth1

I'm somewhat new to network engineering, so any help/advice would be greatly appreciated. Currently, all four of the machines can ping each other and get responses. The only issue I'm facing is getting the three Linux machines to ping websites like this ping www.google.com.

2
  • Sadly, home networking questions are off-topic. Nov 17, 2013 at 13:36
  • This is for a lab, not a home.
    – weskpga
    Nov 18, 2013 at 2:37

1 Answer 1

0

You just need to make sure every Pi is in the same subnet, ex:

192.168.1.1 => router 192.168.1.2 => Pi 1 192.168.1.3 => Pi 2 192.168.1.4 => Pi 3

then configure the default gateway for de Pi's as 192.168.1.1. You should be alright. This way, when in the same subnet, the Pi's see eachother and use the default gateway when they need to reach some other subnet.

Be sure, if the router is also a pc to configure ip forwarding: http://www.ducea.com/2006/08/01/how-to-enable-ip-forwarding-in-linux/

(this las bit is more for "server fault" but the first part isn't)

When this is done as it should be, you should be able to ping 8.8.8.8 (google's DNS). If this works and pinging 'www.google.com' doesn't, you need to configure your DNS server. (in linux: resolv.conf) You can use the DNS from google as your dns server adress (8.8.8.8)

to summarize:

  • configure subnets
  • configure default gateways
  • configure the routing machine as a router
  • configure DNS on clients (and on router)
3
  • When you use 192.168.1.1 => router, are you implying that I should change the 192.168.1.254 IP address that the router has to 192.168.1.1?
    – weskpga
    Nov 17, 2013 at 1:25
  • Or should I have the Pi's be 192.168.1.(2,3,4) and keep the IP of the router the same since changing that would screw with the Internet connection? I'm sorry, but if you could provide a bit of code it would help because my high-level understanding is a little iffy
    – weskpga
    Nov 17, 2013 at 1:43
  • you can use the 192.168.1.254 instead of the 192.168.1.1. That doesn't matter, just make sure you use this then as the default gateway as well.
    – Bulki
    Nov 17, 2013 at 9:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .