Bekijk de volledige versie : Forwarding port 80 --> 8081????
Is there a way to break this behavior. I like to set the web interface to port 8081. And i want it to be accessible with LAN and WAN trought port 8081.
No port redirection.
I want this coz need my port 80 for an other webserver (without killing the current one).
Sollie.
dolphine
21-01-2007, 07:53
Is there a way to break this behavior. I like to set the web interface to port 8081. And i want it to be accessible with LAN and WAN trought port 8081.
No port redirection.
I want this coz need my port 80 for an other webserver (without killing the current one).
Sollie.
Some settings are defaulted in web-gui, others you should be able to modify over the iptables
iptables --list
iptables -d nat --list
See documentation http://www.netfilter.org/documentation/index.html
I would eventually want the same thing, but I don't have time to do so now :-( so I would appreciate if you could share your findings.
Thankx & Regards
I will try to find a way.
Sollie.
I could not find a way to stop the redirection. But i found a way to reverse the direction with some php scripts.
Step 1: I replaced my index.html from web (origional asus website) with the following code:
<head>
<meta http-equiv="refresh" content="0; URL=http://www.yourdomain.com:8082">
</head>
<body>
</body>
</html>
Step 2: I use lighttpd (8082) with php and my index.php looks like this:
<?php
$user = getenv("REMOTE_ADDR");
$host = getenv("HTTP_HOST");
// when you enter your domain form outside (WAN)
if($user == "192.168.0.3") {
if($host == "www.yourdomain.com") { $url = "local_index.php"; } // $url = waar hij heen redirect
elseif($host == "www.yourdomain.com:8082") { $url = "local_index.php"; }
else { $url = "local_index.php" ; }
}
//When you enter your domain from the insite (LAN)
else {
if($host == "www.yourdomain.com") { $url = "remote_index.php"; } // $url = waar hij heen redirect
elseif($host == "www.yourdomain.com:8082") { $url = "remote_index.php"; }
else { $url = "remote_index.php" ; }
}
// Ga naar de $url toe..
Header("Location: $url");
?>
Step 3: whe i reboot the router the index.html i restored by the router. I removed this behavior by adding the following code to rc.local:
# Restore Webserver Redirection
cp /shares/MYVOLUME1/MYSHARE1/run/index.html /shares/MYVOLUME1/MYSHARE1/web
Step 4: to use yourdomain.com local, you have to change your "host" file in windows. Use the following path: windir/system32/drivers/etc/host.
Change that file, by adding a yourdomain.com direction to your routers IP.
Sollie.
Gizmo1007
09-11-2007, 00:23
hi,
Used some of the information provided by sollie, inparticular this link
http://www.netfilter.org/documentation/HOWTO//packet-filtering-HOWTO-7.html
and did the following to get it to work. Checked it with a VPN connection and it does work:D
So here's what you do.
Let's say you have 8081 currently set up on the asus wl700 to serve photos but you want to use lighttpd or another web server on 8088.
I have created a small tutorial which I hope will work for you, It bugged me for 2 weeks but I finally have it cracked. alternatively u can use sollie's suggestion above.
1. You need to find out what line number the 8081 is being served on
iptables -t nat --list --line-numbers
2. you then need to remove the line which has ref to 8081
iptables -t nat -D PREROUTING 2
3. Then you need to add your own server port to replace the 8081 port
iptables -t nat -I PREROUTING 2 -p tcp -m tcp -i eth0 --dport 80 -j DNAT --to-destination <enteryourip>:<newportno>
4. You then need to remove the 8081 port from the INPUT table in iptables.
iptablex -D INPUT <again enter the number of the line 8081 is on>
you may need to run iptables --list --line-numbers to find out what 8081 is on input table.
5. Add the replaced server to the input table
iptable -I input <LINE NO eg 8> -p tcp -m tcp -d <enteryourip> --dport <newportno> -j ACCEPT
You can run a couple of test now on your webserver to see if it's working and you can add the lines above to the rc.local but i suggest that you put them into a file and execute the file from rc.local with #!/opt/bin/bash as the input line followed by the command lines above, put this in a file say called iptable-change and save it in /opt/etc give it a chmod 777 and call it from rc.local.
There may be another way to call it in rc.local but i have found it the best way to get it working.
As always, back up your iptables, before you make a mess of your machine and cannot get anything working. Note these files are located in /tmp
and are called
nat_rules
filter_rules
That way you can always copy them back in if you make a mess.