LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 02-11-2004, 07:20 AM   #1
ThePlague
Member
 
Registered: Jul 2001
Posts: 34

Rep: Reputation: 15
Some linuxrouter network questions


Greetings

How do i configure my linuxrouter if i have for example 4 ip`s, and 100 local computers? Is there any way i can split my network into four so that 25 uses the first ip, 25 uses the second ip and so on? With iptables that is..or anything else would really work.

Now for my other question, how do i set up my linux router if i actually have 100 internet ip`s? Same thing here, with iptables or anything that would work..

Thanks!
 
Old 02-11-2004, 09:33 AM   #2
Tap-Out
Member
 
Registered: Oct 2002
Location: Halifax, NS
Distribution: Ubuntu, Mepis, Debian
Posts: 130

Rep: Reputation: 15
I would set up my router to use four different subnets (one for each ip address you have).

Ie. if your first public IP address was 123.123.123.12 set up a private subnet of 192.168.1.0 for that IP, then for your second public IP, say 123.123.123.13 use 192.168.2.0.

Hope that will point you in some direction, and if you want any more clarification or anything, post here and I'll see if I can help any(more).

Tap
 
Old 02-11-2004, 12:11 PM   #3
ThePlague
Member
 
Registered: Jul 2001
Posts: 34

Original Poster
Rep: Reputation: 15
yes i was thinking the same thing, but then again i am a newbie at this
How would i do things with iptables then?
 
Old 02-11-2004, 12:20 PM   #4
charon79m
Member
 
Registered: Oct 2003
Distribution: Just about anything... so long as it is Debain based.
Posts: 297

Rep: Reputation: 30
Another question to your question....

Just out of curiosity, why even do that? Why not just use a single IP for the entire internal networ? You've only got one pipe out to the internet right? You won't gain any bandwidth but you will add to you're router's processor load.

Best to think it through before causing yourself a headach for nothing.
 
Old 02-11-2004, 12:28 PM   #5
fataldata
Member
 
Registered: Jun 2002
Location: Breckenridge, Colorado
Distribution: Ubuntu Hardy 8.04
Posts: 101

Rep: Reputation: 15
I've posted below the steps I used to set up my RH9 router. I believe what you are looking for would be related to the 3rd step in configuring the POSTROUTING chain of the NAT table. Basically I would use SNAT to "Statically NAT" your internal ip range to the external IP. Something like:

iptables -t nat -A POSTROUTING -s 192.168.2.xxx/24 -j SNAT --to-source (insert public IP or range)


To set my pc up as a Linux gateway/router there seem to be three steps:
1. Enable IP forwarding.
2. Set firewall rules for the Filter table.
3. Set up postrouting on the nat table.

Step 1.
echo "1" > /proc/sys/net/ipv4/ip_forward

# Step 2. Commands to set up the firewall.

iptables -P INPUT ACCEPT # set default policy on the FILTER table INPUT chain to ACCEPT
iptables -F INPUT # flush the chain
iptables -P OUTPUT ACCEPT # policy for OUTPUT chain
iptables -F OUTPUT
iptables -P FORWARD DROP # policy for FORWARD chain
iptables -F FORWARD
iptables -t nat -F # flush the nat table
# Allow all connections OUT and only existing and related ones IN"
iptables -A FORWARD -i $EXTIF -o $INTIF -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -i $INTIF -o $EXTIF -j ACCEPT
#forward all packets from the internal interface if destined for the external interface

# Step 3. Enabling SNAT (MASQUERADE) functionality on $EXTIF"
$IPTABLES -t nat -A POSTROUTING -o $EXTIF -j MASQUERADE
 
Old 02-11-2004, 12:50 PM   #6
ThePlague
Member
 
Registered: Jul 2001
Posts: 34

Original Poster
Rep: Reputation: 15
iptables -t nat -A POSTROUTING -s 192.168.0.0/25 -j SNAT --to-source <ip1>

iptables -t nat -A POSTROUTING -s 192.168.0.128/25 -j SNAT --to-source <ip2>


Something like this you mean? Some guy tried to help me but i didnt understand much what those commands really do..
 
Old 02-11-2004, 01:00 PM   #7
fataldata
Member
 
Registered: Jun 2002
Location: Breckenridge, Colorado
Distribution: Ubuntu Hardy 8.04
Posts: 101

Rep: Reputation: 15
You are correct sir!

Try the command... I'm not sure if the "--to-source" statement is in the right place b/c I haven't used it, but if you get a syntax error just move it infront of the -j argument and try again..

Good Luck.
 
Old 02-11-2004, 01:11 PM   #8
ThePlague
Member
 
Registered: Jul 2001
Posts: 34

