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 10-18-2008, 12:08 PM   #1
Tom Douglas
Member
 
Registered: Jun 2007
Posts: 90

Rep: Reputation: 15
Routing through a gateway


I'm trying to route traffic from subnet 192.168.2.x to subnet 192.168.3.x with limited success. Sometimes it works, sometimes not.

My Ethernet ports are configured as follows on box-3 (Fedora 5)....

Code:
[root@box-3 toms]# ifconfig
eth1      Link encap:Ethernet
          inet addr:192.168.2.42  Bcast:192.168.2.255  Mask:255.255.255.0

eth2      Link encap:Ethernet
          inet addr:192.168.3.43  Bcast:192.168.3.255  Mask:255.255.255.0
The route table is set up, and shows....

Code:
[root@box-3 toms]# route del default
[root@box-3 toms]# route add -net 192.168.3.0 netmask 255.255.255.0 gw 192.168.2.42
[root@box-3 toms]# service network restart
[root@box-3 toms]# route -ee
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface    MSS   Window irtt
192.168.36.0    box-3           255.255.255.0   UG    0      0        0 eth1     0     0      0
192.168.3.0     *               255.255.255.0   U     0      0        0 eth2     0     0      0
192.168.2.0     *               255.255.255.0   U     0      0        0 eth1     0     0      0
169.254.0.0     *               255.255.0.0     U     0      0        0 eth2     0     0      0
default         box-3           0.0.0.0         UG    0      0        0 eth1     0     0      0
The network restart reinserts the default gateway.

Why do I keep getting the default gateway? Do I need it?

With only eth2 enabled on box-3, I can ping box-4 (Fedora 3) at 192.168.3.63. With eth1 and eth2 enabled, pinging box-4 is iffy.

All iptables are off.

What should I be checking, or restarting?

The ultimate objective is to pass traffic through four boxes.

Thanks!

Tom D.
 
Old 10-18-2008, 06:50 PM   #2
zmanea
Member
 
Registered: Sep 2003
Location: Colorado
Posts: 85

Rep: Reputation: 15
Why do you need to add a route for 192.168.3.0/24 to 192.168.2.42 if you already have an interface in that subnet?
 
Old 10-19-2008, 01:32 AM   #3
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 63
As zmanea mentions, no additional route is necessary for directly connected interfaces, since their routes are added with the interface is brought up.

Have you enabled ip_forwarding ?

cat /proc/sys/net/ipv4/ip_forward

Ff 0, then:

echo 1 > /proc/sys/net/ipv4/ip_forward
 
Old 10-23-2008, 06:00 AM   #4
Tom Douglas
Member
 
Registered: Jun 2007
Posts: 90

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by zmanea View Post
Why do you need to add a route for 192.168.3.0/24 to 192.168.2.42 if you already have an interface in that subnet?
This is so other boxes on the 192.168.2.x subnet that have no direct access to 192.168.3.x to get that access through the gateway.

Tom D.
 
Old 10-23-2008, 06:12 AM   #5
Tom Douglas
Member
 
Registered: Jun 2007
Posts: 90

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Mr. C. View Post
Have you enabled ip_forwarding ?

cat /proc/sys/net/ipv4/ip_forward

Ff 0, then:

echo 1 > /proc/sys/net/ipv4/ip_forward
Ahh...Nice catch! I met to write that the forwarding is enabled (or so I thought), on /etc/sysctl.conf, net.ipv4.ip_forward = 1.

/proc/sys/net/ipv4/ip_forward is blank, just tried echoing a "1" to it and fails (using su). I may be looking at permission issues so I'll need to log in as root and try again.
 
Old 10-23-2008, 06:26 AM   #6
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
When I used my laptop to forward traffic from my desktop to the wireless router, I found that I needed to enable the "nf_conntrack" module before forwarding would work. The kernel module may have a different name, depending on which kernel you use. If I remember correctly, it was something like tcp_conntrack.

With both interfaces up, you don't need to add a route. There should already be a 192.168.2.0/24 route and a 192.168.3.0/24 route. The hosts on the 192.168.2.0/24 network will need to use 192.168.2.42 as the default gateway (or the gateway to the 192.168.3.0/24 network).

Is box-3 connected to the internet? If so, then you need a default route to your router or firewall.
 
Old 10-25-2008, 10:26 AM   #7
Tom Douglas
Member
 
Registered: Jun 2007
Posts: 90

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by jschiwal View Post
When I used my laptop to forward traffic from my desktop to the wireless router, I found that I needed to enable the "nf_conntrack" module before forwarding would work.....tcp_conntrack.
I didn't see tcp_conntrack on RPM search but will take another look.

Quote:
Originally Posted by jschiwal View Post
With both interfaces up, you don't need to add a route.....
OK, I cleared out the route table on box-3 (connected to both subnets). Sub 192.168.2.x gateway is defined. From this box I can sometimes ping box-4 on subnet 3 (there's still something squirelly about that).

Then from box-2 I can ping box-3 via subnet 192.168.2.x -- no problem. Can ping box-3 subnet 192.168.3.x's port too, but that's as far as I get. I'm unable to ping box-4 from box-2 (box three being the gateway from subnet 2.x to 3.x). What would be my next step?

Quote:
Originally Posted by jschiwal View Post
Is box-3 connected to the internet? If so, then you need a default route to your router or firewall.
There no Internet from this set of boxes.

Tom D.
 
Old 10-25-2008, 10:30 AM   #8
Tom Douglas
Member
 
Registered: Jun 2007
Posts: 90

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Mr. C. View Post
Have you enabled ip_forwarding ?

cat /proc/sys/net/ipv4/ip_forward
It turned out that box-3 ip_forwarding may have been enabled -- at least that was the case for another box. So cat /proc/sys/net/ipv4/ip_forward echos back a "1".

Tom D.
 
  


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
Routing or Gateway Problem Peter_APIIT Linux - Networking 24 01-26-2008 05:37 AM
vpn routing without the gateway karen.pertierra Linux - Networking 1 03-18-2007 06:39 AM
multi gateway routing problem hi100nu Linux - Networking 2 06-17-2006 01:24 PM
Linux Routing and Gateway GavSim Linux - Networking 1 02-08-2006 02:08 PM
routing/gateway/masquerade help wanted -=dionis=- Linux - Networking 4 06-25-2005 07:17 AM

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

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