How to route between 2 networks (RH 7.3)?

How to route between 2 networks (RH 7.3)?

Post by Mario Niessn » Tue, 10 Sep 2002 05:30:03



I have the following situation:

There's a network (192.168.0.0) with internet access via gateway
192.168.0.1.

My computer (PC1 - 192.168.0.25) has RH 7.3 installed, everything
works great. I've added a second NIC (192.168.2.1) to this PC, and
attached a second PC (PC2 - 192.168.2.2) to this NIC. All services
work between PC1 and PC2, but I cannot ping any machine on the
192.168.0.0 network from PC2 (except for PC1), much less getting
internet access from the PC2 machine (which pings 192.168.2.1 and
192.168.0.25, both NICs in the PC1 computer but nothing beyond it).

Question is, how do I turn the PC1 machine into a router for the
192.168.2.0 network?

Regards
Mario

 
 
 

How to route between 2 networks (RH 7.3)?

Post by Volker Floh » Tue, 10 Sep 2002 07:24:10



> There's a network (192.168.0.0) with internet access via gateway
> 192.168.0.1.

> My computer (PC1 - 192.168.0.25) has RH 7.3 installed, everything
> works great. I've added a second NIC (192.168.2.1) to this PC, and
> attached a second PC (PC2 - 192.168.2.2) to this NIC. All services
> work between PC1 and PC2, but I cannot ping any machine on the
> 192.168.0.0 network from PC2 (except for PC1), much less getting
> internet access from the PC2 machine (which pings 192.168.2.1 and
> 192.168.0.25, both NICs in the PC1 computer but nothing beyond it).

k...first let me try to understand what you mean

internet --> 192.168.0.1 --> your PC (0.25) --> second PC

right?

You will need:
- no routing on router (should be already be set up)
- routing on PC2 (--> set PC1 as gateway)
- enable forward in krnl (  echo 1 >/proc/sys/net/ipv4/ip_forward
 )
- enable masquerading on router (the network 192.168.0.0/24 should not know
about your PC2 and so pakets could not be dilivered without masquerading)
 ( iptables -t nat -A POSTROUTING -i <int_NIC> -o <ext_NIC> -j MASQUERADE)
- enable forward ( iptables -A FORWARD -i <int_NIC> -j ACCEPT )

this is just the basic setup without any firewalling, but it should work

Volker

 
 
 

How to route between 2 networks (RH 7.3)?

Post by Mario Niessn » Wed, 11 Sep 2002 01:21:57




> > There's a network (192.168.0.0) with internet access via gateway
> > 192.168.0.1.

> > My computer (PC1 - 192.168.0.25) has RH 7.3 installed, everything
> > works great. I've added a second NIC (192.168.2.1) to this PC, and
> > attached a second PC (PC2 - 192.168.2.2) to this NIC. All services
> > work between PC1 and PC2, but I cannot ping any machine on the
> > 192.168.0.0 network from PC2 (except for PC1), much less getting
> > internet access from the PC2 machine (which pings 192.168.2.1 and
> > 192.168.0.25, both NICs in the PC1 computer but nothing beyond it).

> k...first let me try to understand what you mean

> internet --> 192.168.0.1 --> your PC (0.25) --> second PC

> right?

> You will need:
> - no routing on router (should be already be set up)
> - routing on PC2 (--> set PC1 as gateway)
> - enable forward in krnl (  echo 1 >/proc/sys/net/ipv4/ip_forward
>  )
> - enable masquerading on router (the network 192.168.0.0/24 should not know
> about your PC2 and so pakets could not be dilivered without masquerading)
>  ( iptables -t nat -A POSTROUTING -i <int_NIC> -o <ext_NIC> -j MASQUERADE)
> - enable forward ( iptables -A FORWARD -i <int_NIC> -j ACCEPT )

> this is just the basic setup without any firewalling, but it should work

> Volker

Thank you very much Volker, I really appreciate your help.

Regarding this issue, for future posters,

the iptables -t nat -A POSTROUTING -i <int_NIC> -o <ext_NIC> -j
MASQUERADE
command apparently has to be split in two (the POSTROUTING chain won't
take -i incoming_eth as a parameter).

iptables -t nat -A PREROUTING -i <int_NIC>
iptables -t nat -A POSTROUTING -o <ext_NIC> -j MASQUERADE

and, particularly for RedHat 7.3, you should check that it doesn't
start the ipchains script and that it does start the iptables script
at boot time, otherwise the iptables command won't work.