Original Poster
Rep: Reputation: 15
Ok, thanks But actually, what does those commands do? i cant see wich ip range goes to ip1 and what ip range that goes to ip2.. Yes newbie alert

Last edited by ThePlague; 02-11-2004 at 01:12 PM.
 
Old 02-11-2004, 03:25 PM   #9
fataldata
Member
 
Registered: Jun 2002
Location: Breckenridge, Colorado
Distribution: Ubuntu Hardy 8.04
Posts: 101

Rep: Reputation: 15
iptables -t nat -A POSTROUTING -s 192.168.0.0/25 -j SNAT --to-source <ip1>

Ok I'm no genius but i'll give it a shot. Of course for in depth understanding read the man page.

The above command makes an entry in the POSTROUTING chain of the NAT table. Telling it that whenever a new connection attempt is made from the source (-s 192.168.0.0/25) network, then the kernel should Statically Network Address Translate that IP to the (--to-source ) IP.

Basically you are reassigning the packet a new IP before it is transmitted.

It should set any ip address from 192.168.0.0/25 to <ip1>
and any ip from 192.168.0.128/25 to <ip2>

hope that helps. Theses are all firewall rules.
 
Old 02-11-2004, 06:26 PM   #10
ThePlague
Member
 
Registered: Jul 2001
Posts: 34

Original Poster
Rep: Reputation: 15
Ok, thanks You made it all clear to me

And now to my other question, how should i do things with linuxrouter if i do have enough internet ip`s for all the computers in my network?
 
Old 02-11-2004, 07:01 PM   #11
fataldata
Member
 
Registered: Jun 2002
Location: Breckenridge, Colorado
Distribution: Ubuntu Hardy 8.04
Posts: 101

Rep: Reputation: 15
That IS what you are doing with SNAT. Using one IP(or group of ip's) for all traffic you send through the linux box. AKA you have many internal non routable IP's on your LAN(192.168.xxx.xxx) once they traverse the firewall to the outside world they are TRANSLATED to the public routable ip's. So that the only address the internet see's is your Public routable IP.

My home network for instance:
I have one static routable IP assigned from my ISP. I assign that address to eth0 NIC on my Linux box along with the subnet mask and GATEWAY address provided by my ISP.
Then I have another NIC eth1 in my Linux box. I assign that NIC 192.168.1.1/24, using eth0's address as it's GATEWAY. eth1 is then attached to a hub where all the other pc's in my network are attached.
Each of them uses 192.168.1.1(or the address of eth1) as their GATEWAY to the internet. When the client pc's make a request to the internet the frame is sent via the hub to the GATEWAY AKA eth1 on the Linux box, then the frame is TRANSLATED by SNAT to the public IP of eth0 and sent to the internet via my ISP.


Internet-->ISP-->DSL Modem--> (eth0) Linux Box (eth1) --> Hub --> Client PC's
 
Old 02-12-2004, 02:51 AM   #12
ThePlague
Member
 
Registered: Jul 2001
Posts: 34

Original Poster
Rep: Reputation: 15
Hm, i ment if i got 100ip`s from my isp
 
Old 02-12-2004, 09:29 AM   #13
fataldata
Member
 
Registered: Jun 2002
Location: Breckenridge, Colorado
Distribution: Ubuntu Hardy 8.04
Posts: 101

Rep: Reputation: 15
sorry about that. I read that as don't not do. My mistake.

If you have enough public IP's what do you want the Linux router to do? Simply act as a firewall?

Not sure I'm clear on what you are trying to do.
 
Old 02-12-2004, 01:28 PM   #14
ThePlague
Member
 
Registered: Jul 2001
Posts: 34

Original Poster
Rep: Reputation: 15
Ok, my english isnt very good

Here it goes: How should i set up the internet access to my lan if im not going to use nat? Since i have 100ip`s..
 
Old 02-13-2004, 10:19 AM   #15
fataldata
Member
 
Registered: Jun 2002
Location: Breckenridge, Colorado
Distribution: Ubuntu Hardy 8.04
Posts: 101

Rep: Reputation: 15
Just don't use the NAT part of the rules. Should work if you just follow the rules I posted previously and omit step 3.
 
  


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 Questions Drakkath Linux - General 10 05-05-2005 01:23 PM
sendmail for internal network and network config questions RedHat123 Linux - Networking 0 04-06-2005 03:15 PM
2 network questions Zuggy Linux - Wireless Networking 1 01-30-2005 01:06 PM
Linuxrouter rogk Linux - Networking 12 08-29-2004 02:51 AM
More Sound/network questions....(I know, Im sorry) /redhat/n00b Linux - Newbie 1 09-16-2003 02:43 PM

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

All times are GMT -5. The time now is 08:29 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