LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-17-2011, 11:19 PM   #1
skjadoon
LQ Newbie
 
Registered: Nov 2010
Posts: 7

Rep: Reputation: 0
Port forwarding


Hi everyone

I want to forward http 9999 port from ppp0 interface (intenet connection) to port 80 on my local server 192.168.1.10.
ppp0 ip is : 124.109.x.x

Currently there is no rule for FORWARD, OUTPUT AND PREROUTING

Rule for POSTROUTING IS: -A POSTROUTING -o ppp0 -j MASQUERADE

routing is also enabled.
 
Old 03-18-2011, 06:06 AM   #2
NM04
Member
 
Registered: Jan 2011
Distribution: Back Track,Fedora,centos
Posts: 240

Rep: Reputation: 14
why don't you change the port of your server on which it listens.

Regards.
 
Old 03-18-2011, 11:34 PM   #3
skjadoon
LQ Newbie
 
Registered: Nov 2010
Posts: 7

Original Poster
Rep: Reputation: 0
I have tried to change the port from 80 to 9999 but face similar problem. I have also allow this port from squid.conf file
 
Old 03-27-2011, 11:31 PM   #4
NM04
Member
 
Registered: Jan 2011
Distribution: Back Track,Fedora,centos
Posts: 240

Rep: Reputation: 14
Quote:
Originally Posted by skjadoon View Post
Hi everyone

I want to forward http 9999 port from ppp0 interface (intenet connection) to port 80 on my local server 192.168.1.10.
ppp0 ip is : 124.109.x.x
skjadoon,

What exactly is your problem, in your this post you said that you want to forward the http 9999 port to http 80. And now you are saying that you tried to change port 80 to port 9999. Need some more info , what exactly you are doing, what is you setup ?
 
Old 03-28-2011, 12:27 AM   #5
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by skjadoon View Post
Currently there is no rule for FORWARD, OUTPUT AND PREROUTING
Well, you need a PREROUTING rule.

Ideally, you'd also want a FORWARD rule, with your policy set to DROP.

The OUTPUT chain is irrelevant here. Example:
Code:
iptables -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -p TCP -i ppp0 -o eth0 --dport 80 -d 192.168.1.10 -m state --state NEW -j ACCEPT
iptables -t nat -A PREROUTING -p TCP --dport 9999 -i ppp0 -j DNAT --to-destination 192.168.1.10:80
iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
There's actually tons of examples on LQ. Did you search before asking?
 
Old 03-30-2011, 12:28 AM   #6
skjadoon
LQ Newbie
 
Registered: Nov 2010
Posts: 7

Original Poster
Rep: Reputation: 0
YES I searched many examples and try all including your sample code. but still when i try to open http://124.109.x.x:9999/ it fails to forward the traffic to 192.168.1.10:80
 
Old 03-30-2011, 09:12 PM   #7
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Please post the output of:
Code:
iptables -nvL --line-numbers FORWARD
Code:
iptables -nvL -t nat --line-numbers
Code:
route -n
Code:
ifconfig
 
Old 03-31-2011, 02:04 AM   #8
skjadoon
LQ Newbie
 
Registered: Nov 2010
Posts: 7

Original Poster
Rep: Reputation: 0
[root@server root]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0D:56:FE:7D:E7
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:88301 errors:0 dropped:0 overruns:0 frame:0
TX packets:77997 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:78495179 (74.8 Mb) TX bytes:15476553 (14.7 Mb)
Interrupt:28 Base address:0xdce0 Memory:fe8e0000-fe900000

eth1 Link encap:Ethernet HWaddr 00:50:BA9:4C:B2
inet addr:192.168.1.10 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:74942 errors:0 dropped:0 overruns:0 frame:0
TX packets:104755 errors:0 dropped:0 overruns:17 carrier:0
collisions:0 txqueuelen:1000
RX bytes:16123396 (15.3 Mb) TX bytes:102714434 (97.9 Mb)
Interrupt:16 Base address:0x3c00

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:1636 errors:0 dropped:0 overruns:0 frame:0
TX packets:1636 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:144722 (141.3 Kb) TX bytes:144722 (141.3 Kb)

ppp0 Link encap:Point-to-Point Protocol
inet addr:124.109.x.x P-t-P:58.65.175.x Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1492 Metric:1
RX packets:88035 errors:0 dropped:0 overruns:0 frame:0
TX packets:77729 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:76189959 (72.6 Mb) TX bytes:13440884 (12.8 Mb)

**************************************************************************************************** ****
[root@pcbserver root]# iptables -nvL FORWARD
Chain FORWARD (policy ACCEPT 1403 packets, 92244 bytes)
pkts bytes target prot opt in out source destination
0 0 ACCEPT tcp -- ppp0 eth1 0.0.0.0/0 192.168.1.10 tcp dpt:80 state NEW
28 1326 ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED

*************************************************************************************************
[root@pcbserver root]# iptables -nvL -t nat
Chain PREROUTING (policy ACCEPT 7199 packets, 512K bytes)
pkts bytes target prot opt in out source destination
0 0 DNAT tcp -- ppp0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:9999 to:192.168.1.10:80

Chain POSTROUTING (policy ACCEPT 1521 packets, 103K bytes)
pkts bytes target prot opt in out source destination
7413 448K MASQUERADE all -- * ppp0 0.0.0.0/0 0.0.0.0/0

Chain OUTPUT (policy ACCEPT 8378 packets, 514K bytes)
pkts bytes target prot opt in out source destination
 
Old 03-31-2011, 02:06 AM   #9
skjadoon
LQ Newbie
 
Registered: Nov 2010
Posts: 7

Original Poster
Rep: Reputation: 0
[root@server root]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
58.65.175.x 0.0.0.0 255.255.255.255 UH 0 0 0 ppp0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth1
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo
0.0.0.0 58.65.175.x 0.0.0.0 UG 0 0 0 ppp0
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Warning: remote port forwarding failed for listen port 7869 windstory Linux - Newbie 1 08-02-2010 10:07 AM
Shorewall: port forwarding problem, port is closed even after forwarding Synt4x_3rr0r Linux - Networking 2 12-13-2009 04:36 PM
port forwarding on Belkin 4-port Cable/DSL Gateway Router sycamorex Linux - Networking 5 03-05-2007 03:27 PM
IPCHAINS port forwarding and IPTABLES port forwarding ediestajr Linux - Networking 26 01-14-2007 07:35 PM
Simple Port Forwarding Firewall - not forwarding MadTurki Linux - Security 14 04-09-2006 12:08 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:54 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration