Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm hoping someone can point me in the right direction for setting up my Linux (Ubuntu 12.04) box to route traffic from eth0 to wlan0. I'll try and explain the problem I am trying to solve:

I currently have two separate networks:

[RaspberryPi/eth0] 192.168.2.2 / 255.255.255.0
    ^
    |
    v
[Ubuntu/eth0] 192.168.2.1 / 255.255.255.0

And:

[Ubuntu/wlan0] 192.168.1.100 / 255.255.255.0
    ^
    |
    v
[ADSL router] 192.168.1.1 / 255.255.255.0

So currently if I want to access the RaspberryPI I can SSH from the Ubuntu box to the PI. And if I want to use the Internet, I have full access from the Ubuntu box, but nothing from the RaspberryPI - the two networks are partitioned.

What I would like to do is configure things so that the RaspberryPI has Internet access via the Ubuntu box and out to the Internet.

I tried to create a bridge, but got the message "wlan0: operation not supported" (wireless chipset is Ralink RT3062).

I'm sure giving the Raspberry PI Internet access should be easy to do in this configuration, but I am a bit lost - can someone point me in the right direction please?

share|improve this question

closed as off-topic by Falcon Momot, Bryan, Jacob, TheCleaner, Ladadadada Jun 28 '13 at 16:29

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions about hardware or software used in a home setting are off-topic because they require answers that may not be practical for the business and support professionals here. You should try asking on Super User instead." – Falcon Momot, Bryan, Jacob, TheCleaner, Ladadadada
If this question can be reworded to fit the rules in the help center, please edit the question.

    
Does the router know to send traffic to 192.168.2.x to the Ubuntu box? Will the router NAT for 192.168.2.x addresses? Is IP forwarding enabled on the Ubuntu box? Troubleshoot in stages. Can the rPi ping 192.168.2.2 (itself)? Can it ping 192.168.2.1 (its own LAN)? Can it ping 192.168.1.1 (the router)? Where it fails will tell you what is wrong. (Note that you must route. You cannot bridge. Ethernet cannot be bridged to a WiFi client connection.) –  David Schwartz Jul 7 '12 at 8:54
    
Thanks David - good advice. All the pings work - however ip forwarding is not enabled. I will follow Mike's instructions and see how we go. Thanks again! –  Scruffers Jul 7 '12 at 9:23

1 Answer 1

up vote 1 down vote accepted

As root, please do this on your ubuntu to MASQ on wlan0, and routing for rasperry pi should work

echo 1 > /proc/sys/net/ipv4/ip_forward
/sbin/iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
/sbin/iptables -A FORWARD -i wlan0 -o eth0 -m state
   --state RELATED,ESTABLISHED -j ACCEPT
/sbin/iptables -A FORWARD -i eth0 -o wlan0 -j ACCEPT

Start forwarding and MASQ at boot

in /etc/sysctl.conf:

net.ipv4.ip_forward = 1

Create your iptables configuration (after applying the iptables commands above)

iptables-save > /etc/iptables_masq.rules

Then, in /etc/network/interfaces under the 'iface eth0' section:

pre-up iptables-restore < /etc/iptables_masq.rules
share|improve this answer
    
Thanks Mike! I will test this as soon as I get back from work and let you know how it goes. –  Scruffers Jul 7 '12 at 9:21
    
Tested this, works great - thank you so much! If you have time, I would be interested to know how to implement the permanent (survives reboot) solution. –  Scruffers Jul 7 '12 at 21:47
    
please see my edits... I am with my wife while she gives birth to our first, so if this doesnt work for some reason my responses might be delayed –  Mike Pennington Jul 8 '12 at 0:42
    
Wow! Well, good luck - I can tell you from experience you won't have much time for computers from now on :) –  Scruffers Jul 8 '12 at 8:37

Not the answer you're looking for? Browse other questions tagged or ask your own question.