Take the 2-minute tour ×

I have two laptops and some other devices in a LAN in which I have a small WIFI router. The two laptops communicate with each other over WIFI through the router. Beside the wifi connections there is a sensor device attached to the ether port of the router, that needs to communicate with laptop2 over the LAN, and it has a fix local ip. All the devices are in the same network. On my laptop1 I have internet through the ethernet interface of the laptop. It looks something like this:

internet ----- laptop1 ------- wifi router ------ laptop2

I would like to use the internet from laptop2. I tried to change the default route on laptop2 to use laptop1 as a gateway:

sudo route add default gw

where is the address of the wifi card in laptop1. It doesn't work, I can't ping any address apart from those in the small LAN. I turned of the firewall in laptop1, but didn't help either. What else should I configure?

details, adderesses:

laptop1 wifi:

laptop1 eth: {public ip}

wifi router:

laptop2 wifi:

other net device eth:

share|improve this question
you need to create routing rules on laptop1 if it must be default gateway for other computers. If connection between laptop2 and laptop1 is passing through router, the router needs to have a specific routing rule setup as well - otherwise it will pass traffic to internet using its own default gateway. –  mnmnc Apr 12 '13 at 10:18
what routing rules do I need to setup on laptop1, how should I do it? I didn't pen it correctly: the small "WIFI router" is actually working in access point mode, so it is rather a hub or switch. –  swizzly Apr 12 '13 at 10:34
You need to setup NAT on laptop1. Routing won't help -- addresses have to be changed. –  David Schwartz Apr 12 '13 at 11:05
read this article on how to forward traffic on linux: ducea.com/2006/08/01/how-to-enable-ip-forwarding-in-linux –  mnmnc Apr 12 '13 at 11:05
add comment

Your Answer



Browse other questions tagged or ask your own question.