routing

Asked by De Noel

I 'am newby in routin and Ubuntu.
I need help to connect two networks.
I have a Ubuntu PC with 2 networkinterfaces

eth0
192.168.146.1
255.255.255.0
GW 192.168.146.107

eth1
192.168.145.1
255.255.255.0

Users from network 192.168.145.0 has to reach other computers in the network 192.168.146.0 and even go to internet over the gateway 192.168.146.107

Users from 192.168.146.0 has to reach computers in the 192.168.145.0 network (I understand that I have to install a default route on this computers in network 146.0)

what I have to do that routing function well between this two networks

thx for you help

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu gnome-nettool Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Hilario J. Montoliu (hjmf) (hmontoliu) said :
#1

You need to provide router for both networks and allow IP forwarding from eth1 to eth0

This is what I would have done (of course, not tested)

ifconfig 192.168.146.1/24 eth0 up
ifconfig 192.168.145.1/24 eth1 up
route add default gw 192.168.146.107 eth0
echo 1 > /proc/sys/net/ipv4/ip_forward
/sbin/iptables --append FORWARD --in-interface eth1 -j ACCEPT

You'll need more tweaks if you want things like nat etc.

Obviously those commands are for you to test, you'll need to place the settings in their propper files

HTH

Revision history for this message
Hilario J. Montoliu (hjmf) (hmontoliu) said :
#2

Hi again,

I've posted the message with my laptop battery almost exhausted :-)

Now with a little more time I want to add a couple of things:

Probably you'll need to add a rule like:

/sbin/iptables --append FORWARD --in-interface eth0 -j ACCEPT

to allow traffic in the other way

Also, you should configure the devices in the network 192.168.146.0 with their DEFAULT GW pointing to the 192.168.146.107 IP, but you'll need to add an additional router to each one that uses 192.168.146.1 as GW for the 192.168.145.0 network.

For the devices in the network 192.168.145.0 will be enough to configure each one to use as the DEFAULT GW the IP 192.168.145.1. They will reach both the devices in 192.168.146.0 and the WAN destinations

HTH

Can you help with this problem?

Provide an answer of your own, or ask De Noel for more information if necessary.

To post a message you must log in.