LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 09-11-2007, 12:22 PM   #1
saifurab
Member
 
Registered: Mar 2007
Posts: 30

Rep: Reputation: 15
Remote Admin port forwarding


Dear Experts

I have my linux box have two interfaces

eth1 -> Public IP -> xxx.xxx.xxx.xxx
eth0 -> Local IP -> 192.168.0.254

i want to forward port of remote admin to my lan computer. which has ip 192.168.0.173.

Please let me know what rule should i apply so that one can access my computer (192.168.0.173) remotely through Remote Admin. Remoteadmin uses 4899 port to connect.

Regards
Saif
 
Old 09-12-2007, 06:59 AM   #2
blackhole54
Senior Member
 
Registered: Mar 2006
Posts: 1,896

Rep: Reputation: 60
You would probably do well to aquaint yourself some with iptables before proceeding, but I believe the rule you are looking for is

Code:
iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 4899 -j DNAT --to-destination 192.168.0.173
You might also want to give some consideration to security and decide if you, in fact, want all such requests to be passed through.
 
Old 09-13-2007, 12:08 AM   #3
saifurab
Member
 
Registered: Mar 2007
Posts: 30

Original Poster
Rep: Reputation: 15
Applied this rule

I am familiar with iptables and i applied the rule below which is quite similar to your suggestion but it doesn't work

iptables -t nat -A PREROUTING -p tcp -d xx.xx.xxx.xxx --dport 4899 -j DNAT --to-destination 192.168.0.173:4899


Any more help

Regards
 
Old 09-13-2007, 06:56 AM   #4
blackhole54
Senior Member
 
Registered: Mar 2006
Posts: 1,896

Rep: Reputation: 60
If your destination address (-d) is correct, that looks to me like it should work. If not ...
  • Do you have any kind of a firewall between the Linux box and the Internet that could be blocking things?
  • Do you have firewall rules in the Linux box that could be blocking? The incoming packets and the return packets will both have to successfully traverse the FORWARD chain.
  • Do you have a firewall on the machine running remoteadmin that could be blocking things?
  • You must have ip_forward enabled on the Linux box.

If it's none of the above, the only thing I know is to trouble shoot. To do that you need a way to send some packets to forward to this machine. (If thats impossible but you have another computer you can hook up to eth1, you can temporarily change eth1 to use a (different) LAN subnet, temporarily alter your DNAT rule to match and trouble shoot in this configuration. Then change things back when it works.) For trouble shooting, when you supply packets you can examine the packet count on your rule with

Code:
iptables -t nat -nvL PREROUTING
and see if the incoming packets are matching. (Only the first one for a given connection will match; after the connection is established the rest of the incoming packets will bypass the PREROUTING chain.) You can also monitor what packets are being received and sent on each interface on your Linux box using tcpdump, wireshark, or some other packet sniffer, and see where you are loosing the packets.
 
Old 09-13-2007, 11:33 PM   #5
saifurab
Member
 
Registered: Mar 2007
Posts: 30

Original Poster
Rep: Reputation: 15
Thanks for detailed reply.

Yes i have firewall installed on that machine. but even i disabled it it won't work. i did according to your instructions and output is as follows and see the bold lines which shows that traffic is coming in..

BEFORE TRYING TO CONNECT

