LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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
  Search this Thread
Old 04-24-2014, 03:45 AM   #1
vjdjsingh
LQ Newbie
 
Registered: Apr 2014
Posts: 8

Rep: Reputation: Disabled
IPTABLES configuration needed for external router managing an internal SFTP server


hello everyone,

I am new on this Forum and what took me here is this mindnumbing problem I have been Dealing with for Quite some days.

I have rightly setup an internal SFTP server with Y.Y.Y.175 on fedora 13 which is connected to this router X.X.X.80 which should allow other to access the Internal SFTP server. but the Problem I'm facing is:

This Router is accesssible from internal network.
But we cant even ping it external to our network. Whereas I tried pinging google from this Router and it was success. Also I pinged the 175 machine via ths router and it was also a success. but If I ping this router from any external IP, the Request times out.

All I want is to access this .175 machine through this .80 router.
here are the Changes i tried inside the iptables:

iptables -A FORWARD -p tcp --dport 22 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 22 -j ACCEPT

P.S SFTP is on 22 port as default. Please help me accessing this machine from outside.

the Interfaces being used are 'eth0' and 'eth1'.
'eth0' is .175 machine and 'eth1' is .80 .

Here is view of iptables -L:

Code:
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED
ACCEPT     icmp --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:domain
ACCEPT     udp  --  anywhere             anywhere            state NEW udp dpt:domain
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:ftp
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:nfs
ACCEPT     udp  --  anywhere             anywhere            state NEW udp dpt:openvpn
ACCEPT     udp  --  anywhere             anywhere            state NEW udp dpt:netbios-ns
ACCEPT     udp  --  anywhere             anywhere            state NEW udp dpt:netbios-dgm
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:netbios-ssn
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:microsoft-ds
ACCEPT     udp  --  anywhere             anywhere            state NEW udp dpt:netbios-ns
ACCEPT     udp  --  anywhere             anywhere            state NEW udp dpt:netbios-dgm
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:ssh
ACCEPT     udp  --  anywhere             anywhere            state NEW udp dpt:tftp
REJECT     all  --  anywhere             anywhere            reject-with icmp-host-prohibited
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:http
ACCEPT     tcp  --  anywhere             anywhere

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED
ACCEPT     icmp --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere
REJECT     all  --  anywhere             anywhere            reject-with icmp-host-prohibited
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:ssh

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     tcp  --  anywhere             anywhere            tcp spt:ssh
and here is view of netstat -ln | grep tcp

Code:
tcp        0      0 0.0.0.0:21                  0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN
tcp        0      0 127.0.0.1:631               0.0.0.0:*                   LISTEN
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN
tcp        0      0 :::5900                     :::*                        LISTEN
tcp        0      0 :::22                       :::*                        LISTEN
tcp        0      0 ::1:631                     :::*                        LISTEN

Last edited by vjdjsingh; 04-24-2014 at 03:52 AM.
 
Old 04-24-2014, 06:43 AM   #2
nikmit
Member
 
Registered: May 2011
Location: Nottingham, UK
Distribution: Debian
Posts: 178

Rep: Reputation: 34
It does not look like you have a firewall issue, as the configuration you pasted in is completely open - you don't have a firewall and nothing should be dropped.

Quote:
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
ACCEPT icmp -- anywhere anywhere
ACCEPT all -- anywhere anywhere
This is as far as your INPUT chain will be processed, similar with the FORWARD chain. The OUTPUT chain has a default policy of ACCEPT and no explicit deny as a last rule in the chain, so again all is allowed.
 
Old 04-24-2014, 07:05 AM   #3
vjdjsingh
LQ Newbie
 
Registered: Apr 2014
Posts: 8

Original Poster
Rep: Reputation: Disabled
Do you have a notion what could be wrong?
As the Router is not pinging unless I ping it from an internal point.
There must have been something I left in setting it up.
 
Old 04-24-2014, 07:27 AM   #4
nikmit
Member
 
Registered: May 2011
Location: Nottingham, UK
Distribution: Debian
Posts: 178

Rep: Reputation: 34
What is the output of
Code:
cat /proc/sys/net/ipv4/ip_forward
- should be 1. If it is not do
Code:
sysctl -w net/ipv4/ip_forward=1
Other than that you will need to provide a sketch of the network at the very least, it is all very foggy right now.

Last edited by nikmit; 04-24-2014 at 07:29 AM.
 
Old 04-24-2014, 07:49 AM   #5
vjdjsingh
LQ Newbie
 
Registered: Apr 2014
Posts: 8

Original Poster
Rep: Reputation: Disabled
I had set the ip_forward to 1 already.
I'll try and Provide the view here.
 
Old 04-24-2014, 08:20 AM   #6
vjdjsingh
LQ Newbie
 
Registered: Apr 2014
Posts: 8

