• Post Reply Bookmark Topic Watch Topic
  • New Topic

Ports  RSS feed

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do I know what services are running on which port?
And, how do I find out if some of the ports are blocked? I have samba installed and its not accepting connections over the network...so apparantly UDP 137-139 is blocked by a firewall, I can't figure out if its IPTABLES or something else.
 
author and jackaroo
Marshal Commander
Posts: 12156
256
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Heath,
<code>netstat -a</code> will show you what ports your system is listening on. If it is unable to do proper reverse lookups to connected systems, it may take some time for timeouts to happen. If you are impatient you can do <code>netstat -an</code> which will stop the lookups (all numeric outputs).
If you do look at the numeric outputs and see something like 0.0.0.0:512 and dont know all the port numbers off the top of your head then you can look in <code>/etc/services</code> which lists all the known services, the ports and protocols they use.
There is another way under linux but I forget how at the moment - I prefer to use methods that work under any *nix system.
If samba is running, you should see the port numbers in the listing from netstat, regardless of whether a firewall is blocking it or not.
For your firewall question, you need to find out if you are running ipchains (old system) or iptables. I no longer have access to ipchains (try typing <code>which ipchains</code> and see if it is installed). If you have iptables installed, you should (as root) be able to type <code>iptables -L -v</code> to see what is being blocked and what is being allowed through. This will only list the standard table - if you have NAT running, then you may have nat tables as well (<code>iptables -L -v -t nat</code>).
Regards, Andrew
 
heath carlough
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
:input ACCEPT
:forward ACCEPT
utput ACCEPT
-A input -s 0/0 -d 0/0 80 -p tcp -y -j ACCEPT
-A input -s 0/0 -d 0/0 21 -p tcp -y -j ACCEPT
-A input -s 0/0 -d 0/0 22 -p tcp -y -j ACCEPT
-A input -s 0/0 -d 0/0 23 -p tcp -y -j ACCEPT
-A input -s 0/0 67:68 -d 0/0 67:68 -p udp -i eth0 -j ACCEPT
-A input -s 0/0 67:68 -d 0/0 67:68 -p udp -i eth1 -j ACCEPT
-A input -s 0/0 -d 0/0 -i lo -j ACCEPT
-A input -p tcp -s 0/0 -d 0/0 0:1023 -y -j REJECT
-A input -p tcp -s 0/0 -d 0/0 2049 -y -j REJECT
-A input -p udp -s 0/0 -d 0/0 0:1023 -j REJECT
-A input -p udp -s 0/0 -d 0/0 2049 -j REJECT
-A input -p tcp -s 0/0 -d 0/0 6000:6009 -y -j REJECT
-A input -p tcp -s 0/0 -d 0/0 7100 -y -j REJECT
This is my ipchains rules, do I have explicity add an ACCEPT for samba (udp 139)??
thanks for your post
 
heath carlough
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your input Andrew, I found out it was a firewall issue (ipchains for my box) and I was adding a rule for UDP and it wasn't working, later I found out that samba uses TCP. So I added a ACCEPT rule in the chain and it works perfectly now.
 
Saloon Keeper
Posts: 18800
74
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's a good idea to always log rejected packets. Samba uses ports 137-139 and (for Win2K mode) 453(?). It seems to degrade gracefully if certain ports are blocked, but I wouldn't expect it to handle every misconfiguration.
I'm not 100% sure on the port scheme, but it's in that general direction.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!