Mario

 
 
 

How to route between 2 networks (RH 7.3)?

Post by Jerry She » Wed, 11 Sep 2002 01:26:07


How do you get that forwarding in the kernel to be enabled at boot
without just putting that echo statement in the rc.local script.  I
put 'FORWARD_IPV4="yes"' in /etc/sysconfig/network but that didn't
seem to do the trick.


> > There's a network (192.168.0.0) with internet access via gateway
> > 192.168.0.1.

> > My computer (PC1 - 192.168.0.25) has RH 7.3 installed, everything
> > works great. I've added a second NIC (192.168.2.1) to this PC, and
> > attached a second PC (PC2 - 192.168.2.2) to this NIC. All services
> > work between PC1 and PC2, but I cannot ping any machine on the
> > 192.168.0.0 network from PC2 (except for PC1), much less getting
> > internet access from the PC2 machine (which pings 192.168.2.1 and
> > 192.168.0.25, both NICs in the PC1 computer but nothing beyond it).

> k...first let me try to understand what you mean

> internet --> 192.168.0.1 --> your PC (0.25) --> second PC

> right?

> You will need:
> - no routing on router (should be already be set up)
> - routing on PC2 (--> set PC1 as gateway)
> - enable forward in krnl (  echo 1 >/proc/sys/net/ipv4/ip_forward
>  )
> - enable masquerading on router (the network 192.168.0.0/24 should not know
> about your PC2 and so pakets could not be dilivered without masquerading)
>  ( iptables -t nat -A POSTROUTING -i <int_NIC> -o <ext_NIC> -j MASQUERADE)
> - enable forward ( iptables -A FORWARD -i <int_NIC> -j ACCEPT )

> this is just the basic setup without any firewalling, but it should work

> Volker

 
 
 

How to route between 2 networks (RH 7.3)?

Post by Volker Floh » Wed, 11 Sep 2002 01:39:31



> command apparently has to be split in two (the POSTROUTING chain won't
> take -i incoming_eth as a parameter).

> iptables -t nat -A PREROUTING -i <int_NIC>
> iptables -t nat -A POSTROUTING -o <ext_NIC> -j MASQUERADE

yap... my fault... I use it with -s and a mask instead of -i

such things happen if I'm first writing and then thinking... ;)

Volker

 
 
 

How to route between 2 networks (RH 7.3)?

Post by Volker Floh » Wed, 11 Sep 2002 02:10:02



> How do you get that forwarding in the kernel to be enabled at boot
> without just putting that echo statement in the rc.local script.  I
> put 'FORWARD_IPV4="yes"' in /etc/sysconfig/network but that didn't
> seem to do the trick.

Did you run the script to actualize config after this change?
In SuSE for example you have to run SuSEconfig after this to make the
changes work.

Well, I prefer using echo in script, because I have more control that way
about the behaviour of the router in boot-process. I don't put in in
rc.local, too. It is just part of my firewall-scrips because without
firewall I don't like to have something forwarded ;)

To have IP_FORWARD always enabled I think you can compile a kernel, which
has this option on 'enabled' by default. But this kind of kernel hacking is
no a good solution in my eyes, especially because forwarding is not an
option in the kernelconfig, so you would have to change the sourcefiles as
far as I know.
Better try to find out where the problem with /etc/sysconfig/network is
located and how to fix it.

Volker

 
 
 

1. Networking ssues post RH 7.3 to RH 9.0

|The system responds to all request on LOCAL HOST (SMTP, HTTP, DNS)
|but network request on ETH0 are un answered.   Also PING fails to
|reach the gateway  or any other machine on the network.
|
|Any suggestions for fixing this would be appreciated.

Sounds like you have the firewall active. I don't use RH, but I'm sure
thre's a GUI tool to monitor and configure it.
--

2. charset windows-874

3. routing problem help on RH 7.3

4. optimization- help!

5. RH 7.3 ipchains routing, timing out...

6. Lib error while trying to run Netscape--PLEAASE HELP!!

7. Kernel recompile loses networking, RH 7.3

8. Morse Telecom's WWW server now online

9. network gui tool RH 7.3

10. RH 7.3 network install fails, NE2000, DHCP

11. RH 7.3 reboot needed after network disconnect.

12. Networking Trouble in RH 7.3

13. HELP! - Configuring RH 7.3 with Wireless Networking