Simple question: closing ports

I want to close off some ports on my machine and I was told to use iptables (I have kernel 2.4.3). I can't figure out how to do it from the man page. What command would I issue to say close off port 111?
Who is Participating?

Improve company productivity with a Business Account.Sign Up

ahoffmannConnect With a Mentor Commented:
iptables -A FORWARD -d <your-IP> --dport 111 -j DROP
iptables -A INPUT   -d localhost --dport 111 -j DROP

# you need to have packetfiltering enabled in the kernel
you put a place to put my IP. I don't have a static IP. What do I put there? (localhost?)
deck16Author Commented:
rrr, I hate the auto-login (sorry for posting with a different account I'm at by brother's house (zxcvzxcv) not used to having to logout and then back in :-)
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

What about

ADDR=$(/sbin/ifconfig ppp0 | grep addr | cut -d':' -f 2 | cut -d' ' -f 1)

There the address is set as it IP number of your machine
and later refer to the IP address as $ADDR


iptables -A FORWARD -d $ADDR/32 --dport 111 -j DROP

deck16Author Commented:
why $ADDR/32 in the iptables argument?
that is the mask for the address 32 bits =
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.