Home > Articles > Apple > Operating Systems
␡- Understanding the Mac OS X Firewall
- This is the official web site of tcpdump, a powerful command-line packet analyzer; and libpcap, a portable C/C library for network traffic capture. In this page, you'll find the latest stable version of tcpdump and libpcap, as well as current development snapshots, a complete documentation, and information about how to report bugs.
- Packets ``dropped by kernel' (this is the number of packets that were dropped, due to a lack of buffer space, by the packet capture mechanism in the OS on which tcpdump is running, if the OS reports that information to applications; if not, it will be reported as 0).
- TCPdump is a powerful command-line packet analyzer tool which used to capture or filter TCP/IP packets that received or transferred over a network on a specific interface. It’s available on every Linux flavor for free of course. Install TCPdump on CentOS: yum install tcpdump. Install TCPdump on Debian and Ubuntu: apt-get install tcpdump.
Packet Peeper is a free network protocol analyzer (or ‘packet sniffer’) for Mac OS X. Its features include: TCP stream reassembly; Privilege separation; Simultaneous capture sessions; Filters, which may be defined at any time. Packet Peeper uses the same syntax as tcpdump and Wireshark (or any other program that uses the pcap library).
This chapter is from the book
This chapter is from the book
Time | This lesson takes approximately 30 minutes to complete. |
Goals | Control network traffic Understand the firewall options in Mac OS X and Mac OS X Server Explore the command line and remote configuration of firewalls |
Security has never been more critical when administrating client and server systems.
Today’s external threats range from macro viruses embedded in documents and spreadsheets, to denial of service network attacks. All networked systems are potentially vulnerable to probes and attacks—intentional and unintentional—as assailants constantly scan systems connected to the Internet. However, attacks can also come from internal sources. In 2008 and 2009, the greatest number of reported data breaches actually came from within corporate networks.
To help administrators protect their systems, this chapter focuses on mitigating and controlling access using Mac OS X firewalls on both the client and server. In this chapter, you’ll learn how to verify when attack attempts and system failures occur, and how to configure firewalls to guard against them.
Understanding the Mac OS X Firewall
In the days before digital technology, the term firewall described an actual fireproof wall designed to contain fires, such as the barrier between a car’s engine and its passenger section.
Like those physical walls, computer firewalls work to prevent improper network packets from “burning through” a host or network perimeter. Today’s digital firewalls consist of hardware or software that blocks unauthorized network access from sources outside or inside your network.
Mac OS X has two software firewalls: the IP Firewall (ipfw) and the Application Firewall. While ipfw is available in both Mac OS X and Mac OS X Server, Mac OS X Server includes a graphical user interface for detailed configuration, monitoring, and troubleshooting. Mac OS X provides basic, user-oriented service configuration, and optional advanced configuration. Mac OS X Server also includes an Adaptive Firewall, which can add and remove firewall rules based on network events.
Using the Mac OS X Application Firewall
The most common method for securing network services is to configure a firewall at the network perimeter, where the network connects to a remote network such as the Internet. Most networks use a firewall to limit inbound traffic from the Internet or remote connections. In fact, most home and small business routers, such as Apple’s AirPort base stations, are designed with built-in firewall software.
While network-level firewalls will block unauthorized traffic trying to enter your network, they will not block traffic that originated inside your network. Also, if your Mac is mobile and frequently joins new wired or wireless networks, your computer will regularly encounter networks with different firewall rules or, possibly, no firewall protection at all. So secure mobile access is an important consideration in designing your overall firewall policies.
To protect against unauthorized network access to your Mac, you can enable the Application Firewall via System Preferences. Administrators can utilize command-line tools to enable and configure the firewall.
Network-based firewalls use a set of rules that target specific service port numbers, such as TCP port 80, the port used for standard HTTP services. However, certain network services—such as iChatAgent (the background process that receives incoming connections for iChat)—use a wide range of dynamically assigned ports. These dynamic multiport services use more than one port to transfer multiple data types. For example, iChat can transmit audio, video, screen sharing, and text all at one time, which requires a multiport approach. This typically causes configuration complications with network-based firewalls because numerous ports need to be open to allow the service to function.
As a solution to this issue, Mac OS X’s Application Firewall allows connections based on application and service needs without requiring the user or administrator to know the myriad ports these apps and services may use. For example, you can authorize iChatAgent to allow incoming connections without manually configuring ports or port ranges.
The Application Firewall in Mac OS X version 10.6 includes a new feature that enables administrators to allow signed software to receive incoming connections automatically. Applications that have been digitally signed by their authors can accept inbound network connections without further configuration from the user or administrator, simplifying administration of deployed systems. Digitally signing an application provides reassurance that the application has not been tampered with.
Its adaptive nature means the Application Firewall will open necessary ports only when an application is running. This prevents several types of known attacks on personal systems.
Configuring the Mac OS X Application Firewall
To enable and configure the Max OS X firewall using System Preferences, here’s what you do:
- Open iChat by clicking its icon in the Dock.
- Choose Apple menu > System Preferences and then click the Security icon to open Security preferences.
- In the lower-left corner of the security pane, click the lock icon and then authenticate yourself as an administrative user to unlock Sharing preferences.
- Click the Firewall tab, and then click Start to turn on the Max OS X firewall using its default rules.
When the firewall is enabled, the Start button changes to a Stop button and the advanced button is enabled.
The default firewall configuration allows incoming traffic for established connections (such as a website responding to a click in Safari) and communications from any signed software or enabled services. This default configuration provides a level of security that is adequate for most users.
- To customize the firewall, click Advanced for additional configuration options.
You can see which services are currently enabled from the Sharing preferences. Sharing service ports are enabled by default when a service such as Web Sharing is enabled.
If you want to exercise more control over the configuration, you can manually set which applications and services the firewall allows by selecting or deselecting the checkbox that automatically allows signed software.
With this firewall choice enabled, when a network-aware application such as iChat opens or requests a network connection, a dialog, such as the one shown in the following figure, asks if you want to allow the application access to the network. This dialog will appear as a warning anytime a network-aware application requests incoming access for the first time.
- Click Allow to create a firewall rule that allows access for the application.
When manually setting firewall access by application or service in the Advanced tab, you can return to the Advanced tab to review and modify or specifically deny connections.
Another option provided by the firewall, Stealth Mode, prevents network probing tools that use common discovery tools based on the ICMP protocol (such as ping) from discovering the Mac is even on the network.
- Select the checkbox to enable Stealth Mode.
- From Applications > Utilities in Finder, open the Terminal and execute the following command to attempt to ping your system:
You will see the following timeout message illustrating that your system is not responding to the ping request.
Request timeout for icmp_seq
When utilizing your Mac on an unfamiliar network such as at an Internet café or a trade show, you can select “Block all incoming connections” to prevent any access except that required for basic network services, Internet browsing, and email. Selecting this option also will disable access to all shared services hosted on your Mac, but on an unfamiliar network this is highly desirable.
Unlike in Mac OS X Server, in Mac OS X the command-line ipfw program is the only interface available to configure port-based rules for a firewall manually.
Related Resources
- Book $55.99
- eBook (Watermarked) $55.99
- Web Edition $55.99
Introduction
In this tutorial, we’re going to bring you a popular network tool you should know about in order to correctly manage your networks.
We are assuming that you have root permission, otherwise, you may start commands with “sudo”.
Install TCPdump
TCPdump is a powerful command-line packet analyzer tool which used to capture or filter TCP/IP packets that received or transferred over a network on a specific interface. it’s available on every Linux flavor for free of course.
Install TCPdump on CentOS:
Install TCPdump on Debian and Ubuntu:
Once the TCPdump tool is installed, you can continue to browse following commands.
Capture packets from a specific interface
If you execute the TCPdump command with the “-i” flag you can name an interface and the TCPdump tool will start capture that specific interface packets for you.
Capture only specific number of packets
Using “-c” flag will allow you to capture a specific number of packets, for example, with the command below we can capture 20 packets of our eth0 interface:
Print captured packets in ASCII
The below TCPdump command with the flag “-A” displays the packages in ASCII format. it’s a character-encoding scheme format.
Display available interfaces
To get a list of available interfaces on the system you can run the following command:
Capture and save packets in a file
Clamav For Mac Os X
TCPdump has a feature to capture and save its result in a “.pcap” file, to do this just execute:
If you don’t use “-c” flag it will start capturing eth0 and write the result to the output file until you break it with “Ctrl+c”.
For read and analyze the file that you just created execute:
Tcpdump Show Mac Address
Capture IP address packets
If you want to capture your network interface and analyze the IP address you can use the “-n” flag it will stop translating IP addresses into Hostnames and This can be used to avoid DNS lookups.
Capture only TCP packets
To capture packets based on TCP ports, add a “tcp” in your command:
Tcpdump Mac Filter
Capture packets from a specific port
Tcpdump Examples
Let’s assume you want to monitor on a specific port like 80, you can use the following command to do that with TCPdump:
Filter records with source and destination IP
To Capture packets from a source IP you can use the following command:
You can monitor packets from a destination IP as well with the command below:
You can find more information about TCPdump on its official website!