If FreeBSD were a college student, network configuration would be how it says:
"Hey, I live here now, and this is my IP address."
Let’s help it not get lost every time it boots up!
First Things First: Check Your Interface Name
Before anything, we need to know your network interface's name. In FreeBSD, interface names are often... creatively named (like neighborhood cats).
Use:
ifconfig
Sample output:
em0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
Here, em0 is the interface name. For Wi-Fi, it could be wlan0, ath0, iwn0, or other funky aliases.
DHCP: The Lazy, Chill Option
If you want FreeBSD to automatically request an IP from your router, just add this to /etc/rc.conf:
ifconfig_em0="DHCP"
Replace em0 with your actual interface name, of course.
Static IP: Loyal and Predictable
If you need a fixed IP address (e.g., for a local server), use this config in /etc/rc.conf:
ifconfig_em0="inet 192.168.1.100 netmask 255.255.255.0"
defaultrouter="192.168.1.1"
Explanation:
-
192.168.1.100: Your desired IP -
255.255.255.0: Typical netmask -
192.168.1.1: Your gateway/router
Wi-Fi: Internet That Needs Sweet Talking
Wi-Fi on FreeBSD can be... temperamental. But yes, it’s possible! Here’s how:
1. Load the Driver and Firmware
For example, if you're using Intel Wi-Fi:
kldload if_iwm
kldload iwm8265fw
Add them to /boot/loader.conf to auto-load at boot:
if_iwm_load="YES"
iwm8265fw_load="YES"
2. Create wpa_supplicant.conf
vi /etc/wpa_supplicant.conf
Contents:
network={
ssid="YourWiFiName"
psk="yourpassword"
}
3. Add to rc.conf
wlans_iwm0="wlan0"
ifconfig_wlan0="WPA DHCP"
Or if you want a static IP:
ifconfig_wlan0="WPA inet 192.168.1.150 netmask 255.255.255.0"
defaultrouter="192.168.1.1"
Restart the Network
After setting everything, restart with:
service netif restart
service routing restart
If using Wi-Fi:
service wpa_supplicant restart
Check Your Connection
Check your IP:
ifconfig
Test connectivity:
ping google.com
If you get replies, congratulations — your FreeBSD box just made contact with the outside world!
| Mode | Simplicity | Best For |
|---|---|---|
| DHCP | Easiest | Desktops & laptops |
| Static IP | Needs precision | Servers, Raspberry Pi |
| Wi-Fi + WPA | Needs effort | Laptops & DIY nerds |

0 Comments:
Posting Komentar