Hi Jeroen,
thank you for your answer,
> "Jeroen Geilman" <(E-Mail Removed)> wrote in message
> > Henrik Feidner wrote:
> > Hi,
> > i have a small problem with my network configuration.
> > my router is connected to the internet over DSL via one nic and has a
> > second nic for my internal net.
> > I'm running a web server on my router. On my web server i have a site
> > with a java applet, this applet
> > wants to open a socket on port 9050 on my router. This port is forwarded
> > to an internal host.
>
> It wants to open a /connection/ to a socket on port 9050, I presume ?
> The fact that it is properly forwarded to an internal machine makes it a
> socket, i.e. something that can accept incoming connections.
>
Yes, the applet wants to open a connection to a socket on port 9050.
And yes, there is a webcam connected at my internal host on port 9050. So I
forwarded
the port 9050 of my router to my internal host.
> > Now if i call the web site from my internal network the applet can open
> > the socket, but if i call the
> > applet from outsite, from the internet, i get a " ...... 9050 connection
> > timed out: connect".
>
> How does the java applet know which IP address to use ?
I give the IP address over a parameter, it's the internet IP address at the
device ppp0.
>
> > Maybe my iptables script is missing a rule to allow opening this socket?
>
> No clue, but this is an English newsgroup - please post an English
> iptables script.. iptables is hard enough to read in English !
>
sorry for posting stuff in german, I translated the comments to english.
#!/bin/sh
echo "1" > /proc/sys/net/ipv4/ip_forward # initialize forwardings
# flush, delete, creation
################################################## ##############
iptables -F
iptables -F -t nat
iptables -F mychain
iptables -X mychain
iptables -N mychain
iptables -F mychain
# first contact #
#################
# throw everything away from the lan which has not my ip addresses
iptables -A mychain -i eth1 -s ! 192.168.1.0/255.255.255.0 -j DROP
# otherwise accept everything else from the lan
iptables -A mychain -i eth1 -j ACCEPT
# for Loopback everything is allowed
iptables -A mychain -i lo -s 127.0.0.1/255.0.0.0 -j ACCEPT
# throw everything away from the internet with my ip addresses
iptables -A mychain -i ppp0 -s 192.168.0.0/255.255.255.0 -j DROP
# accept stuff #
###############
iptables -A mychain -p tcp --dport 9050 -j ACCEPT # accept connection on
port 9050
# answers allowed #
######################
iptables -A mychain -m state --state ESTABLISHED,RELATED -j ACCEPT
# everything else reject (RFC-conform) #
#######################################
iptables -A mychain -p tcp -j REJECT --reject-with tcp-reset
iptables -A mychain -p udp -j REJECT --reject-with icmp-port-unreachable
# activate mychain #
#####################
#iptables -A INPUT -j mychain
#iptables -A FORWARD -j mychain
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT # accept always output
iptables -t nat -P OUTPUT ACCEPT
# NAT #
#######
# everything going is will be masqueraded
iptables -A POSTROUTING -t nat -o ppp0 -j MASQUERADE
# forward connection to device eth0 on port 9050 to internal host
iptables -A PREROUTING -t nat -i eth1 -p tcp --dport 9050 -j
DNAT --to-destination 192.168.1.2
# forward connection to device ppp0 on port 9050 to internal host
iptables -A PREROUTING -t nat -i ppp0 -p tcp --dport 9050 -j
DNAT --to-destination 192.168.1.2
iptables -A POSTROUTING -t nat -o eth1 --j SNAT --to-source 192.168.1.1
iptables -A POSTROUTING -t nat -o ppp0 --j SNAT --to-source 192.168.1.1
echo "Firewall started"
>
> J.
|