[How To] set or change the IP address on FreeBSD

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

  1. 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
  2. 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
  3. 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"
    
  4. 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.

One Response

  1. gadoom January 16, 2023 Reply

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: