LinuxQuestions.org
Visit Jeremy's Blog.
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 07-20-2014, 05:57 AM   #1
megatronium
LQ Newbie
 
Registered: Jul 2014
Posts: 2

Rep: Reputation: Disabled
open port range for ftp server on private network


i have a private network with 2 machines with ips:
server 150.0.0.2
client 200.200.150.150

i made a ftp server which is listening to port 50006 for connection and then randomly pick new number between 60000:65000 for file transfer

i having trouble to connect to the server (even the beginning on port 50006) and i get connection refuse.
i have ping from client to server, i also turned off firweall

i am using redhat linux os

how do i open the ranges for listening ?
 
Old 07-20-2014, 09:46 AM   #2
Vegan
Member
 
Registered: Aug 2010
Location: Idaho
Distribution: Arch, Ubuntu, Fedora
Posts: 114
Blog Entries: 2

Rep: Reputation: 10
If you have turned off the firewall, you may need to open up the ports on the router to allow incoming.

What FTP server are you using?
 
Old 07-20-2014, 02:45 PM   #3
megatronium
LQ Newbie
 
Registered: Jul 2014
Posts: 2

Original Poster
Rep: Reputation: Disabled
sloved

used:

int sock;
struct addrinfo hints, *res;
int reuseaddr = 1; /* True */

/* Get the address info */
memset(&hints, 0, sizeof hints);
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM;
if (getaddrinfo(NULL, PORT, &hints, &res) != 0) {
perror("getaddrinfo");
return 1;
}

/* Create the socket */
sock = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
if (sock == -1) {
perror("socket");
return 1;
}

/* Enable the socket to reuse the address */
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &reuseaddr, sizeof(int)) == -1) {
perror("setsockopt");
return 1;
}

/* Bind to the address */
if (bind(sock, res->ai_addr, res->ai_addrlen) == -1) {
perror("bind!!!!");
return 0;
}

freeaddrinfo(res);

which is only for same machine connection, changed it to:

struct sockaddr_in ip4addr;
ip4addr.sin_family= AF_INET;
ip4addr.sin_port = htons(p2);
inet_pton(PF_INET,"10.0.0.2",&ip4addr.sin_addr);

/* Create the socket */
sock=socket(PF_INET,SOCK_STREAM,0);
if (sock == -1) {
perror("socket");
return 1;
}


/* Bind to the address */

bind(sock,(struct sockaddr*)&ip4addr,sizeof ip4addr);

---------- Post added 07-20-14 at 02:45 PM ----------

and changed ip as well ofcourse
 
  


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
[SOLVED] open the port range for FTP passive transfer ccc Linux - Networking 3 10-01-2013 04:03 PM
[SOLVED] open RPC port range bino25 Linux - Networking 2 01-26-2011 07:56 AM
Creating a bogus DNS domain inside private address range network zogness Linux - Networking 13 10-16-2009 01:34 PM
Private ftp server.. Lowe Linux - Software 2 09-04-2004 08:13 PM
Open Port Range cobolexpert Linux - Security 5 09-02-2004 08:30 AM

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

All times are GMT -5. The time now is 06:00 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