Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.


I'm using Ubuntu 11.10. And I want to know something about firewall in Ubuntu, because I want to know if it could be the reason why my application doesn't work properly.

Little background:
I'have programmed client-server application, where Server is in C and client in java, when I run it from Eclipse Indigo (programing editor & environment) it works fine, but when I compile and run the klient in terminal, the communication doesn't work. The server doen't even recognize that the klient try to connect to the server. (using tcp sockets). Somebody said me that firewall could cause these problems, so my question should be probably What effect have firewall to applications and network communication??? (I run all on localhost 127.0.0.1 and port 10000).

It could be little complex question, so I'll try to more spiecify it with few little questions connected to my research and effort to find the source of problem.

This is what I've get when I put in terminal iptables -L:

Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination        

1) I look at ubuntu wiki and I suppose there should be some rules, so I suppose that the firewall is not configured and it's off. Question: Am I right?
2) If is the firewall off or not configured could it have affect to network communication on my computer? (According the backgroud info)
3) If is the firewall on or bad configured can I do something to set up it correctly or swich off? 4)If I do something from no. 3 will it have bad impact to my security (virus protection on internet)?

NOTE: I have few theoretical info about linux, newtorking, firewalls, but I don't have many experiences with linux configuration and practical using these things.

share|improve this question
add comment

2 Answers

I'm assuming that your server (which is also your client in this case) is behind a NAT router from the internet. If this is the case, a firewall on linux is not strictly needed. (There will be tin-foil hatters out there that say everything needs a well configured firewall.)

The output you have shows that there are no rules in effect and so the default is to let everything pass. So the problem likely exists elsewhere. Start by running your server program and then running

lsof | grep IP

and looking for the name of your program or the port 10000. If you don't find it on the list, then your program did not manage to bind a socket to a port. In that case, you need to do more error checking in your C code. If you do see your program, then look into a program called wireshark. Running wireshark while you run the client will allow you to see if your client is sending packets correctly. A filter like (tcp.port == 10000) should yield at least half of the conversation, depending on how your server works.

share|improve this answer
    
I runned the lsof | grep IP as you adviced. And I can see my application.Server 2318 ondra 3u IPv4 415089 0t0 TCP localhost:webmin (LISTEN) and when I change the port in server application to 20000 Server 2256 ondra 3u IPv4 382680 0t0 TCP localhost:20000 (LISTEN) webmin as port looks strange to me.. but server listen, so it probably works ok. I go get luck with wireshark. –  user1097772 Feb 19 '12 at 22:59
    
So the webmin is there only cause lsof things that on 10000 is running webmin, so this is not the problem, server works fine, so the problem must be in client –  user1097772 Feb 20 '12 at 0:13
    
There is a file that lists all the common ports and what they are used for. You can likely find it in the man page for lsof (or some related tool). It is a good idea to try to avoid those ports in your applications, just in case they're ever run on a machine where that port is already used. –  Huckle Feb 20 '12 at 1:24
add comment

The default firewall configuration tool for Ubuntu is ufw. Developed to ease iptables firewall configuration, ufw provides a user friendly way to create an IPv4 or IPv6 host-based firewall.

ufw by default is initially disabled. From the ufw man page:

“ ufw is not intended to provide complete firewall functionality via its command interface, but instead provides an easy way to add or remove simple rules. It is currently mainly used for host-based firewalls. ” The default firewall configuration tool for Ubuntu is ufw. Developed to ease iptables firewall configuration, ufw provides a user friendly way to create an IPv4 or IPv6 host-based firewall.

ufw by default is initially disabled. From the ufw man page:

“ ufw is not intended to provide complete firewall functionality via its command interface, but instead provides an easy way to add or remove simple rules. It is currently mainly used for host-based firewalls. ”

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.