PF pf open/close a specific port to tcp

Hi,
I am a very noob and I'd like to be sure not doing any error

To open a tcp port ie. the 23456 I followed this piece of advice:
Code:
vim /etc/pf.conf
then I added:
Code:
pass in proto tcp from any to any port 23456
then after having saved I typed:
Code:
sudo pfctl -f /etc/pf.conf
is that correct?
When I want to come back to my specific former pf.conf, is this enough? putting a "#" at the line beginning
Code:
#pass in proto tcp from any to any port 23456
then again:
Code:
sudo pfctl -f /etc/pf.conf
?

Sorry if it seems basic or dumb, I would like to be sure putting a "#" is enough and that there is no specific law to write. And sorry for my English it's some French scholar English!
Thanks
This is a new world for me :)
 
Ports are not "opened" by a firewall. A service (like Apache or NTP) opens a port. All a firewall does is allow or block access to that port.

In any case, yes, you're doing it properly. Edit /etc/pf.conf and reload it with # pfctl -f /etc/pf.conf to activate it. You can use a command like # pfctl -sr to see what your active rules are.
 
thanks for your answer and sorry for the bad phrase with «open ». You’re right I meant « allow ».
I’m glad the « # » is enough to come back to the previous state. Best regards.
 
Back
Top