LinuxQuestions.org
Visit Jeremy's Blog.
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-22-2012, 01:56 PM   #1
Gil@LQ
Member
 
Registered: Apr 2010
Location: India /Hyderabad
Distribution: RedHat, CentOS
Posts: 273

Rep: Reputation: 1
stop masquerade for specific network


hi,

i have a linux system configured as router with 3 nic's 192.168.85.254, 192.168.1.254, 192.168.2.254

192.168.85.0 network 1
192.168.1.0 network 2
192.168.2.0 network 3

i configured below rule so that 192.168.1.0 and 192.168.2.0 clients communicate with 192.168.85.0 network.

Quote:
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
Now my requirement is to stop 192.168.1.0 to comminicate / ping 192.168.85.0 so i did

Quote:
iptables -A FORWARD -s 192.168.2.0/24 -d 192.168.85.0/24 -j REJECT
it's working, my doubt is, if it's proper way to do to get my purpose served or is there any other way i mean.., removing the
Quote:
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
completely and write another rule to make 192.168.2.0 communicate with 192.168.85.0

please help me

thank you.......
 
Old 07-23-2012, 02:26 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
if you want a connection to not be possible, explicitly blocking is always the best way. I would say your approach is preferable that simply putting in a configuration that omits some functionality. They'd both do the same job really, but an explicit deny is easier to read and more secure.
 
Old 07-23-2012, 07:13 AM   #3
Gil@LQ
Member
 
Registered: Apr 2010
Location: India /Hyderabad
Distribution: RedHat, CentOS
Posts: 273

Original Poster
Rep: Reputation: 1
Hi acid_kewpie,

I don't get u, if you say i'm correct...thanks for your reply. By the way please look at the below thread.

http://www.linuxquestions.org/questi...ks-4175417938/
I posted this many time's but u never come accross my thread, my badluck. Please go through it. I want to buil a router to join 4 networks with a linux system using 4 lan cards, enabled ip forward in /etc/sysctl.conf. What i'm stucking at iptables.i know i should use masquerade. my doubt is do i have to apply rule for all the four cards ?

please help me. really need at my work...

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

Rep: Reputation: 51
In most cases, you would only enable MASQUERADE on an interface which is directly connected to the internet. In your other thread you suggest that you don't have an internet connection, is this correct?
 
Old 07-25-2012, 05:21 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 your reply, i think i confused. i was talking about squid as an example plese leave it in this post. Now i'll tell you my problem.
Quote:
I'm working with four networks now in real. Say A, B , C , D.
Now i have to make all the four networks to communicate with each other. So as you want to know if i enabled packet forwarding in /etc/sysctl.conf file, I did it. i enabled
Quote:
net.ipv4.ip_forward = 1
, so next part is configuring iptables. please tell me how to configure. for all the four nic cards. please help me. As if now no lan card is connected directly to internet.

thank you.
 
Old 07-31-2012, 02:56 AM   #6
SuperJediWombat!
Member
 
Registered: Apr 2009
Location: Perth, Australia
Distribution: Ubuntu/CentOS
Posts: 208

Rep: Reputation: 51
If you have 4 networks and wish to route between them, you do not need any masquerading.

Code:
iptables -t nat -F
iptables -I FORWARD -j ACCEPT
Once you have input those commands, your box should be able to route traffic between the various networks. If you are having trouble, make sure that you have set the gateway on your other machines correctly.

If you are still having issues after this, please make a network diagram with your current configuration.

Last edited by SuperJediWombat!; 07-31-2012 at 02:57 AM.
 
Old 08-02-2012, 03:37 PM   #7
Gil@LQ
Member
 
Registered: Apr 2010
Location: India /Hyderabad
Distribution: RedHat, CentOS
Posts: 273

Original Poster
Rep: Reputation: 1
hi SuperJediWombat!,

thank you, ur right it masquerades all the interfaces am i right ? what if i don't want "A" netowrk not communicate with "C" any rule to drop reques from "A" to "C"

thank you.
 
Old 08-03-2012, 01:38 AM   #8
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
I thought we already cleared all that up? Just put a REJECT on that route

iptables -A FORWARD -i eth0 -o eth2 -j REJECT

for example
 
  


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
How do I stop a device from being controlled by a specific driver? prushik Linux - Hardware 2 04-06-2011 02:39 PM
Is there any way to stop the kernel probing a specific USB controller? gzunk Linux - Hardware 9 11-22-2009 05:45 AM
How to stop HAL from seeing specific partitions? gibson79 Slackware 1 09-22-2009 01:07 PM
how to stop a connection to a specific UDP/TCP port? aromes Linux - Networking 2 03-04-2004 07:37 PM
how to tell to kernel to stop trying installing a specific module? zeppelin Slackware 4 08-21-2003 05:50 AM

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

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