Use Linux as firewall and Internet Sharing
You can configure linux as firewall in several ways, depends on your requirements and your network size. The easiest way is to use iptables (packet filtering) if you have a simple network or a few computers. There are other methods like pf and ipfw etc but they are quite complex to setup as you’ll need them if you have huge network or inhouse servers like web servers, email server, dns server etc with huge amount of traffic.
For for basic and simplicity we’ll use iptables as it is very easy to setup and troubleshoot, also we’ll setup this linux box to do NAT (network address translation) as well, means it will share internet with other computers.
I will setup packet filtering firewall for the following diagram

Here linux which acts as firewall and do NAT as well. If you to Linux box to assign IP to your computer you’ll need to install DHCP service, or you can assign IPs manually if you do not want DHCP server. In either case your workstations will have these TCP/IP settings.
i.e.
Workstation1
IP: 192.168.1.21
Subnetmask: 255.255.255.0
Gateway: 192.168.1.10
DNS: If you are using a router/DSL modem then DNS ip is the IP of your Router i.e. 192.168.1.1, if you are using cable modem then it will be the Public DNS IP which is 194.168.4.100 other wise if can give it the IP of linux machine if this linux box is a dns server as well. You’ll two Ethernet Cards, connect the first ethernet card (eth0) to your Switch and the second ethernet card (eth1) to your router or cable modem. Set eth1 to get IP automatically from router or cable modem and type ifconfig eth1 Let say IP assigned by router to eth1 is 192.168.1.2
Read the rest of this entry »

