I can't find a solution in a network like in the drawing below.
- I need to be able to open admin page of router 2 on LAN2 from a pc in a LAN1, w/o routing throught Internet.
- I have a "bridge" PC with 2 NIC and linux (Debian) and I can doing everything on it.
I would like that from any PC connected to LAN 1 it's possible to access port 80 of the LAN 2 router.
Internet 1 Internet 2
! !
+---------------------+ +---------------------+
| Router 1 | | Router 2 |
| LAN 192.168.55.1/24 | | LAN 192.168.2.1/24 |
| | | |
+---------------------+ +---------------------+
| |
| |
| +-----------------------+ |
| | | |
| | BRIDGE | |
|-------|eth0 | |
| |192.168.55.2 eth1|---|
| | 192.168.2.2| |
| +-----------------------+ |
| |
| |
Other clients other clients
LAN 1 LAN 2
The idea is to set a port (example 8080) on eth0, of the (PC) "bridge" and exit on eth1 on LAN 2 to the IP of the router 192.168.2.1:80
The answer from 192.168.2.1 would not go through the gateway but would go back to eth1. After manipulation, the IP pachet come out from eth0. The "bridge" should replace the source address, as if it originated from 192.168.55.2.
I've done a lot of testing, but I can't find a solution with various test with iptables settings.
Obviously, I enabled ip_forward = 1 and I set iptables so.
iptables -A FORWARD -i eth0 -o eth1 -p tcp --dport 8080 -j ACCEPT
iptables -A PREROUTING -t nat -p tcp -i eth0 --dport 8080 -j DNAT --to 192.168.2.1:80
and forwarding:
sysctl -a | grep "\.forwarding" | grep ipv4
sysctl: reading key "net.ipv6.conf.all.stable_secret"
sysctl: reading key "net.ipv6.conf.default.stable_secret"
sysctl: reading key "net.ipv6.conf.eth0.stable_secret"
sysctl: reading key "net.ipv6.conf.lo.stable_secret"
sysctl: reading key "net.ipv6.conf.wlan0.stable_secret"
net.ipv4.conf.all.forwarding = 1
net.ipv4.conf.default.forwarding = 1
net.ipv4.conf.eth0.forwarding = 1
net.ipv4.conf.lo.forwarding = 1
net.ipv4.conf.wlan0.forwarding = 1
has anyone had a similar problem and can you give me a hint?
Thanks in advance!