LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Routing 2 Internal Networks (https://www.linuxquestions.org/questions/linux-networking-3/routing-2-internal-networks-878214/)

nytram1984 05-01-2011 07:17 PM

Routing 2 Internal Networks
 
Hi dudes and dudettes,

Im a computer networking student in my 3rd year and most of it has been based on windows, just completed a Unix Systems Administration course at my University and decided to take the skills home with me, but I have a slight problem and Ive been racking my brains out trying to figure it out.

I have 2 Networks in my home and im trying to get connectivity between the 2 networks but to no success, so I come here and bow in the knowledge of a Guru to help my case

Network Set up

Network A
Network: 192.168.2.0 /24
Computer 1A - Windows 7
Computer 2A - Ubuntu 11.04 (2 Nics and file sharing with samba)
All Machines are connected Via a Switch which in turn is Connected to a SOHO router for internet access (default gw 192.168.2.254)

Network B
Network: 192.168.1.0 /24
Computer 1B - Windows 7
Computer 2B - Windows 7
Computer 3B - Windows XP
All Machines are connected wirelessly to a SOHO router for internet access (default gw 192.168.1.254

These 2 networks have 2 seperate ISP connections

Objective:
Allow hosts on Network A to see hosts on Network B (networking->windows network) and vice versa

I want to be set my Ubuntu box up as a central location for file sharing and have installed SAMBA.

Problem:
My Ubuntu box has 2 NIC's eth0 is connected to Network A wlan0 is connected to Network B
I can reach both gateways on the Ubuntu box, but can not access both gateways from Network A clients or network B clients

With Windows 2003, routing and remote access with RIP took care of this for me, but on linux, I am lost. If someone would be kind enough to help my understanding it would be ever so greatfull!

Thank you in Advance
//Martyn

T3RM1NVT0R 05-01-2011 07:46 PM

@ Reply
 
Hi there,

Things to check:

1. Check whether IP forwarding is enabled on your Ubuntu system or not. You can check it using cat /proc/sys/net/ipv4/ip_forward. If not then enable it by using the following command echo 1 > /proc/sys/net/ipv4/ip_forward

2. As you said that your Ubuntu system has got two NICs that means it is acting as a central location. Are all host in Network A set to use default route to this Ubuntu machine? Is Ubuntu machine setup to forward the traffic from machines in Network A to SOHO router?

3. On your Ubuntu system the default route should be 192.168.2.254. Is this setup correctly. Check by typing route.

4. Also let us know the configuration of Ubuntu system eth0 and eth1. I think we need to create an static route to network B but can't comment on that before we see the ethernet configuration of your Ubuntu system.

5. Also let us know the ip configuration of any machine from Network B.

nytram1984 05-01-2011 08:40 PM

Thanks for your prompt response T3RM1NVT0R,

1. I found this command searching the net and have done this.

2. I'm not entirely sure on this, the default gateway on network a clients points to 192.168.2.254, the clients on network be use the 192.168.1.254 default gateway.

3. The ubuntu machine is set to use 192.168.2.254 as its default gateway and has Internet connectivity, which can ping both Network A and Network B clients successfully and can access both routers.

4. eth0 is set to use 192.168.2.100
I used these commands:
ifconfig eth0 192.168.2.100 netmask 255.255.255.0
route add default gw 192.168.2.254 eth0

wlan0 is set to use 192.168.1.100
ifconfig wlan0 192.168.1.100 netmask 255.255.255.0
route add default gw 192.168.1.254 wlan0

5. Machines on network A have these settings

Machine 1: 192.168.2.10 /24 default gw 192.168.2.254
Machine 2: Shown above eth0 & wlan0

Machines on network B have these settings

Machine 1: 192.168.1.10 /24 default gw 192.168.1.254
Machine 2: 192.168.1.11 /24 default gw 192.168.1.254


Apart from that the settings haven't been modified or altered in any shape or form, I tried this:

route add 192.168.1.0 netmask 255.255.255.0 eth0
route add 192.168.2.0 netmask 255.255.255.0 wlan0

Figuring if i put the networks into the routing table it might have done the trick, obviously not :p

I'm sure its something relativity simple, with the said settings, what should should the routing table look like? I'm not sure what should be pointing to where, Microsoft made this a little too easy and now I feel like rereading first years ccna exploration all over again. I also did some arp-proxy command which I forget now :(

Being in the UK, my girlfriend has requested I shut off my ubuntu box because the fans keep her awake so I cant show you the output from route, essentially, the ubuntu box is just acting like a client with samba file sharing on it, all i need to do is getting network a from eth0 talking to network b on wlan0.

Thanks for your kind words of wisdom and its amazing how open source operating systems have much more support than the likes of microsoft.

T3RM1NVT0R 05-01-2011 09:17 PM

@ Reply
 
As you said that your Ubuntu system is acting as a client but in real it can also act as a communicator between Network A and B the only thing that we need to establish is whether hosts from Network B can ping Ubuntu system or not.

From what you said the picture that comes to my mind is as follows:

1. Network A hosts can communicate among themselves and are able to get on to internet.
2. Network A hosts cannot communicate to Network B hosts.
3. Ubuntu system which is in network A can communicate to both routers and can ping network B clients successfully. That implies that network B hosts can also communicate to Ubuntu system. You have to check and confirm to us.
4. Network B hosts can get on to internet.
5. Network B hosts cannot communicate to Network A hosts.

Suggestions:

1. Make your Network A hosts default route to be Ubuntu eth0 which is in Network A. This will do two things. First of all traffic will go through Ubuntu system. Even if Network A host require internet access then there is a default route set on Ubuntu system to route traffic which is not specifically mentioned in routing table to default route 192.168.2.254 (Internet).

2. Add a static route entry on Ubuntu system: route add -net 192.168.1.0 gw 192.168.2.100 (Ubuntu system IP)

I hope the above should do the trick. If not then share your routing table with us and then we might be able to further narrow down the issue.

nytram1984 05-01-2011 09:29 PM

Yet again, Thank you for your quick response!

I will have to goto sleep for now! But I will reply as soon as I come back from work tommorow, Yet again, much appreciated and thank you for spending time in replying!

1-5 are all correct and Network B Clients can ping the Ubuntu machine

Its weird because originally I had 2 nics in one of my windows machines and shared it over the Network using windows sharing and Network B clients could see the share.

thanks again and ill get back to you,
Eye-shutting-must-sleep
init 0

nytram1984 05-02-2011 01:08 PM

This is getting rather annoying :(

Code:

Kernel IP routing table
Destination    Gateway        Genmask        Flags Metric Ref    Use Iface
192.168.2.0    *              255.255.255.0  U    1      0        0 eth0
192.168.1.0    *              255.255.255.0  U    2      0        0 wlan0
link-local      *              255.255.0.0    U    1000  0        0 eth0
default        192.168.2.254  0.0.0.0        UG    0      0        0 eth0


Topology Diagram
Code:

      Machine 1
eth0  192.168.2.10-----|
                      |
      Machine 2      |---- Switch ----192.168.2.254 ----- Internet Access
eht0  192.168.2.100----|

wlan0 192.168.1.100   
          |
        Switch------------------------Machine 3
          |                      |
    192.168.1.254                ----Machine 4
          |
    Internet Access

Machine 1 can ping 192.168.2.254 and has internet access
Machine 2 can ping 192.168.1.254 & 192.168.2.254 and has internet access
Machine 3 can ping 192.168.1.254 and has internet access
Machine 4 can ping 192.168.1.254

Problem
Machine 1 can not ping 192.168.1.254 or reach clients 3 and 4
Machines 3 and 4 can not ping 192.168.2.254 or reach client 1

T3RM1NVT0R 05-02-2011 01:30 PM

@ Reply
 
Quote:

Originally Posted by nytram1984 (Post 4344154)
This is getting rather annoying :(

Code:

Kernel IP routing table
Destination    Gateway        Genmask        Flags Metric Ref    Use Iface
192.168.2.0    *              255.255.255.0  U    1      0        0 eth0
192.168.1.0    *              255.255.255.0  U    2      0        0 wlan0
link-local      *              255.255.0.0    U    1000  0        0 eth0
default        192.168.2.254  0.0.0.0        UG    0      0        0 eth0


Topology Diagram
Code:

      Machine 1
eth0  192.168.2.10-----|
                      |
      Machine 2      |---- Switch ----192.168.2.254 ----- Internet Access
eht0  192.168.2.100----|
wlan0 192.168.1.100
          |
          |
        Switch------------------------Machine 3
          |                      |
    192.168.1.254                ----Machine 4
          |
    Internet Access


Machine 1 can ping 192.168.2.254 and has internet access
Machine 2 can ping 192.168.1.254 & 192.168.2.254 and has internet access
Machine 3 can ping 192.168.1.254 and has internet access
Machine 4 can ping 192.168.1.254

Problem
Machine 1 can not ping 192.168.1.254 or reach clients 3 and 4
Machines 3 and 4 can not ping 192.168.2.254 or reach client 1

Routing table I guess is from Ubutu system?

Machine 1 can ping 192.168.2.254 and has internet access

This is just a client machine from 192.168.2.0 subnet.

Machine 2 can ping 192.168.1.254 & 192.168.2.254 and has internet access

This is your Ubuntu system?

Machine 3 can ping 192.168.1.254 and has internet access

Client machine on 192.168.1.0 network.

Machine 4 can ping 192.168.1.254

Client machine on 192.168.1.0 network and I think this machine also have the internet access?

Machine 1 can not ping 192.168.1.254 or reach clients 3 and 4

As stated before this is just a client machine and for this machine I guess default route is set to 192.168.2.254. I am quite sure that Machine 2 is Ubuntu machine and it can reach both the networks.

Machines 3 and 4 can not ping 192.168.2.254 or reach client 1

No route defined, they wont be able to reach client 1.

Suggestions:

From the routing table you pasted you require to do the following:

1. Make sure that ip forwarding is enabled. I have mentioned that in my previous posts.
2. Since your Ubuntu machine is able to get on internet and is able to access machines on both subnets. Change Machine 1 IP default route to Ubuntu system i.e. 192.168.2.100 and see if this establishes communication between Machine 1 and internet and Machine 1 and network 192.168.1.100

nytram1984 05-02-2011 01:39 PM

Machine 2 is my Ubuntu system, correct.
I have enabled IP routing.
I added the default route (Windows machine so presuming its the default gateway?)
Machine 1 now has no internet access nor can ping any clients in 192.168.1.100 network

T3RM1NVT0R 05-02-2011 01:57 PM

@ Reply
 
Quote:

Machine 2 is my Ubuntu system, correct.
I have enabled IP routing.
I added the default route (Windows machine so presuming its the default gateway?)
Machine 1 now has no internet access nor can ping any clients in 192.168.1.100 network
Let us know the following:

1. Is Machine 1 able to ping eth1 on Machine2.
2. Run a tracert on Machine 1. tracert www.google.com and tracert 192.168.1.254.
2. When you say that you have enabled IP routing can you please paste the output of cat /proc/sys/net/ipv4/ip_forward
3. Also add a static route on Ubuntu machine route add -net 192.168.1.0 gw 192.168.2.100
4. Keep the default route setting on Machine 1 to be 192.168.2.100. Reboot Machine 1 and see if Machine 1 is able to get to clients on 192.168.1.0 network.

nytram1984 05-02-2011 02:47 PM

1. yes
2. first hop is 192.168.2.254 then packets hopped externally
3.
Code:

root@Antec-RBox:# cat /proc/sys/net/ipv4/ip_forward
1
root@Antec-RBox:#

4.
Code:

Kernel IP routing table
Destination    Gateway        Genmask        Flags Metric Ref    Use Iface
192.168.2.0    192.168.1.100  255.255.255.0  UG    0      0        0 wlan0
192.168.2.0    *              255.255.255.0  U    1      0        0 eth0
192.168.1.0    192.168.2.100  255.255.255.0  UG    0      0        0 eth0
192.168.1.0    *              255.255.255.0  U    2      0        0 wlan0
link-local      *              255.255.0.0    U    1000  0        0 eth0
default        192.168.2.254  0.0.0.0        UG    0      0        0 eth0

Outcome of this is that no connectivity at all is allowed on machine 2

also tried
Code:

Kernel IP routing table
Destination    Gateway        Genmask        Flags Metric Ref    Use Iface
192.168.2.0    192.168.1.254  255.255.255.0  UG    0      0        0 wlan0
192.168.2.0    *              255.255.255.0  U    1      0        0 eth0
192.168.1.0    192.168.2.254  255.255.255.0  UG    0      0        0 eth0
192.168.1.0    *              255.255.255.0  U    2      0        0 wlan0
link-local      *              255.255.0.0    U    1000  0        0 eth0
default        192.168.2.254  0.0.0.0        UG    0      0        0 eth0

Outcome of this is also no external connectivity

Also tried
Code:

Kernel IP routing table
Destination    Gateway        Genmask        Flags Metric Ref    Use Iface
192.168.2.0    192.168.2.254  255.255.255.0  UG    0      0        0 eth0
192.168.2.0    *              255.255.255.0  U    1      0        0 eth0
192.168.1.0    192.168.1.254  255.255.255.0  UG    0      0        0 wlan0
192.168.1.0    *              255.255.255.0  U    2      0        0 wlan0
link-local      *              255.255.0.0    U    1000  0        0 eth0
default        192.168.2.254  0.0.0.0        UG    0      0        0 eth0

Outcome of this is as if I never added anything at all.
Code:

Kernel IP routing table
Destination    Gateway        Genmask        Flags Metric Ref    Use Iface
192.168.2.0    192.168.2.100  255.255.255.0  UG    0      0        0 eth0
192.168.2.0    *              255.255.255.0  U    1      0        0 eth0
192.168.1.0    192.168.1.100  255.255.255.0  UG    0      0        0 wlan0
192.168.1.0    *              255.255.255.0  U    2      0        0 wlan0
link-local      *              255.255.0.0    U    1000  0        0 eth0
default        192.168.2.254  0.0.0.0        UG    0      0        0 eth0

Also no connectivity at all

I have tried numerous entries and routes, but none of them seem to work, I have nuked my logical thinking to its maximum and yet I cant do this simple task!

I could just plug the wireless adapter onto machine 1 which would then pick up both internal networks and allow samba sharing but I don’t want to have 2 computers switched on for this service.

There must be a simple and logical way to get eth0 and wlan0 to have windows equivalent "File and Network sharing" or Routing and Remote access.

I've had a few of my friends who are network ops from IRC have a look at this as well and they also cant seem to get it.

T3RM1NVT0R 05-02-2011 03:08 PM

@ Reply
 
192.168.2.0 192.168.1.100 255.255.255.0 UG 0 0 0 wlan0
192.168.2.0 * 255.255.255.0 U 1 0 0 eth0
192.168.1.0 192.168.2.100 255.255.255.0 UG 0 0 0 eth0
192.168.1.0 * 255.255.255.0 U 2 0 0 wlan0
link-local * 255.255.0.0 U 1000 0 0 eth0
default 192.168.2.254 0.0.0.0 UG 0 0 0 eth0

Why you added destination 192.168.2.0 via 192.168.1.100 this is wrong the only route that you need to add is 192.168.1.0 via 192.168.2.100. Remove the top entry and I hope that the Ubuntu system should have internet connectivity after that.

Also when you say 1st HOP is 192.168.2.254 and then next is externally. This is when you are using 192.168.2.254 as default gateway on Machine 1. Set the default gateway on Machine 1 to be 192.168.2.100 and then run tracert.

In addition to where we were yesterday is that all clients can atleast access internet.

The suggest that I gave yesterday to just add a static route entry to 192.168.1.0 network via 192.168.2.100 i.e. your Ubuntu machine and point your client on network 192.168.2.0 network to use Ubuntu system as a router.

nytram1984 05-02-2011 03:16 PM

Quote:

Originally Posted by T3RM1NVT0R (Post 4344276)
192.168.2.0 192.168.1.100 255.255.255.0 UG 0 0 0 wlan0
192.168.2.0 * 255.255.255.0 U 1 0 0 eth0
192.168.1.0 192.168.2.100 255.255.255.0 UG 0 0 0 eth0
192.168.1.0 * 255.255.255.0 U 2 0 0 wlan0
link-local * 255.255.0.0 U 1000 0 0 eth0
default 192.168.2.254 0.0.0.0 UG 0 0 0 eth0

Why you added destination 192.168.2.0 via 192.168.1.100 this is wrong the only route that you need to add is 192.168.1.0 via 192.168.2.100. Remove the top entry and I hope that the Ubuntu system should have internet connectivity after that.

Also when you say 1st HOP is 192.168.2.254 and then next is externally. This is when you are using 192.168.2.254 as default gateway on Machine 1. Set the default gateway on Machine 1 to be 192.168.2.100 and then run tracert.

so now my routing table should look like this?
Code:

Destination    Gateway        Genmask        Flags Metric Ref    Use Iface
192.168.2.0    *              255.255.255.0  U    1      0        0 eth0
192.168.1.0    192.168.2.100  255.255.255.0  UG    0      0        0 eth0
192.168.1.0    *              255.255.255.0  U    2      0        0 wlan0
link-local      *              255.255.0.0    U    1000  0        0 eth0
default        192.168.2.254  0.0.0.0        UG    0      0        0 eth0


T3RM1NVT0R 05-02-2011 03:18 PM

Quote:

so now my routing table should look like this?
Code:

Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.2.0 * 255.255.255.0 U 1 0 0 eth0
192.168.1.0 192.168.2.100 255.255.255.0 UG 0 0 0 eth0
192.168.1.0 * 255.255.255.0 U 2 0 0 wlan0
link-local * 255.255.0.0 U 1000 0 0 eth0
default 192.168.2.254 0.0.0.0 UG 0 0 0 eth0
Yes, also I edited my last post please have a look.

nytram1984 05-02-2011 03:26 PM

Ok, Machine 1 now has 192.168.2.100 set as its default gateway and has internet connectivity. 1st hope is 192.168.2.100
Pinging 192.168.1.254 from machine 1 shows that "Destination host unreachable" rather than "request timed out"

T3RM1NVT0R 05-02-2011 03:33 PM

@ Reply
 
Great that we have internet connectivity on Machine 1 with default gateway set to 192.168.2.100

You said that Machine 1 when tries to ping 192.168.1.254 you get destination host unreachable.

Run a tracert from this machine as it would be interested to see which route it is taking to reach there where it fails.


All times are GMT -5. The time now is 02:12 AM.