During FreeBSD installation, the user is offered automatic network configuration via DHCP by default. This is convenient if a DHCP server is available in the local network, but it can cause problems if the network uses only static IP addresses. In such cases, after the system installation is complete, the user may find that there is no access to the internet or local network. To fix this issue, a static IP address must be manually assigned.
Log into the system and run the ifconfig
command to determine the network interface.
In our case, the interface is vtnet0
.
Temporarily assign a static IP address using the command:ifconfig <interface> inet <ip> netmask <netmask> up
route add default <gateway>
Now specify the DNS servers:echo “nameserver 8.8.8.8” >> /etc/resolv.conf
echo “nameserver 8.8.4.4” >> /etc/resolv.conf
Next, test the connection:ping 8.8.8.8
Once we’ve confirmed that the network is working, we need to make this configuration permanent. Edit the /etc/rc.conf
file. To do this, enter the command:
vi /etc/rc.conf
The editor window will open. Locate the line that starts with ifconfig_vtnet0
.
Change its value to:"inet <ip> netmask <netmask>"
.To start editing, press the “i” key. Use the “delete” key to remove characters.
Then, on the next line, add: defaultrouter=”<gateway>”
To save changes and exit the editor, press Esc and type :wq!
, then hit Enter.
Finally, reboot the system with the command: reboot
Your static IP address is now configured.