How to set static IP address on the FreeBSD machine?

Solution 1:

in /etc/rc.conf:

ifconfig_em0="inet 192.168.0.254 netmask 255.255.255.0"
defaultrouter="192.168.0.1"
192.168.0.254 -- the machine IP, 192.168.0.1 -- gateway
These settings in rc.conf are looked up in the boot process.
If you'd like to set ip manually, run:
ifconfig em0 inet 192.168.0.254 netmask 255.255.255.0
route delete default; route add default 192.168.0.1

Solution 2:

Another way to do the same thing:

  • run "sysinstall" as root
  • "configure"
  • "networking"
  • "interfaces"
  • Now choose you interface and configure it.