LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices


Reply
  Search this Thread
Old 07-07-2007, 12:55 AM   #1
nomb
Member
 
Registered: Jan 2006
Distribution: Debian Testing
Posts: 675

Rep: Reputation: 58
Um, quick question about ports.


I just installed a fresh install of debian, no matter what firewall system i get going these ports dont change:

21 - Open
22 - Open
113 - Closed

I like to get everything stealthed. Why wont these change?

nomb
 
Old 07-07-2007, 02:48 AM   #2
makuyl
Senior Member
 
Registered: Dec 2004
Location: Helsinki
Distribution: Debian Sid
Posts: 1,107

Rep: Reputation: 54
The reason for open ports is that you have services listening on those ports, ftp, ssh and rpc.
You can probably disable everything in /etc/inetd.conf with a "#" at the beginning of each line.
Do a "netstat -tunap|grep LISTEN" and check the servicename to the right, for example ssh.
For each do "update-rc.d -f ssh remove" and "/etc/init.d/ssh stop" substituting ssh for each netstat output.
 
Old 07-07-2007, 05:33 AM   #3
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 57
21:ftp
22:ssh
113: identd <-- used for irc and some ftp servers
 
Old 07-07-2007, 09:17 AM   #4
nomb
Member
 
Registered: Jan 2006
Distribution: Debian Testing
Posts: 675

Original Poster
Rep: Reputation: 58
Um, this was the output:

tcp 0 0 0.0.0.0:43403 0.0.0.0:* LISTEN 3038/rpc.statd
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 2500/portmap
tcp 0 0 0.0.0.0:113 0.0.0.0:* LISTEN 2989/inetd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 2854/cupsd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2975/exim4

I don't have ssh installed or ftp yet. Does this make sense? Do you think since it is enabled in my router it is giving a 'false positive'?

What can I do to the above so they don't show up in netstat?

Thanks,
nomb
 
Old 07-07-2007, 10:38 AM   #5
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 57
tcp 0 0 0.0.0.0:43403 0.0.0.0:* LISTEN 3038/rpc.statd
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 2500/portmap

Do you have samba or nfs?
You can see what rpc service is active:
rpcinfo -p localhost
Then, if you don't need to be an rpc server for anyone but you you can restrict the interface to listen to localhost only
there is an /etc/rpc.conf and there is an option line, here you should probably put -i 127.0.0.1 (look at portmap manpage)
If you don't need portmap (no rpcinfo service that you need), remove the package portmap



tcp 0 0 0.0.0.0:113 0.0.0.0:* LISTEN 2989/inetd
This is inetd opening identd.
Either you remove inetd or if you keep it and not need identd, then comment the line identd in /etc/inetd.conf) and restart inetd:
killall -HUP inetd

21 and 22 open needs more investigation, could be your router or anything.
Actually I wonder why it says 113 closed while its opened??

How did you check these open ports?
Go on grc.com
 
Old 07-07-2007, 09:17 PM   #6
nomb
Member
 
Registered: Jan 2006
Distribution: Debian Testing
Posts: 675

Original Poster
Rep: Reputation: 58
Ok when I ran that rpcinfo command I got:

100000 2 tcp 111 portmapper
100000 2 udp 111 portmapper
100024 1 udp 32768 status
100024 1 tcp 43403 status

not sure exactly what it is. I seem to recall useing it for nfs but not sure. I don't have anything like that so I can probably disable it?

Same thing for inet.d. I'm not sure what it is or if I need it.

as far as port 21, 22, and 113 on the scan, it's gotta be the router because when I use nmap on the lo, those don't get returned.

grc.com is what I'm using to scan.
 
Old 07-07-2007, 10:49 PM   #7
farslayer
LQ Guru
 
Registered: Oct 2005
Location: Northeast Ohio
Distribution: linuxdebian
Posts: 7,249
Blog Entries: 5

Rep: Reputation: 191Reputation: 191
Yes if you have port forwards set on the router the Scan from GRC will show the ports as open regardless if they are open on the PC behind the router or not..

Disable those port forwards in your broadband router config and the scan will be fully stealthed.
 
Old 07-08-2007, 10:34 AM   #8
nomb
Member
 
Registered: Jan 2006
Distribution: Debian Testing
Posts: 675

Original Poster
Rep: Reputation: 58
... i did nmap 127.0.0.1 and got:

25/tcp open smtp
80/tcp open http
111/tcp open rpcbind
113/tcp open auth
631/tcp open ipp

