14

I have a FreeBSD machine running on a virtual machine. I am using SUN Virtual Box. I need to set static IP address to this machine. So that I can access this machine. Is there anyway to do this ?

0

2 Answers 2

26

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

2
  • It can also be done without directly editing the file, via sysrc ifconfig_em0=inet 192.168.0.254 netmask 255.255.255.0. sysrc` is a built-in tool in FreeBSD specifically designed to add/remove entries from the /etc/rc.conf file.
    – user373230
    Jun 12, 2017 at 18:43
  • I am using FreeBSD 11.2-RELEASE-p10 and when I run the command I am getting unknown variable error. Nov 17, 2019 at 12:16
2

Another way to do the same thing:

  • run "sysinstall" as root
  • "configure"
  • "networking"
  • "interfaces"
  • Now choose you interface and configure it.
1
  • 1
    There is no sysinstall on FreeBSD 11.1-RELEASE
    – Megidd
    Sep 11, 2017 at 4:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .