Project Home
Project Home
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Blocking external access for qconn: (6 Items)
   
Blocking external access for qconn  
Lets say I start qconn on port 8000 on target.
I want DENY all connections to this port from all hosts except localhost.
Can I do it using network configuration or do I have to have firewall for that?
Or can I change qconn code to do something like this?
Re: Blocking external access for qconn  
On Fri, Aug 06, 2010 at 12:17:53PM -0400, Elena Laskavaia wrote:
> Lets say I start qconn on port 8000 on target.
> I want DENY all connections to this port from all hosts except localhost.
> Can I do it using network configuration or do I have to have firewall for that?
> Or can I change qconn code to do something like this?

Instead of bind()ing to INADDR_ANY:8000 you can
bind() to INADDR_LOOPBACK:8000.

Regards,

-seanb
Re: Blocking external access for qconn  
So I changed code to this:
memset(&addr, 0x00, sizeof addr);
addr.sin_len = sizeof addr;
addr.sin_addr.s_addr = local?INADDR_LOOPBACK:INADDR_ANY;
addr.sin_family = AF_INET;
addr.sin_port = 9000;

if (bind(fd, (struct sockaddr *)&addr, addr.sin_len) == -1) {
...
}
But it does not accept connection now (if I run with local flag):

localhost:/tmp)telnet localhost 9000
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
Trying ::1...
telnet: socket: Address family not supported by protocol family

Anything else I need to change?

Sean Boudreau wrote:
> On Fri, Aug 06, 2010 at 12:17:53PM -0400, Elena Laskavaia wrote:
>   
>> Lets say I start qconn on port 8000 on target.
>> I want DENY all connections to this port from all hosts except localhost.
>> Can I do it using network configuration or do I have to have firewall for that?
>> Or can I change qconn code to do something like this?
>>     
>
> Instead of bind()ing to INADDR_ANY:8000 you can
> bind() to INADDR_LOOPBACK:8000.
>
> Regards,
>
> -seanb
>
>
>
> _______________________________________________
>
> General
> http://community.qnx.com/sf/go/post62060
>
>   
Re: Blocking external access for qconn  
You probably need

 addr.sin_addr.s_addr = local ? htonl(INADDR_LOOPBACK) : INADDR_ANY;

but I would have thought the bind would fail.  Check 'netstat -an'.

Regards,

-seanb

On Fri, Aug 06, 2010 at 01:12:40PM -0400, Elena Laskavaia wrote:
> So I changed code to this:
> memset(&addr, 0x00, sizeof addr);
> addr.sin_len = sizeof addr;
> addr.sin_addr.s_addr = local?INADDR_LOOPBACK:INADDR_ANY;
> addr.sin_family = AF_INET;
> addr.sin_port = 9000;
> 
> if (bind(fd, (struct sockaddr *)&addr, addr.sin_len) == -1) {
> ...
> }
> But it does not accept connection now (if I run with local flag):
> 
> localhost:/tmp)telnet localhost 9000
> Trying 127.0.0.1...
> telnet: connect to address 127.0.0.1: Connection refused
> Trying ::1...
> telnet: socket: Address family not supported by protocol family
> 
> Anything else I need to change?
> 
> Sean Boudreau wrote:
> > On Fri, Aug 06, 2010 at 12:17:53PM -0400, Elena Laskavaia wrote:
> >   
> >> Lets say I start qconn on port 8000 on target.
> >> I want DENY all connections to this port from all hosts except localhost.
> >> Can I do it using network configuration or do I have to have firewall for that?
> >> Or can I change qconn code to do something like this?
> >>     
> >
> > Instead of bind()ing to INADDR_ANY:8000 you can
> > bind() to INADDR_LOOPBACK:8000.
> >
> > Regards,
> >
> > -seanb
> >
> >
> >
> > _______________________________________________
> >
> > General
> > http://community.qnx.com/sf/go/post62060
> >
> >   
> 
> 
> 
> _______________________________________________
> 
> General
> http://community.qnx.com/sf/go/post62087
> 
Re: Blocking external access for qconn  
  Thanks it worked!

On 06/08/10 01:16 PM, Sean Boudreau wrote:
> You probably need
>
>   addr.sin_addr.s_addr = local ? htonl(INADDR_LOOPBACK) : INADDR_ANY;
>
> but I would have thought the bind would fail.  Check 'netstat -an'.
>
> Regards,
>
> -seanb
>
> On Fri, Aug 06, 2010 at 01:12:40PM -0400, Elena Laskavaia wrote:
>> So I changed code to this:
>> memset(&addr, 0x00, sizeof addr);
>> addr.sin_len = sizeof addr;
>> addr.sin_addr.s_addr = local?INADDR_LOOPBACK:INADDR_ANY;
>> addr.sin_family = AF_INET;
>> addr.sin_port = 9000;
>>
>> if (bind(fd, (struct sockaddr *)&addr, addr.sin_len) == -1) {
>> ...
>> }
>> But it does not accept connection now (if I run with local flag):
>>
>> localhost:/tmp)telnet localhost 9000
>> Trying 127.0.0.1...
>> telnet: connect to address 127.0.0.1: Connection refused
>> Trying ::1...
>> telnet: socket: Address family not supported by protocol family
>>
>> Anything else I need to change?
>>
>> Sean Boudreau wrote:
>>> On Fri, Aug 06, 2010 at 12:17:53PM -0400, Elena Laskavaia wrote:
>>>
>>>> Lets say I start qconn on port 8000 on target.
>>>> I want DENY all connections to this port from all hosts except localhost.
>>>> Can I do it using network configuration or do I have to have firewall for that?
>>>> Or can I change qconn code to do something like this?
>>>>
>>> Instead of bind()ing to INADDR_ANY:8000 you can
>>> bind() to INADDR_LOOPBACK:8000.
>>>
>>> Regards,
>>>
>>> -seanb
>>>
>>>
>>>
>>> _______________________________________________
>>>
>>> General
>>> http://community.qnx.com/sf/go/post62060
>>>
>>>
>>
>>
>> _______________________________________________
>>
>> General
>> http://community.qnx.com/sf/go/post62087
>>
>
>
> _______________________________________________
>
> General
> http://community.qnx.com/sf/go/post62089
>
Re: Blocking external access for qconn  
And does somebody know answer to my first question? If I cannot modify the code can I block
external access using network configuration or I need firewall?