i dont think im making this any better. Can you guys take a look at my firewall script please?

Code:
#!/bin/bash

# No spoofing
if [ -e /proc/sys/net/ipv4/conf/all/rp_filter ]
then
for filtre in /proc/sys/net/ipv4/conf/*/rp_filter
do
echo 1 > $filtre
done
fi 

# No icmp
echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all
echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts

#load some modules you may need
modprobe ip_tables
modprobe ip_nat_ftp
modprobe ip_nat_irc
modprobe iptable_filter
modprobe iptable_nat 

# Remove all rules and chains
iptables -F
iptables -X

# first set the default behaviour => accept connections
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT

# Create 2 chains, it allows to write a clean script
iptables -N FIREWALL
iptables -N TRUSTED

# Allow ESTABLISHED and RELATED incoming connection
iptables -A FIREWALL -i eth2 -m state --state ESTABLISHED,RELATED -j ACCEPT
# Allow loopback traffic
iptables -A FIREWALL -i lo -j ACCEPT
# Send all package to the TRUSTED chain
iptables -A FIREWALL -j TRUSTED
# DROP all other packets
iptables -A FIREWALL -j DROP

# Send all INPUT packets to the FIREWALL chain
iptables -A INPUT -j FIREWALL
# DROP all forward packets, we don't share internet connection in this example
iptables -A FORWARD -j DROP

# Allow https	 
# iptables -A TRUSTED -i eth0 -p udp -m udp --sport 443 -j ACCEPT	 
# iptables -A TRUSTED -i eth0 -p tcp -m tcp --sport 443 -j ACCEPT

# End message
echo " [End iptables rules setting]"
I know this is very basic. I was hopeing someone could suggest a more hardened firewall entries.

Last edited by nomb; 07-08-2007 at 10:36 AM.
 
Old 07-08-2007, 01:28 PM   #9
makuyl
Senior Member
 
Registered: Dec 2004
Location: Helsinki
Distribution: Debian Sid
Posts: 1,107

Rep: Reputation: 54
No pun intended but that firewall script doesn't do much. At least make the input default DROP. Hwo about letting this page make a script for you: http://easyfwgen.morizot.net/gen/

Routers aren't very good at stealthing 113. Best way is to forward it in the router to a natted IP address that you don't use. Say your box is 192.168.1.2 then forward 113 to 192.168.1.10 or some such.

You need not worry about services listening on 127.0.0.1:??? since that's just a loopback (localhost).

Like instructed above, remove portmap with "apt-get --purge remove portmap" and comment out everything in /etc/inetd.conf with a "#" at the beginning of each line.
 
Old 07-08-2007, 02:05 PM   #10
nomb
Member
 
Registered: Jan 2006
Distribution: Debian Testing
Posts: 675

Original Poster
Rep: Reputation: 58
I used that site and this is what I came back with. However, it wont let me access the internet or anything if the firewall is on:

Code:
Chain INPUT (policy DROP)
target     prot opt source               destination         
ACCEPT     0    --  anywhere             anywhere            
bad_packets  0    --  anywhere             anywhere            
DROP       0    --  anywhere             224.0.0.1           
ACCEPT     0    --  anywhere             anywhere            state RELATED,ESTABLISHED 
tcp_inbound  tcp  --  anywhere             anywhere            
udp_inbound  udp  --  anywhere             anywhere            
icmp_packets  icmp --  anywhere             anywhere            
DROP       0    --  anywhere             anywhere            PKTTYPE = broadcast 
LOG        0    --  anywhere             anywhere            limit: avg 3/min burst 3 LOG level warning prefix `INPUT packet died: ' 

Chain FORWARD (policy DROP)
target     prot opt source               destination         

Chain OUTPUT (policy DROP)
target     prot opt source               destination         
DROP       icmp --  anywhere             anywhere            state INVALID 
ACCEPT     0    --  localhost            anywhere            
ACCEPT     0    --  anywhere             anywhere            
ACCEPT     0    --  anywhere             anywhere            
LOG        0    --  anywhere             anywhere            limit: avg 3/min burst 3 LOG level warning prefix `OUTPUT packet died: ' 

Chain bad_packets (1 references)
target     prot opt source               destination         
LOG        0    --  anywhere             anywhere            state INVALID LOG level warning prefix `Invalid packet: ' 
DROP       0    --  anywhere             anywhere            state INVALID 
bad_tcp_packets  tcp  --  anywhere             anywhere            
RETURN     0    --  anywhere             anywhere            

Chain bad_tcp_packets (1 references)
target     prot opt source               destination         
LOG        tcp  --  anywhere             anywhere            tcp flags:!FIN,SYN,RST,ACK/SYN state NEW LOG level warning prefix `New not syn: ' 
DROP       tcp  --  anywhere             anywhere            tcp flags:!FIN,SYN,RST,ACK/SYN state NEW 
LOG        tcp  --  anywhere             anywhere            tcp flags:FIN,SYN,RST,PSH,ACK,URG/NONE LOG level warning prefix `Stealth scan: ' 
DROP       tcp  --  anywhere             anywhere            tcp flags:FIN,SYN,RST,PSH,ACK,URG/NONE 
LOG        tcp  --  anywhere             anywhere            tcp flags:FIN,SYN,RST,PSH,ACK,URG/FIN,SYN,RST,PSH,ACK,URG LOG level warning prefix `Stealth scan: ' 
DROP       tcp  --  anywhere             anywhere            tcp flags:FIN,SYN,RST,PSH,ACK,URG/FIN,SYN,RST,PSH,ACK,URG 
LOG        tcp  --  anywhere             anywhere            tcp flags:FIN,SYN,RST,PSH,ACK,URG/FIN,PSH,URG LOG level warning prefix `Stealth scan: ' 
DROP       tcp  --  anywhere             anywhere            tcp flags:FIN,SYN,RST,PSH,ACK,URG/FIN,PSH,URG 
LOG        tcp  --  anywhere             anywhere            tcp flags:FIN,SYN,RST,PSH,ACK,URG/FIN,SYN,RST,ACK,URG LOG level warning prefix `Stealth scan: ' 
DROP       tcp  --  anywhere             anywhere            tcp flags:FIN,SYN,RST,PSH,ACK,URG/FIN,SYN,RST,ACK,URG 
LOG        tcp  --  anywhere             anywhere            tcp flags:SYN,RST/SYN,RST LOG level warning prefix `Stealth scan: ' 
DROP       tcp  --  anywhere             anywhere            tcp flags:SYN,RST/SYN,RST 
LOG        tcp  --  anywhere             anywhere            tcp flags:FIN,SYN/FIN,SYN LOG level warning prefix `Stealth scan: ' 
DROP       tcp  --  anywhere             anywhere            tcp flags:FIN,SYN/FIN,SYN 
RETURN     tcp  --  anywhere             anywhere            

Chain icmp_packets (1 references)
target     prot opt source               destination         
LOG        icmp -f  anywhere             anywhere            LOG level warning prefix `ICMP Fragment: ' 
DROP       icmp -f  anywhere             anywhere            
DROP       icmp --  anywhere             anywhere            icmp echo-request 
ACCEPT     icmp --  anywhere             anywhere            icmp time-exceeded 
RETURN     icmp --  anywhere             anywhere            

Chain tcp_inbound (1 references)
target     prot opt source               destination         
REJECT     tcp  --  anywhere             anywhere            tcp dpt:auth reject-with icmp-port-unreachable 
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:ssh 
RETURN     tcp  --  anywhere             anywhere            

Chain tcp_outbound (0 references)
target     prot opt source               destination         
ACCEPT     tcp  --  anywhere             anywhere            

Chain udp_inbound (1 references)
target     prot opt source               destination         
DROP       udp  --  anywhere             anywhere            udp dpt:netbios-ns 
DROP       udp  --  anywhere             anywhere            udp dpt:netbios-dgm 
REJECT     udp  --  anywhere             anywhere            udp dpt:113 reject-with icmp-port-unreachable 
ACCEPT     udp  --  anywhere             anywhere            udp spt:bootps dpt:bootpc 
RETURN     udp  --  anywhere             anywhere            

Chain udp_outbound (0 references)
target     prot opt source               destination         
ACCEPT     udp  --  anywhere             anywhere
nvm... i put the wrong interface in... now to test it...

Last edited by nomb; 07-08-2007 at 02:30 PM.
 
  


Reply



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
A quick question about ports & internal/external networks for webservers... jacksonscottsly Linux - Networking 2 07-10-2005 09:35 PM
quick question about ports jp-lack Slackware 6 07-09-2005 09:23 PM
Quick Question about listening ports nevarlen Linux - Newbie 9 06-24-2005 03:40 PM
Question Concerning ISO's and one quick question. evrae Linux - Software 2 06-21-2004 03:53 AM
samba smb.config question (quick question) TheDOGG Linux - Networking 1 03-02-2004 07:19 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian

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