To change the IP address on a FreeBSD system, use the ifconfig command pattern.
sudo ifconfig interface_name inet new_ip_address netmask subnet_mask
Example
-
To change the IP address of the em0 interface to 192.168.1.100 with a subnet mask of 255.255.255.0, you would use the following command:
sudo ifconfig em0 inet 192.168.1.100 netmask 255.255.255.0
-
To make the changes permanent, you will need to edit the configuration files in /etc/rc.conf or /etc/rc.conf.d/
sudo vi /etc/rc.conf
-
Edit the line that starts with “ifconfig_em0” and add the IP, netmask and any other options you need.
ifconfig_em0="inet 192.168.1.100 netmask 255.255.255.0"
-
After that, you need to restart the network service or reboot your computer.
sudo service netif restart
Please be aware that the above commands and steps are examples, the actual commands and filenames may vary depending on your system configuration.
FreeBSDs’ ifconfig supports CIDR notation and has inet as default for address family, so you can write:
doas ifconfig em0 192.168.1.10/24
ifconfig_em0=”192.168.1.100/24″