Operating System - Linux
1822448 Members
2422 Online
109642 Solutions
New Discussion юеВ

Make a linux box as a simple router

 
yongye_1
Advisor

Make a linux box as a simple router

Hi,

The server installed AS3U2. It has two nics. I assigned 10.0.0.2/24 to eth0 and 192.168.0.1/24 to eth1. I enabled the net.ipv4.ip_forward in /etc/sysctl.conf and reboot the server. The followed lines are the output from netstat -r command,
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
192.168.0.0 * 255.255.255.0 U 0 0 0 eth1
10.0.0.0 * 255.255.248.0 U 0 0 0 eth0
127.0.0.0 * 255.0.0.0 U 0 0 0 lo
default cluster1.as3 0.0.0.0 UG 0 0 0 eth0

I have to pcs connected with the linux box with two subnet. From 10.0.0.3 I can ping 10.0.0.2 and from 192.168.0.2 I can ping 192.168.0.1 without problem. But when I issue ping 192.168.0.2 command on the 10.0.0.3, it failed with no output. No timeout,no destination cann't be reached messages showed on the screen.

Is there anything I forget to config? Who can give me an advice? Thanks in advanced.

Yongye
10 REPLIES 10
Slawomir Gora
Honored Contributor

Re: Make a linux box as a simple router

Hi,

did you set routing on your PC
a) 192.168.0.3 gateway must be 192.168.0.1
b) 10.0.0.3 gw 10.0.0.2
Muthukumar_5
Honored Contributor

Re: Make a linux box as a simple router

Your routing will be the problem there.

While checking the routing entries use as,
# route -n
# netstat -nr

It will give full informations there.

You can check trace routing problem's with traceroute command there.

Problem information says your routing settings are wrong there. what is the machine router informations??

Please post that informations to pin-point exact problem.
Easy to suggest when don't know about the problem!
Muthukumar_5
Honored Contributor

Re: Make a linux box as a simple router

PCS are not having routing entries for 192.* entries there. Configure your PCS as,

Destination Gateway
192.168.0.0 192.168.0.1
10.0.0.0 10.0.0.2

so that requests will be sent corresponding gateway. If that is missing and using default routing as,

default

then it will be sent through that gateway and other interface ip can not be accessible there.
Easy to suggest when don't know about the problem!
Steven E. Protter
Exalted Contributor

Re: Make a linux box as a simple router

I have four Linux boxes that act as routers.

To have a secure router to the public Internet, you need a few things:

The gateway must be set up as discussed in prior posts on the NIC on the public Internet.

The PC's should have(this varies by isp) /etc/resolv.conf or for Windows DNS information for the outside ISP DNS name servers.

You need to turn on IP forwarding on the Linux box.
echo 1 > /proc/sys/net/ipv4/ip_forward

This document explains the setup either with ipchains(obsolete) or iptables

http://www.yolinux.com/TUTORIALS/LinuxTutorialIptablesNetworkGateway.html

Basically you need to set up SNAT NAT Address translation on the Linux box, this will enable it to handle Internet traffic on your network with stateless connection.

I can give you more direction once you've gotten some of the work above done.

SEP

Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
yongye_1
Advisor

Re: Make a linux box as a simple router

Hi,

Thanks for your response.

I add the default gw 10.0.0.2 on 10.0.0.3.Followed lines are output on 10.0.0.3 by issueing netstat -r
[root@lvs root]# netstat -r
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
10.0.0.0 * 255.255.255.0 U 0 0 0 eth0
169.254.0.0 * 255.255.0.0 U 0 0 0 eth0
127.0.0.0 * 255.0.0.0 U 0 0 0 lo
default 10.0.0.2 0.0.0.0 UG 0 0 0 eth0

But the problem still exist.

If I set up the static route table on 10.0.0.3 as Muthukumar said. Not using default gw on 10.0.0.3. Followed lines are output from netstat -r
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
10.0.0.0 10.0.6.212 255.255.255.0 UG 0 0 0 eth0
10.0.0.0 * 255.255.255.0 U 0 0 0 eth0
169.254.0.0 * 255.255.0.0 U 0 0 0 eth0
127.0.0.0 * 255.0.0.0 U 0 0 0 lo

The problem still here.
And I disabled the firewall on all machines.

Yongye
Muthukumar_5
Honored Contributor

Re: Make a linux box as a simple router

Lets analyse with examples here.

Pc1 = 10.0.0.3
----------------
10.0.0.0 * 255.255.255.0 U 0 0 0 eth0
169.254.0.0 * 255.255.0.0 U 0 0 0 eth0
127.0.0.0 * 255.0.0.0 U 0 0 0 lo
default 10.0.0.2 0.0.0.0 UG 0 0 0 eth0

There is no entries regarding routing of 192.0.0.* networks so that it will be routed with 10.0.0.2 entry.

Try to make an arrangement as,

10.0.0.3 10.0.0.3
10.0.0.0 10.0.0.2
192.168.0.2 192.168.0.1
192.168.0.0 192.168.0.1
other entries there...

Rules are as,
route add -host 192.168.0.2 netmask 255.255.0.0 gw 192.168.0.1

--> metric try with 1 / 0

route add -net 192.162.0.0 gw 192.168.0.1

PS. I am not having machine to check metric so try with 0 / 1 there upto get add entry ..... there.
Easy to suggest when don't know about the problem!
Muthukumar_5
Honored Contributor

Re: Make a linux box as a simple router

When you are maintaing router with multiple interface and ip's there then,

1. Please use same ip-address there to avoid confusion there with different network there.

Example: 10.0.0.2/24 192.168.0.1/24 confusing there. try to use as,
10.0.0.2/24 192.168.0.1/24 or vice versa

2. Routing for different interface / network ip must need routing entry there on routing table. Else it will try to use default gateway there. IT will be sent there but on gateway it don't know how to go next there.

After routing table entry check as,

traceroute

To analyse which path it is going there with out simply using ping there.

3. Put associate routing entries for every network / ip-address with out sending them using default gateway. It will be the main problem when using multiple interface on router there.
Easy to suggest when don't know about the problem!
Muthukumar_5
Honored Contributor

Re: Make a linux box as a simple router

Say your network routing as,

PC Router
10.0.0.0, * ----> 10.0.0.2
192.168.0.1

* means every other ip-address / network. So it don't know how to reach 192.168.0.* network there. So add an entry in pc as,

route add -net 192.168.0.0 netmask 255.255.0.0 gw 192.168.0.1

IT will give you a chance to reach 192.168.*.* networks there easily.

If you need clarfication then ping (traceroute) us :-)
Easy to suggest when don't know about the problem!
yongye_1
Advisor

Re: Make a linux box as a simple router

Hi,

Thank you for your advice.

But I think on the pc(10.0.0.3).Adding the default gw(10.0.0.2) is enough. How to arrive 192.168.0.2 is the router's job. So I think it is not necessary to adding routeing table(192.168.0.0) on pc(10.0.0.3).

Yongye
Muthukumar_5
Honored Contributor

Re: Make a linux box as a simple router

Let's go in your way,

what are you getting when you try with yoru default routing to 10.0.0.2 for,

traceroute 192.168.0.2
traceroute 192.168.0.1
traceroute 10.0.0.3
traceroute 10.0.0.2

It is good to know your routing information's there.
Easy to suggest when don't know about the problem!