S
S
Sinot2015-03-30 22:25:52
linux
Sinot, 2015-03-30 22:25:52

How to connect two networks through a third?

Greetings.
The network 192.168.0.0/22 ​​has several PCs and a Windows XP gateway (192.168.0.1). On the same network, there is a virtual machine on Debian (eth0 192.168.2.6), on the same virtual machine there is another interface eth1 172.16.16.1 (172.16.16.0/29). This network has a piece of iron (172.16.16.2) if you specify it as a gateway, then node 172.20.82.1 will be available. You can’t configure the piece of iron (but 172.16.16.1 is registered on it as a gateway).
Actually how to get access to this node (172.20.82.1) from the network 192.168.0.0/22?
I tried to configure both routes and port forwarding (PCs on the 192.168.0.0/22 ​​network work with 172.20.82.1, thinking that it is 192.168.2.6, this option will also suit), but nothing worked out for me.
Thank you.
UPD 1
route on Debian:

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
172.20.82.1     172.16.16.2     255.255.255.255 UGH   0      0        0 eth1
172.16.16.0     0.0.0.0         255.255.255.248 U     0      0        0 eth1
192.168.0.0     0.0.0.0         255.255.252.0   U     0      0        0 eth0

iptables is empty and everything is allowed.
On a machine in the network 192.168.0.0/22, if you register the gateway 192.168.2.6 or add routes:
route add 172.16.16.0 mask 255.255.255.248 192.168.2.6
route add 172.20.82.1 192.168.2.6

The network 172.16.16.0/29 is visible, pings pass. But 172.20.82.1 is not visible.
Actually, this is where I stopped. Is there any reason to believe that something is configured wrong on the piece of iron? It is not yet possible to view its settings.
UDP 2
I registered a masquerade on Debian and it all worked:
iptables -t nat -A POSTROUTING -o eth1 -s 192.168.0.0/22 -d 172.20.82.1 -j MASQUERADE

On the Windos XP gateway (192.168.0.1) I wrote:
route add 172.20.82.1 192.168.2.6
And now the machines on the network 192.168.0.0/22 ​​now also see 172.20.82.1

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Valentin, 2015-03-30
@vvpoloskin

Get used to drawing diagrams, then you will get high-quality answers. According to the subject from what I understood:
1) check whether everything is allowed on the virtual machine in IPTABLES in ALL chains, primarily FORWARDING. Check if forwarding is enabled on it (/proc/sys/net/ipv4/ip_forward)
2) check the routes on the hardware, maybe it's not default on it?
3) temporarily forget about the win xp gateway and install a virtual machine for everyone as a gateway
4) if it doesn’t work, try to run ping from the virtual machine with the source address 192.168.2.6 parameter

R
Rsa97, 2015-03-30
@Rsa97

1. On the network 192.168.0.0/22 ​​on all Windows computers, add a permanent route
2. On Debian, enable routing by writing in the /etc/sysctl.conf file
Add a route to the /etc/network/interfaces file for the eth1 interface
Run the same commands so as not to restart the server

# sysctl net.ipv4.ip_forward=1
# route add 172.20.82.1 gw 172.16.16.2

In theory, everything should work.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question