Results 1 to 4 of 4
I'm running Fedora and have a Java program that attempts to bind ports 162 and 165 (SNMP). It is unable to bind these ports and gets an exception which says ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 02-27-2004 #1Just Joined!
- Join Date
- Feb 2004
- Posts
- 2
Java program unable to bind ports
I'm running Fedora and have a Java program that attempts to bind ports 162 and 165 (SNMP). It is unable to bind these ports and gets an exception which says that "permission denied".
I have the software firewall turned off and am not running the snmptrapd service. The snmpd service is running, which binds to the agent port 161 - so no conflicts there. I see nothing already bound to ports 162 and 165 when I run netstat.
I found the hosts.allow file in the /etc directory, and tried putting this line into it: "ALL:ALL:ALLOW" from one of the help file examples - no effect on the errors.
Can anyone tell me what if any security mechanisms may be stopping my program from accessing these ports, and how I can configure things to let it run correctly?
Thanks - Dave
- 02-27-2004 #2Linux Guru
- Join Date
- Apr 2003
- Location
- London, UK
- Posts
- 3,284
Re: Java program unable to bind ports
Any program attempting to bind to a port below 1024 must be started as root for security. The idea was that a user on the box could not "killall sendmail" and then start their own version with "extra functionality" without having admin privs on the machine.
Originally Posted by davebp
Jason
Jason
- 02-27-2004 #3Just Joined!
- Join Date
- Feb 2004
- Posts
- 2
Jason - Thanks! That makes sense.
I can in fact get my program to work if I log on as root. Is there some clever way to accomplish the same thing from inside my run.sh shell script - without having to log on as root?
Dave
- 02-27-2004 #4Linux Guru
- Join Date
- Apr 2003
- Location
- London, UK
- Posts
- 3,284
Really all you can do is change the port the application listens on (so its > 1024).
Alternativly, if possible in java, start it as root, and get it to switch user once it has bound to the port.
Jason


Reply With Quote
