Solved Unable to access internet from FreeBSD running as guest on virtualbox

alwindoss

New Member

Reaction score: 3
Messages: 12

I am a new user of FreeBSD and I managed to install it on virtualbox as a guest after failing to install it directly on my laptop. I will do that after I gain confidence in FreeBSD on virtualbox.

However after installation I am unable to access internet from the Guest FreeBSD. I have looked through forums and none of the solutions listed there are working.

I am determined to learn and use FreeBSD, if someone could walk me through getting out of this problem it will help me.

I didn't know what is the basic information that needs to be posted for a network related issue so haven't posted any. Please let me know if I have to post specific details.
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 12,342
Messages: 38,859

Check the network settings in Virtualbox. The easiest to use is NAT or bridged.
 
OP
alwindoss

alwindoss

New Member

Reaction score: 3
Messages: 12

Check the network settings in Virtualbox. The easiest to use is NAT or bridged.
I tried both NAT and Bridged without success. Do I have to set any specific configuration.

One other detail is during installation after configuring the networks as a final step in the process it asked me if I want to download the handbook. Just to check if internet is accessible I tried that option of downloading and it was successful. Not sure what happened when I booted into the OS.
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 12,342
Messages: 38,859

Ok, that probably means the settings in Virtualbox are good. What does ifconfig(8) show? Does any other interface besides lo0 show up?
 

Paul Floyd

Active Member

Reaction score: 48
Messages: 135

It's not easy to be specific because the required configuration varies so much.

What network options did you choose during install?
 
OP
alwindoss

alwindoss

New Member

Reaction score: 3
Messages: 12

Ok, that probably means the settings in Virtualbox are good. What does ifconfig(8) show? Does any other interface besides lo0 show up?
No I only see lo0, here is the screenshot of the same
Screenshot from 2020-07-02 15-02-46.png
 
OP
alwindoss

alwindoss

New Member

Reaction score: 3
Messages: 12

It's not easy to be specific because the required configuration varies so much.

What network options did you choose during install?
The only thing I chose is the DHCP configuration, I don't seem to recall the specifics, is there anyway I can retrieve this information from a file in the system?
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 12,342
Messages: 38,859

No I only see lo0
Look more closely, you have an em0 interface. Which actually has an IP address. So you should have network in the guest.

is there anyway I can retrieve this information from a file in the system?
Pretty much all important configuration on FreeBSD is done in /etc/rc.conf.
 

Zvoni

Active Member

Reaction score: 94
Messages: 165

and his em0 looks suspiciously like a Bridge and not the standard NAT.
For reasons unknown, for me, FreeBSD in VBox as guest only works with NAT
 
OP
alwindoss

alwindoss

New Member

Reaction score: 3
Messages: 12

My apologies trying to follow different solutions on the forums I had made multiple changes. As part of that I had done the following changes:
  1. Edited /etc/rc.conf
  2. Added different entries trying to experiment
  3. Changed to different adapter in the virtualbox

However, when I removed all the duplicate entries in the /etc/rc.conf and only left the one with em0 and switched the virtualbox adapter to bridged, I was able to access the internet
 

T-Daemon

Daemon

Reaction score: 881
Messages: 1,761

For reasons unknown, for me, FreeBSD in VBox as guest only works with NAT
You have missed this VirtualBox documentation:


The network configuration is done accordingly, ie:

If the host is connected by cable to the network router -> (VBox network configuration) en0: Ethernet, when wifi -> en1: Wi-Fi (en0, en1 - hosts physical network interfaces may differ on your system).

(guests) /etc/rc.conf:
Rich (BB code):
ifconfig_em0="DHCP"
defaultrouter="ip of the (physical) router in the network"
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 12,342
Messages: 38,859

You do not need to set defaultrouter if you use DHCP. You should get this setting from DHCP.
 

Mjölnir

Daemon

Reaction score: 1,505
Messages: 2,114

The default router should be set by dhclient(8) if DHCP is enabled on that interface?
I set a metric with ifconfig(8) (ifconfig_xxx="defaultif metric 1" in rc.conf(5)), so depending on wether I plug in em(4) or have WLAN, or use PPP's tun0 with my WWAN modem, the default route is set accordingly.
EDIT: SirDice, you're always 15 seconds too fast!
2nd EDIT: alwindoss: pkg install {en,bn}-freebsd-doc then the docs are under /usr/local/share/doc/freebsd to be viewn with any browser.
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 12,342
Messages: 38,859

I set a metric with ifconfig(8) (ifconfig_xxx="defaultif metric 1" in rc.conf(5)), so depending on wether I plug in em(4) or have WLAN, or use PPP's tun0 with my WWAN modem, the default route is set accordingly.
The metric is ignored. It's only useful with dynamic routing protocols like OSPF or BGP. Your default route is set by the last DHCP response you got.
 
Top