我有一台带有2个网络连接的linux机器,wlan0和eth0。通过wlan0,linux机器连接到路由器,通过eth0,linux机器连接到IP摄像机(通过网络交换机)。
从与wlan0在同一网络上的Windows机器上,我使用putty连接到linux机器。如何通过我的通过wlan0连接的Windows机器连接到eth0上的ipcamera?
我的linux机器的IP,通过wlan0连接的是192.168.100.10(网关:192.168.100.1)
使用交换机通过eth0连接到linux机器的IP摄像机IP为192.168.1.10(网关192.168.1.1)
当我在我的linux机器上时,我可以连接到wlan0和eth0,并访问IP摄像头,但是当我尝试通过我的windows pc连接到eth0时,它连接到与wlan0相同的路由器,我可以没有连接到eth0。
如何将IP Camera eth0连接转发到我的wlan0连接,以便从Windows PC访问它?
我启用了IP转发。
这是我的接口配置:
# 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
ifconfig的输出是:
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)
路线输出是:
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
我已经尝试通过iptables进行IP转发,但没有任何结果。我试过了:iptables -t nat -A PREROUTING -p tcp -d 192.168.1.10 --dport 80 -j DNAT --to 192.168.100.10:80
和 iptables -A FORWARD -p tcp -d 192.168.100.10 --dport 80 -j ACCEPT
我也试过了 iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j DNAT --to 192.168.100.10:80
但我仍然无法在我的Windows PC上访问192.168.1.10。我写在网址192.168.100.10,因为我通过wlan0连接到它,我尝试将IP摄像头连接转发到该网址。