LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 07-20-2005, 05:39 AM   #1
Centinul
Member
 
Registered: Jun 2005
Distribution: Gentoo
Posts: 552

Rep: Reputation: 30
Question Network / Firewall Setup


I have a couple of questions pertaining to Network and Firewall setup.

I'm going to be building a firewall soon and I would like to know how to configure the PC's behind the firewall so they can have internet access (like what IP's to give them etc) I'm pretty new to the whole networking idea (especially with linux). There is one catch though when I return to school in the fall they only assign 2 IP addresses and I have three computers (firewall, laptop and desktop). How do I get around this? I don't have a router to put behind the firewall only a hub. Essentially I want to set my network up like the following (sorry about diagram but spacing doesn't work):


Firewall ----> Hub -----> Desktop, Laptop


Like I mentioned above I don't know how to configure the PC's to get access through the firewall especially since I'm limited with IP addresses. I've heard people mention a "gateway" but I wouldn't know how to set one up. I've also heard of having a firewall / router so I could get more IP's but I don't know how to set that up either. Thanks for the help!


Last edited by Centinul; 07-20-2005 at 05:41 AM.
 
Old 07-20-2005, 07:56 AM   #2
oneandoneis2
Senior Member
 
Registered: Nov 2003
Location: London, England
Distribution: Ubuntu
Posts: 1,460

Rep: Reputation: 48
You use IP masquerading to have multiple machines using a single IP address - Linux does it very well. My entire home Network (up to four PCs) all access the net thru a single router with just one WAN-side IP.

Depending on what you want to do with your firewall, a simple one is to use iptables to block ALL incoming traffic other than replies to your outgoing requests - this'll make it impossible for anybody to get access to your machine while still allowing you to chat & browse the web unrestricted.
 
Old 07-20-2005, 08:07 AM   #3
Centinul
Member
 
Registered: Jun 2005
Distribution: Gentoo
Posts: 552

Original Poster
Rep: Reputation: 30
I'm still very new with IPTables. I'm trying to learn that also so I can setup the firewall.

So do I have to setup a gateway on the firewall box so the PC's can get access to the internet?


Essentially how do the PC's know what to go through to access the internet?

Thanks!

Last edited by Centinul; 07-20-2005 at 08:16 AM.
 
Old 07-20-2005, 08:24 AM   #4
oneandoneis2
Senior Member
 
Registered: Nov 2003
Location: London, England
Distribution: Ubuntu
Posts: 1,460

Rep: Reputation: 48
That would probably be the easiest way to connect more PCs than you have IP numbers, yes.

I don't have my current firewall config available, but a simple & effective ruleset is something like:

Code:
#Set the default policy to "Drop everthing"
iptables -P FORWARD DROP
iptables -P INPUT   DROP
iptables -P OUTPUT  DROP

#Allow traffic out & allow replies back in:
iptables -A OUTPUT -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT

#Allow your computer to talk to itself:
iptables -A OUTPUT -j ACCEPT -o lo
iptables -A INPUT -j ACCEPT -i lo
You can improve it further to allow only specific traffic out, such as only allowing outbound requests to port 80 so only web traffic is allowed, but this is a good place to begin. . .
 
Old 07-20-2005, 08:36 AM   #5
Centinul
Member
 
Registered: Jun 2005
Distribution: Gentoo
Posts: 552

Original Poster
Rep: Reputation: 30
Thanks for the sample config I will save that so I can use it when I start building my firewall.
 
Old 07-20-2005, 10:04 AM   #6
fr_laz
Member
 
Registered: Jan 2005
Location: Cork Ireland
Distribution: Debian
Posts: 384

Rep: Reputation: 32
Hi,

For the PC to access internet, you have to configure their:
1/ IP address, say 192.168.0.1, 192.168.0.2...
2/ Netmask, say 255.255.255.0 (every PC/router/firewall on the same network MUST have the same netmask, it's used to know what part of the IP address is used to address the subnet and what part is used to identify each host)
3/ Gateway, the IP address of the network adapter of the firewall that is on the same subnet as the PCs (so NOT the IP given by your provider).
4/ DNS, the IP addresses of nameservers provided to you by your provider (unless you have your own DNS server)

you can easily configure all this by right-clicking on your network adapter icon and select options, or configuration (just don't remember at the moment) under windows... under linux, that will depend on your distro, but this is usually well documented on internet.


that was for the PC. I'll had 2 things to what proposed oneandoneis2 for the firewall config:
iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -d ! 192.168.0.0/24 -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward

the first line will configure masquerading, which enables NAT (network address translation) in iptables: every packet coming from your LAN and going to internet will use your public IP address.

the second line enables packet forwarding from an interface to another: if the /proc/sys/net/ipv4/ip_forward file countains 0, then packets cannot be transfered from a network adapter to another.

Good luck...
 
Old 07-20-2005, 10:08 AM   #7
Centinul
Member
 
Registered: Jun 2005
Distribution: Gentoo
Posts: 552

Original Poster
Rep: Reputation: 30
fr_laz thanks! You cleared that right up

Now I just need to figure out how to use IPTables and setup a gateway
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
network and firewall setup outriggen Linux - Security 3 06-08-2005 12:28 AM
Home network setup with network firewall/router Gates1026 Linux - Networking 4 01-17-2005 08:26 PM
MDK Multi-network-firewall - where are the network logs stored? Avatar Mandriva 5 02-11-2004 08:44 PM
help with client side NFS-firewall setup and server side NIS-firewall setup niverson Linux - Networking 3 02-02-2004 08:52 AM
How to Setup Firewall for home network julesbrat Linux - Networking 1 05-19-2002 03:17 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 07:53 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration