LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices

Reply
 
Search this Thread
Old 07-23-2007, 04:14 AM   #1
suhas!
Member
 
Registered: Mar 2007
Posts: 100

Rep: Reputation: 17
Problem with SSH local port forwarding


I want to forward the port 1812 running on server1 to server2. So I issue following command from server2

[root@server2 ~]# ssh -g -L 1812:server1:1812 server1
root@server1's password:
bind: Address already in use
Last login: Mon Jul 23 14:35:19 2007 from server2
[root@server1 ~]#


when I use above command without using -g option then it works fine. But I want the forwarded port to be used by other clients as well.

I have made sure that there is no service running on Server2 on port no. 1812. I have tried with many other ports as well.


Can anybody suggest me what to do to enable other clients to use forwarded port.

Last edited by suhas!; 07-23-2007 at 04:19 AM.
 
Old 07-24-2007, 04:52 AM   #2
mallux
Member
 
Registered: Jun 2007
Location: London, UK
Distribution: Ubuntu, RHEL, Fedora
Posts: 46
Blog Entries: 1

Rep: Reputation: 16
Hi suhas! I can reproduce this on my system; and the output from strace indicates that ssh is attempting to bind to both IPv6 and IPv4 addresses:
Code:
$ strace -f -- ssh -g -L 12345:localhost:80 server2
...
socket(PF_INET6, SOCK_STREAM, IPPROTO_TCP) = 4
setsockopt(4, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
bind(4, {sa_family=AF_INET6, sin6_port=htons(12345), inet_pton(AF_INET6, "::", &sin6_addr), sin6_flowinfo=0, sin6_scope_id=0}, 28) = 0
listen(4, 128)                          = 0
...
socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 5
setsockopt(5, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
bind(5, {sa_family=AF_INET, sin_port=htons(12345), sin_addr=inet_addr("0.0.0.0")}, 16) = -1 EADDRINUSE (Address already in use)
write(2, "bind: Address already in use\r\n", 30bind: Address already in use
) = 30
close(5)                                = 0
...
If you tell it to use IPv4 only then you don't get the error message, so for your example:
[root@server2 ~]# ssh -4 -g -L 1812:server2:1812 server1
 
Old 07-25-2007, 03:34 AM   #3
suhas!
Member
 
Registered: Mar 2007
Posts: 100

Original Poster
Rep: Reputation: 17
Oh Yess!!!!! It really worked man!!! Now every thing is working fine.....


I would like to know that which command's output have you posted above.. which helped you to figure out the problem?


Once again, Thanks a lot Mallux.... This is a great forum!!!!!!
 
Old 07-25-2007, 10:06 AM   #4
mallux
Member
 
Registered: Jun 2007
Location: London, UK
Distribution: Ubuntu, RHEL, Fedora
Posts: 46
Blog Entries: 1

Rep: Reputation: 16
Quote:
Originally Posted by suhas!
I would like to know that which command's output have you posted above.. which helped you to figure out the problem?
Yes it's actually at the top of the code section I posted: strace is the program - it might not be installed by default on your system but most distributions include it. It basically shows every system call that a process makes; you don't need to recompile anything and you can even attach to processes that are already running. Check out "man strace" for more info.

Quote:
Originally Posted by suhas!
Once again, Thanks a lot Mallux.... This is a great forum!!!!!!
Glad to be of service. Please call again.
 
  


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Local Port Forwarding CobraCRK Linux - Server 3 05-14-2007 03:13 PM
ssh port forwarding problem. jcombs_31 Linux - Networking 2 07-26-2006 06:22 AM
X forwarding video with ssh and using local sound card dr_zayus69 Linux - Networking 2 03-01-2006 09:57 PM
sshd/ssh config for local forwarding ewlnxnewB Linux - Networking 2 11-04-2003 02:09 PM
forwarding a local port Hano Linux - Networking 8 10-14-2003 12:20 PM


All times are GMT -5. The time now is 05:44 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 Google+: linuxquestions
Open Source Consulting | Domain Registration