Original Poster
Rep: Reputation: Disabled
Here is What my network looks like........
https://www.dropbox.com/s/9z3zwh6mal...orkDiagram.JPG
 
Old 04-24-2014, 08:38 AM   #7
nikmit
Member
 
Registered: May 2011
Location: Nottingham, UK
Distribution: Debian
Posts: 178

Rep: Reputation: 34
Code:
*nat
-A PREROUTING -i eth1 -d x.x.x.80 -p tcp -dport 22 -j DNAT --to-destination y.y.y.175:22
-A PREROUTING -i eth1 -d x.x.x.80 -p icmp -j DNAT --to-destination y.y.y.175
COMMIT
Something like this should configure NAT port forwarding, which is what you need. Add to your iptables rule file and do iptables-restore after
Change ports/protocols as needed, and the IPs to the real ones. The above should forward TCP/22 (SSH) and all ICMP.
 
Old 04-24-2014, 08:41 AM   #8
vjdjsingh
LQ Newbie
 
Registered: Apr 2014
Posts: 8

Original Poster
Rep: Reputation: Disabled
Do i need to make the default rule as nat or filter will do fine??
 
Old 04-24-2014, 08:43 AM   #9
nikmit
Member
 
Registered: May 2011
Location: Nottingham, UK
Distribution: Debian
Posts: 178

Rep: Reputation: 34
Needs to be nat
 
Old 04-24-2014, 09:30 AM   #10
vjdjsingh
LQ Newbie
 
Registered: Apr 2014
Posts: 8

Original Poster
Rep: Reputation: Disabled
I changed the iptables to below configurations and then saved it in a file and then restored it again.
But still if I am doing iptables -L, it is showing the same result as before as if the changes i have made has not been acknowledged by system.

Here is my iptables view:
Code:
[root@ZZZZZZ sysconfig]# cat iptables
*nat
-P PREROUTING ACCEPT
-P POSTROUTING ACCEPT
-P OUTPUT ACCEPT
-A PREROUTING -d x.x.x.80/32 -i eth1 -p tcp -m tcp --dport 22 -j DNAT --to-destination y.y.y.175:22
-A PREROUTING -d x.x.x.80/32 -i eth1 -p icmp -j DNAT --to-destination y.y.y.175
COMMIT
And here is what iptables -L looks like:
Code:
[root@zzzzz sysconfig]# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED
ACCEPT     icmp --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:domain
ACCEPT     udp  --  anywhere             anywhere            state NEW udp dpt:domain
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:ftp
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:nfs
ACCEPT     udp  --  anywhere             anywhere            state NEW udp dpt:openvpn
ACCEPT     udp  --  anywhere             anywhere            state NEW udp dpt:netbios-ns
ACCEPT     udp  --  anywhere             anywhere            state NEW udp dpt:netbios-dgm
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:netbios-ssn
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:microsoft-ds
ACCEPT     udp  --  anywhere             anywhere            state NEW udp dpt:netbios-ns
ACCEPT     udp  --  anywhere             anywhere            state NEW udp dpt:netbios-dgm
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:ssh
ACCEPT     udp  --  anywhere             anywhere            state NEW udp dpt:tftp
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:http
ACCEPT     tcp  --  anywhere             anywhere

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED
ACCEPT     icmp --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:ssh

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     tcp  --  anywhere             anywhere            tcp spt:ssh
P.S I put the right IPs there in my system. I provided IP-tweaked view here.

Last edited by vjdjsingh; 04-24-2014 at 09:32 AM.
 
Old 04-25-2014, 05:20 AM   #11
vjdjsingh
LQ Newbie
 
Registered: Apr 2014
Posts: 8

Original Poster
Rep: Reputation: Disabled
okay it got Resolved,
the problem was with DNS i set it to 8.8.8.8
Everythings fine now!!!!!
 
Old 04-25-2014, 07:07 PM   #12
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by vjdjsingh View Post
I have rightly setup an internal SFTP server with Y.Y.Y.175 on fedora 13
Fedora 13 is too old to be used. Current release is 20. Please install that or another current Linux distribution release.
 
  


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
[SOLVED] linux nat router - 2 internal interfaces out on 2 external ones psycroptic Linux - Networking 1 10-20-2013 12:28 PM
[SOLVED] IPTables config to allow external clients to connect to internal MS SQL server Smuff Linux - Newbie 4 05-15-2012 04:21 AM
iptables setup - internal / external traffic xenny123 Linux - Networking 4 02-10-2010 05:18 PM
iptables redirect all traffic from external ip to internal ip brb_bart Linux - Networking 1 12-17-2009 06:56 PM
Simple IPTables... Want to pass all data from one external IP to an internal IP AdamRankin Linux - Networking 3 04-01-2003 03:24 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 01:10 PM.

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