Solved

Another routing problem

Posted on 2004-03-22
14
233 Views
Last Modified: 2011-09-20
I have 3 Linux machines(Debian woody) A,B,C.
A and B are in same network.
C is in diffrent network.
I want to use B as the gateway for A for connecting to the C network.
 -------------------------------------------------
A and B are in 192.168.1.0 network
A    IPaddress -   192.168.1.2
       Netmask 255.255.255.0

B     IP address 192.168.1.1
       Netmask 255.255.255.0


C is in 192.168.0.0 network
     IP address -192.168.0.1
     Netmask      255.255.255.0

Now I want  to connect from   192.168.1.0 network to 192.168.0.0 network and vice versa.

For this In machine B I did a routing.
      route add -net 192.168.0.0 netmask 255.255.255.0  dev eth0
and in Machine C
   route add -net 192.168.1.0 netmask 255.255.255.0  dev eth0
 
  done.Now i am able to ping from machine B to C.

 No  I want to use my Machine B as Gateway for A to access the other network.
 For this In Machine A in the routing entry I added

     route add -net 192.168.0.0 netmask 255.255.255.0 gateway 192.168.1.1 dev eth0.
                     But I cud not ping or ssh to C from A .From C also I cud not ping to A .But I can access Machine B  .
Why?.Am i did anything wrong?.            
0
Comment
Question by:palanisaravanan
  • 7
  • 4
  • 3
14 Comments
 
LVL 4

Expert Comment

by:Jivko
ID: 10656875

Why just not add a secondary IP address 192.168.0.254 for machine B?
ifconfig eth0:1 192.168.0.254 netmask 255.255.255.0

Then you can use machine B for a default GW in both networks
0
 
LVL 4

Expert Comment

by:Jivko
ID: 10656894
And also enable IP Forwarding and Proxy Arp

echo 1 > /proc/sys/net/ipv4/ip_forward
echo 1 > /proc/sys/net/ipv4/conf/eth0/proxy_arp
0
 
LVL 8

Expert Comment

by:da99rmd
ID: 10656913
You must enable ip forwarding with
echo "1" > /proc/sys/net/ipv4/ip_forward
and add the ipmasq config with
/sbin/iptables -t nat -A POSTROUTING -o (ougoing interface name) -j MASQUERAD

all this is made on the GW machine

/Rob
0
 
LVL 8

Expert Comment

by:da99rmd
ID: 10656931
jviko,
what does the  
echo 1 > /proc/sys/net/ipv4/conf/eth0/proxy_arp
command ?
0
 

Author Comment

by:palanisaravanan
ID: 10657108
Jviko
 I don't want to use machine B as gateway for both the networks.
MY situation is
Machine B should be the gateway for all the outgoing packets sent from
Machine A to the other network i.e Machine C .
I know it is possible.It involves a bit of route command.There only I am struggling.
 
0
 
LVL 4

Accepted Solution

by:
Jivko earned 150 total points
ID: 10665112
da99rmd ,
There is no need of Masquerading or NAT in this situation.

echo 1 > /proc/sys/net/ipv4/conf/eth0/proxy_arp
 Enables proxy arp.

palanisaravanan ,
 Adding a two static routes on machine C :

route add 192.168.1.1 dev eth0
route add -net 192.168.1.0/24 gw 192.168.1.1

And on machine A:

route add -net 192.168.0.0/24 gw 192.168.1.1


Of cource enabling IP Forwarding on machine B is a MUST. :

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



Regards



0
 
LVL 8

Expert Comment

by:da99rmd
ID: 10665235
Yes thats true,
didnt se he was trying to route between 2 private nets :/

/Rob
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 8

Expert Comment

by:da99rmd
ID: 10665242
Yes,
thats true aboute the NAT, i didnt se that he was trying to route between 2 private nets. :/

/Rob
0
 
LVL 8

Expert Comment

by:da99rmd
ID: 10665244
:)
0
 

Author Comment

by:palanisaravanan
ID: 10665356
yes!Every thing is in my private net.

Jivco!
  Thanks.But it is not working
0
 

Author Comment

by:palanisaravanan
ID: 10665384
As Jivko said there is no need for NAT in my case
0
 
LVL 8

Expert Comment

by:da99rmd
ID: 10665442
Try finding out what stops the communication beacuse it should work with the configuration jivco posted.

You dont have some kind of firewall stoping the communication.

Try running a tcpdump on each interface of the B machine and sort out the nessesary trafic perhaps with:

tcpdump -i eth(0 or 1) 'src (ip adress)'

/Rob
0
 

Author Comment

by:palanisaravanan
ID: 10665547
Yeah!It is working now.I didn't do any new thing .Just i restarted my netwoking interfaces.And again start the routing configuration.It started working.Thank you guys
0
 
LVL 8

Expert Comment

by:da99rmd
ID: 10665588
You are welcome
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

I have seen several blogs and forum entries elsewhere state that because NTFS volumes do not support linux ownership or permissions, they cannot be used for anonymous ftp upload through the vsftpd program.   IT can be done and here's how to get i…
Note: for this to work properly you need to use a Cross-Over network cable. 1. Connect both servers S1 and S2 on the second network slots respectively. Note that you can use the 1st slots but usually these would be occupied by the Service Provide…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now