FreeBSD Network Configuration Troubleshooting

A guide to diagnosing and resolving network issues in FreeBSD

Introduction

FreeBSD is known for its robust networking capabilities, but like any system, it can encounter issues. This guide will walk you through common network problems and their solutions in FreeBSD.

Basic Network Troubleshooting Steps

  1. Check physical connections
  2. Verify network interface status
  3. Check IP configuration
  4. Test local connectivity
  5. Test remote connectivity
  6. Check DNS resolution
  7. Verify firewall settings

Checking Network Interface Status

Use the following commands to check the status of your network interfaces:

ifconfig

This will list all network interfaces and their current configuration.

To check the status of a specific interface (e.g., em0):

ifconfig em0
Tip: Look for the "status: active" line to confirm the interface is up and running.

Verifying IP Configuration

Ensure your IP address, netmask, and gateway are correctly configured:

cat /etc/rc.conf

Look for lines like:

ifconfig_em0="inet 192.168.1.100 netmask 255.255.255.0"
defaultrouter="192.168.1.1"
  

If you need to change these settings, edit the file with:

ee /etc/rc.conf

After making changes, restart the network service:

service netif restart && service routing restart

Testing Connectivity

Local Connectivity

Test loopback interface:

ping -c 4 127.0.0.1

Remote Connectivity

Ping your default gateway:

ping -c 4 $(route -n get default | grep gateway | awk '{print $2}')

Ping a public DNS server:

ping -c 4 8.8.8.8

Checking DNS Resolution

Verify your DNS configuration:

cat /etc/resolv.conf

Test DNS resolution:

host www.freebsd.org

If DNS is not working, you can manually set DNS servers in /etc/resolv.conf:

nameserver 8.8.8.8
nameserver 8.8.4.4
  

Firewall Troubleshooting

Check if the firewall is enabled:

sysrc -n firewall_enable

If it returns "YES", review your firewall rules:

pfctl -s rules

Temporarily disable the firewall for testing:

service pf stop
Warning: Only disable the firewall temporarily and in a safe environment.

Advanced Network Diagnostics

Checking Network Statistics

netstat -i

This shows interface statistics, including packets sent/received and errors.

Tracing Network Routes

traceroute example.com

This shows the path packets take to reach a destination.

Checking Open Ports

sockstat -4l

This lists all IPv4 ports that are currently open and listening.

Common Issues and Solutions

1. Interface Not Detecting Link

If your interface isn't detecting a link, try:

2. Cannot Reach Default Gateway

3. DNS Resolution Failures

Additional Resources






Scroll to Top