Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mac OSX – open a port

Tags:

I want to open the port 25 of my Mac, so I edited the file /etc/pf.conf

MacBook-Pro-de-nunito:~ calzada$ more /etc/pf.conf # # Default PF configuration file. # # This file contains the main ruleset, which gets automatically loaded # at startup.  PF will not be automatically enabled, however.  Instead, # each component which utilizes PF is responsible for enabling and disabling # PF via -E and -X as documented in pfctl(8).  That will ensure that PF # is disabled only when the last enable reference is released. # # Care must be taken to ensure that the main ruleset does not get flushed, # as the nested anchors rely on the anchor point defined here. In addition, # to the anchors loaded by this file, some system services would dynamically  # insert anchors into the main ruleset. These anchors will be added only when # the system service is used and would removed on termination of the service. # # See pf.conf(5) for syntax. #  # # com.apple anchor point # pass in proto tcp from any to any port 80 pass in proto tcp from any to any port 25 scrub-anchor "com.apple/*" nat-anchor "com.apple/*" rdr-anchor "com.apple/*" dummynet-anchor "com.apple/*" anchor "com.apple/*" load anchor "com.apple" from "/etc/pf.anchors/com.apple" 

But when I restart the service, I got these errors:

MacBook-Pro-de-nunito:~ calzada$ sudo pfctl -f /etc/pf.conf pfctl: Use of -f option, could result in flushing of rules present in the main ruleset added by the system at startup. See /etc/pf.conf for further details.  No ALTQ support in kernel ALTQ related functions disabled /etc/pf.conf:24: Rules must be in order: options, normalization, queueing, translation, filtering /etc/pf.conf:25: Rules must be in order: options, normalization, queueing, translation, filtering /etc/pf.conf:26: Rules must be in order: options, normalization, queueing, translation, filtering pfctl: Syntax error in config file: pf rules not loaded 

adding the lines at the end of the file:

MacBook-Pro-de-nunito:~ calzada$ sudo pfctl -f /etc/pf.conf pfctl: Use of -f option, could result in flushing of rules present in the main ruleset added by the system at startup. See /etc/pf.conf for further details.  No ALTQ support in kernel ALTQ related functions disabled MacBook-Pro-de-nunito:~ calzada$ nmap -p 25 localhost  Starting Nmap 7.40 ( https://nmap.org ) at 2017-03-12 21:35 CET Nmap scan report for localhost (127.0.0.1) Host is up (0.00023s latency). Other addresses for localhost (not scanned): ::1 PORT   STATE  SERVICE 25/tcp closed smtp  Nmap done: 1 IP address (1 host up) scanned in 0.04 seconds 
like image 465
Nunyet de Can Calçada Avatar asked Mar 12 '17 19:03

Nunyet de Can Calçada


People also ask

How do I open a specific port?

Answer: From the Control Panel, navigate to System and Security, and click on Windows Firewall. Go to the Advanced settings and right-click on Inbound Rules on the left pane. Select New Rule, add the port and click Next. Pick the Protocol and the Port Number, click Next again.

How do I check if a port is open on my Mac?

On a Mac computer (earlier than macOS 11 Big Sur)Type "Network Utility" in the search field and select Network Utility. Select Port Scan, enter an IP address or hostname in the text field, and specify a port range. Click Scan to begin the test. If a TCP port is open, it will be displayed here.


1 Answers

Are you sure you have something listening on port 25? If you don't have anything listening on port 25 it will show as closed.

As you ran nmap on localhost you wouldn't even need to allow anything through the firewall. You would only need to allow it through the firewall if traffic was coming inbound from another device.

You can use the following to check if a program is listening on port 25

lsof -n -i:25 | grep LISTEN

like image 147
Ryan Avatar answered Nov 02 '22 00:11

Ryan