[root@squid ~]# iptables -t nat -nvL PREROUTING; iptables -nvL FORWARD
Chain PREROUTING (policy ACCEPT 490 packets, 66732 bytes)
pkts bytes target prot opt in out source destination
0 0 DROP tcp -- eth0 * 0.0.0.0/0 209.8.41.0/24
0 0 DROP udp -- eth0 * 0.0.0.0/0 209.8.41.0/24
3 144 DNAT tcp -- eth1 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:4899 to:192.168.0.173:4899
Chain FORWARD (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 ACCEPT tcp -- eth0 eth1 0.0.0.0/0 0.0.0.0/0 multiport dports 22,25,1863,5050,110,143,443,80,21
0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
0 0 DROP tcp -- * * 0.0.0.0/0 0.0.0.0/0 multiport dports 135,139,445
9 432 ACCEPT tcp -- eth1 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:4899

AFTER TRYING TO CONNECT

root@squid ~]# iptables -t nat -nvL PREROUTING; iptables -nvL FORWARD
Chain PREROUTING (policy ACCEPT 490 packets, 66732 bytes)
pkts bytes target prot opt in out source destination
0 0 DROP tcp -- eth0 * 0.0.0.0/0 209.8.41.0/24
0 0 DROP udp -- eth0 * 0.0.0.0/0 209.8.41.0/24
4 192 DNAT tcp -- eth1 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:4899 to:192.168.0.173:4899
Chain FORWARD (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 ACCEPT tcp -- eth0 eth1 0.0.0.0/0 0.0.0.0/0 multiport dports 22,25,1863,5050,110,143,443,80,21
0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
0 0 DROP tcp -- * * 0.0.0.0/0 0.0.0.0/0 multiport dports 135,139,445
12 576 ACCEPT tcp -- eth1 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:4899


And here is tcpdump output
[root@squid ~]# tcpdump -i eth1 port 4899
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth1, link-type EN10MB (Ethernet), capture size 96 bytes
09:27:17.888807 IP <My IP>.23308 > <Destination IP>.radmin-port: S 1168980337:1168980337(0) win 16384 <mss 1452,nop,nop,sackOK>
09:27:20.769602 IP <My IP>.23308 > <Destination IP>.radmin-port: S 1168980337:1168980337(0) win 16384 <mss 1452,nop,nop,sackOK>
09:27:26.788891 IP <My IP>.23308 > <Destination IP>.radmin-port: S 1168980337:1168980337(0) win 16384 <mss 1452,nop,nop,sackOK>


These output seems OK to me. If you have any observation please let me know. The "192.168.0.173" works fine on LAN for remote admin

Regards
Saif ur Rab
 
Old 09-14-2007, 12:11 AM   #6
blackhole54
Senior Member
 
Registered: Mar 2006
Posts: 1,896

Rep: Reputation: 60
On your tcpdump output, "Destination IP" is the public IP address of the machine with the DNAT rule? If so, that looks to me like 3 "syn" packets (that is what that capital S means) -- the first packet sent to start a TCP handshake. In other words, three attempts from your remote machine to start a conversation, with no packets coming back.

Obviously you got a match on the DNAT rule, but beyond that I am not sure I understand the packet counts. Perhaps I still don't fully understand the details of what happens with the packet handling with DNAT.

I suggest you use tcpdump to monitor eth0 to see if the packet ever leaves the machine, and if so, whether a response comes back. If the packet never leaves this machine, make sure you have ip_forward enabled and that your routing table makes sense:

Code:
sysctl -a | grep ip_forward
route -n
 
Old 09-14-2007, 12:44 AM   #7
saifurab
Member
 
Registered: Mar 2007
Posts: 30

Original Poster
Rep: Reputation: 15
I tried one more thing. see output below. it seems 192.168.0.173 is receiving the packets but couldn't establish the connection

any clues??

[root@squid ~]# tcpdump host 192.168.0.173
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes
10:39:31.867367 arp who-has 192.168.0.173 tell 192.168.0.254
10:39:31.867470 arp reply 192.168.0.173 is-at 00:13:20:28:31:18 (oui Unknown)
10:39:31.867479 IP <My IP>.24812 > 192.168.0.173.radmin-port: S 2100045692:2100045692(0) win 16384 <mss 1452,nop,nop,sackOK>
10:39:31.867668 arp who-has 192.168.0.1 tell 192.168.0.173
10:39:40.865820 arp who-has 192.168.0.1 tell 192.168.0.173
 
Old 09-14-2007, 12:49 AM   #8
saifurab
Member
 
Registered: Mar 2007
Posts: 30

Original Poster
Rep: Reputation: 15
also see the eth0 traffic

[[root@squid ~]# tcpdump -i eth0 port 4899
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes
10:45:38.980845 IP <MY IP>.24944 > 192.168.0.173.radmin-port: S 1400909149:1400909149(0) win 16384 <mss 1452,nop,nop,sackOK>
10:45:41.870045 IP <MY IP>.24944 > 192.168.0.173.radmin-port: S 1400909149:1400909149(0) win 16384 <mss 1452,nop,nop,sackOK>
10:45:47.889760 IP <MY IP>.24944 > 192.168.0.173.radmin-port: S 1400909149:1400909149(0) win 16384 <mss 1452,nop,nop,sackOK>

any clues??
 
Old 09-14-2007, 01:05 AM   #9
blackhole54
Senior Member
 
Registered: Mar 2006
Posts: 1,896

Rep: Reputation: 60
I was wondering if perhaps the firewall on 192.168.0.173, or maybe the Remote Admin application itself was blocking IP addresses that are not from your LAN.

Can you put a packet sniffer on 92.168.0.173 itself? If it is receiving those packets but not sending anything back, then you know the issue is on that machine. You've already established that the problem (at least the initial problem) is not on the machine doing the DNAT.
 
Old 09-14-2007, 02:47 AM   #10
saifurab
Member
 
Registered: Mar 2007
Posts: 30

Original Poster
Rep: Reputation: 15
Thank you vvery much for support. The Problem has been resolved.

[root@squid ~]# tcpdump host 192.168.0.173
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes
10:39:31.867367 arp who-has 192.168.0.173 tell 192.168.0.254
10:39:31.867470 arp reply 192.168.0.173 is-at 00:13:20:28:31:18 (oui Unknown)
10:39:31.867479 IP <My IP>.24812 > 192.168.0.173.radmin-port: S 2100045692:2100045692(0) win 16384 <mss 1452,nop,nop,sackOK>
10:39:31.867668 arp who-has 192.168.0.1 tell 192.168.0.173
10:39:40.865820 arp who-has 192.168.0.1 tell 192.168.0.173



the above helped me in resolving the issue and obviously your advise...infact all traffic of this machine going through squid so i never bothered to change the gateway. infact my gateway is 192.168.0.254 but if you see above dump in bold then see that it is showing the gateway 192.168.0.1

cheer
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
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
Forwarding ONE port to remote machine supertrout Linux - Networking 2 12-14-2004 10:02 PM
Remote Port Forwarding Question juxstapose Linux - Networking 1 08-01-2004 12:32 PM
Port forwarding and remote X11 sessions lfabiani Linux - Networking 6 04-01-2002 06:11 AM


All times are GMT -5. The time now is 10:09 AM.

Main Menu
 
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
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration