Easy script for easy lan

Posted: 26/11/2009 in System Administration
Tags: ,

Today is a good day to die. This is the mind of all routers of our provider cos today they decide to suicide, letting us without a way to reach Internet.

Today I planned to make live the server our customer with an effort of 2 hours. But Murphy’s law is all around us and then the DSL link of our offices went down.

Well, the choice was two: a party or my hsdpa cellphone…. I chose  for the second one :(. So i decided to use the netbook as gateway for lan traffic, connecting it to my pc with ethernet cable.

What is interesting is how is versatile iptables who allow me to configure my netbook as router, and my pc as a gateway for other computer in the office.

These are the miracle four rows (on netbook)

iptables -A FORWARD -i ppp0 -o eth0 -m state –state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -i eth0 -o ppp0 -j ACCEPT
iptables -A FORWARD -j LOG
iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE

and these are the four for the pc

iptables -A FORWARD -i eth0 -o eth1 -m state –state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT
iptables -A FORWARD -j LOG
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

Obviously I make a lan between my pc and netbook configured by hand using ifconfig, and I changed the routing using route command.

This is a link of a full script that use iptables to transform a pc in a router.
http://www.ecst.csuchico.edu/~dranch/LINUX/ipmasq/examples/rc.firewall-iptables

I know iptables is a little bit hard to use, but there are solutions at high level as shorewall, who manage iptables and allow you to know only what you really need to know.

Enjoy.

Advertisements
Comments
  1. […] more easy 08/01/2010 cippino Leave a comment Go to comments Hi all, remember the previous post about an easy way to transform a netbook in a router for hsdpa connections? Well, I decided to make […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s