LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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-21-2012, 05:40 AM   #1
Gil@LQ
Member
 
Registered: Apr 2010
Location: India /Hyderabad
Distribution: RedHat, CentOS
Posts: 273

Rep: Reputation: 1
Configuring linux router with four networks


hi,

i have 4 differnet networks x.x.1.x,x.x.2.x,x.x.3.x,x.x.x.4. so setup a linux machine with 4 lan cards. enabled forwarding in /etc/sysctl.conf.
but i have doubt configuring iptables to make 4 networks communicate.


I have squid.

|--------|
WAN eth0| squid |eth1 LAN
|--------|

preivously i my lan sysetms get internet through proxy but unable to ping 8.8.8.8 (google dns), i mean external ip's through squid from termial. I found a solution that NAT has to be enabled on my squid server. so i did as below and now
Quote:
they are pinging external ip's and connect my servers on branch via putty.
Quote:
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -A FORWARD -i eth1 -j ACCEPT.

Quote:
If i want to make my router work, do i have to apply above NAT rule for my four lan card or what ?
Please help me set up a linux router with four networks.

Please help me.

thank you.
 
Old 07-21-2012, 12:05 PM   #2
pingu
Senior Member
 
Registered: Jul 2004
Location: Skuttunge SWEDEN
Distribution: Debian preferably
Posts: 1,350

Rep: Reputation: 127Reputation: 127
Quote:
i have 4 differnet networks x.x.1.x, x.x.2.x, x.x.3.x, x.x.x.4
Typo there I think? Last must be x.x.4.x

Now I'm not quite sure what you want to achieve, also you didn't say what router you have?
Normally, traffic is allowed from inside to outside (WAN), but not from outside to inside.
If you want to allow traffic to servers on inside (be it LAN, squid or eth1) you must open a port in the firewall/router for that.
If you don't have public IP:s on the 3 inside networks then answer is Yes, you need to add NAT rules.

That's what I can say so far, please return with more info about adressing - private or public ip:s? - and spec of router.
 
Old 07-22-2012, 09:38 AM   #3
Gil@LQ
Member
 
Registered: Apr 2010
Location: India /Hyderabad
Distribution: RedHat, CentOS
Posts: 273

Original Poster
Rep: Reputation: 1
hi pingu,

thanks for reply. Now i'll give you my exact requirement.

Quote:
i have 4 networks in my office.x.x.1.x, x.x.2.x, x.x.3.x, x.x.4.x
. now i want to join all the 4 networks using linux router, i mean i configured a centos6 system as router. hope you got what my router is?. Now please tel me what to do. no interface is connected to internet, i have squid for want to connected to one of the 4 network cards of linux router. If it's not clear leave about squid.
Quote:
just tell me how to confiure linux machine as router to join all the four networks connected to linux router system.
please help me do it.

thank you.
 
Old 07-24-2012, 12:50 AM   #4
SuperJediWombat!
Member
 
Registered: Apr 2009
Location: Perth, Australia
Distribution: Ubuntu/CentOS
Posts: 208

Rep: Reputation: 51
Do you want all four networks to be able to communicate with each other, using the linux server as their gateway?


Please post the output of these two commands so that we can assist you further:
Code:
cat /proc/sys/net/ipv4/ip_forward
iptables-save
 
Old 07-24-2012, 03:52 AM   #5
Gil@LQ
Member
 
Registered: Apr 2010
Location: India /Hyderabad
Distribution: RedHat, CentOS
Posts: 273

Original Poster
Rep: Reputation: 1
hi SuperJediWombat!,

thanks for reply, sorry if i misguide u. I didn't do it completely i just added "1" to
Quote:
/proc/sys/net/ipv4/ip_forward
, hope that what u want to see as out put. I want to you to tel me how to configure iptable to make my router system complete.please help me. i did nt configure any thing in iptables. below configuration which i posted in the beging was on another server.


Quote:
they are pinging external ip's and connect my servers on branch via putty.
Quote:
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -A FORWARD -i eth1 -j ACCEPT.
Iptables are not configured in current system which i want to configure as router.

thank you.
 
  


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
Linux Router - 3 private networks sirfraz Linux - Networking 2 04-08-2012 08:36 PM
Linux as a router between 2 local networks to ISPs. shaileshjkumar Linux - Newbie 3 08-16-2011 03:36 AM
linux box as a router between two networks LinuxLover Linux - Server 1 08-04-2007 01:25 AM
2 networks and 2 internet connections on linux router seer_tenedos Linux - Networking 6 03-27-2005 07:24 AM
I need help configuring Linux behind router ?? neilmon2 Linux - General 7 10-16-2002 04:26 PM

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

All times are GMT -5. The time now is 02:09 PM.

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