2
1
I have a linux machine with 2 network connections, wlan0 and eth0. Through wlan0, the linux machine is connected to the router, and through eth0, the linux machine is connected to the IP camera (via a network switch).
From a windows machine on the same network as wlan0, I connect to the linux machine using putty. How can I connect to the ipcamera on eth0, through my windows machine connected via wlan0?
IP of my linux machine, connected via wlan0 is 192.168.100.10 (gateway: 192.168.100.1)
IP of IP camera, connected to linux machine via eth0, using a switch, is 192.168.1.10 (gateway 192.168.1.1)
When I am on my linux machine, I can connect to both wlan0, and to eth0, and access the IP camera, but when I try to connect to eth0 through my windows pc, which is connected to the same router as wlan0, I can not connect to eth0.
How can I forward the IP Camera eth0 connection to my wlan0 connection so I could access it from my Windows PC?
I have IP forwarding enabled.
Here is my interfaces configuration:
# Local loopback
auto lo
iface lo inet loopback
#Wireless
#Uplink1 Wireless
auto wlan0
iface wlan0 inet static
wpa-ssid wifi
w8a-psk 90509d8a2bcd0893a2b873e5d9ba9c96ec686ce2b90e3252eab680fdef1c6125
address 192.168.100.10
netmask 255.255.255.0
gateway 192.168.100.1
post-up ip route add 192.168.100.0/24 dev wlan0 table uplink1
post-up ip route add default via 192.168.100.1 table uplink1
post-up ip rule add from 192.168.100.10/32 table uplink1 priority 100
post-up ip route flush cache
pre-down ip rule del from 192.168.100.10/32 table uplink1 priority 100
pre-down ip route flush table uplink1
pre-down ip route flush cache
#Uplink2
auto eth0
iface eth0 inet static
address 192.168.1.118
netmask 255.255.255.0
#gateway 192.168.1.1
post-up ip route add 192.168.1.0/24 dev eth0 table uplink2
post-up ip route add default via 192.168.1.1 table uplink2
post-up ip rule add from 192.168.1.118/32 table uplink2 priority 110
post-up ip route flush cache
pre-down ip rule del from 192.168.1.118/32 table uplink2 priority 110
pre-down ip route flush table uplink2
pre-down ip route flush cache
The output of ifconfig is:
eth0 Link encap:Ethernet HWaddr 02:41:06:40:b3:e9
inet addr:192.168.1.118 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::41:6ff:fe40:b3e9/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1064 errors:0 dropped:0 overruns:0 frame:0
TX packets:7 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:63840 (62.3 KiB) TX bytes:558 (558.0 B)
Interrupt:46
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
wlan0 Link encap:Ethernet HWaddr 00:a1:b0:f0:63:e4
inet addr:192.168.100.10 Bcast:192.168.100.255 Mask:255.255.255.0
inet6 addr: fe80::2a1:b0ff:fef0:63e4/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1369 errors:0 dropped:0 overruns:0 frame:0
TX packets:790 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:126212 (123.2 KiB) TX bytes:102124 (99.7 KiB)
Output of route is:
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.100.1 0.0.0.0 UG 0 0 0 wlan0
192.168.1.0 * 255.255.255.0 U 0 0 0 eth0
192.168.100.0 * 255.255.255.0 U 0 0 0 wlan0
I already tried to do the IP forwarding via iptables but without any results. I tried: iptables -t nat -A PREROUTING -p tcp -d 192.168.1.10 --dport 80 -j DNAT --to 192.168.100.10:80
and iptables -A FORWARD -p tcp -d 192.168.100.10 --dport 80 -j ACCEPT
I also tried iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j DNAT --to 192.168.100.10:80
But I can still not access 192.168.1.10 on my windows PC. I write in the url 192.168.100.10 since I am connected via wlan0 to it, and I try to forward the IP camera connection to that url.