11773 How to configure a NIC on FreeBSD host so it's dedicated to VirtualBox VM - The FreeBSD Forums
The FreeBSD Forums  

Go Back   The FreeBSD Forums > Server & Networking > Networking

Networking Network related discussions (including general TCP/IP stuff, routing, etc).

Reply
 
Thread Tools Display Modes
  #1  
Old August 29th, 2011, 01:59
LSDave LSDave is offline
Junior Member
 
Join Date: May 2010
Posts: 16
Thanks: 3
Thanked 0 Times in 0 Posts
Default How to configure a NIC on FreeBSD host so it's dedicated to VirtualBox VM

I have a dual-homed FreeBSD 9.0 machine that itself only uses one NIC. Until today, I have left the second NIC unconfigured.

Now I have installed Virtualbox on the FreeBSD host, and want to assign a particular Window guest two NICs, including dedicated access to this second, previously unused NIC. Within VirtualBox, I know this is a matter of selecting "Bridged Adapter" and pointing VirtualBox to the second NIC. What is unclear is how do I configure the second NIC on the FreeBSD host, so that the NIC is up and available for Virtualbox guests, without having TCP/IP properties or being connectable by/to the host.

With Hyper-V or VMware on Windows, this is simple a matter of enabling the NIC on the host machine, and then accessing the NIC's properties on the host machine, and then unchecking all the connection items (e.g, Client for Microsoft Networks, QoS Packet Scheduler, File and Print Sharing TCP/IPv4, TCP/IPv6, etc).

I am still new to FreeBSD and am not sure how to achieve the equivalent result editing by the /etc/rc.conf (or whatever other file).

Any help is appreciated. Thanks in advance.
Reply With Quote
  #2  
Old August 29th, 2011, 05:50
wblock@'s Avatar
wblock@ wblock@ is offline
Moderator
 
Join Date: Sep 2009
Location: Milky Way galaxy
Posts: 7,850
Thanks: 444
Thanked 1,828 Times in 1,494 Posts
Default

Interesting question. I would guess as long as it isn't assigned an IP address, an interface would be up but unused. It wouldn't hurt to just set it that way:
/etc/rc.conf
Code:
ifconfig_re1="up"
As an alternate question: is a second NIC even needed? Well, yes, if it's connected to a different physical network. But can you bridge more than one VM onto a single physical card? Haven't tested, but I'd think so.
Reply With Quote
  #3  
Old August 29th, 2011, 08:15
pbd pbd is offline
Member
 
Join Date: Nov 2008
Location: Brno, CZ
Posts: 187
Thanks: 9
Thanked 31 Times in 31 Posts
Default

Quote:
Originally Posted by wblock View Post
But can you bridge more than one VM onto a single physical card?
Yes, that is possible.
Reply With Quote
The Following User Says Thank You to pbd For This Useful Post:
wblock@ (August 29th, 2011)
  #4  
Old August 30th, 2011, 01:14
LSDave LSDave is offline
Junior Member
 
Join Date: May 2010
Posts: 16
Thanks: 3
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by wblock View Post
Interesting question. I would guess as long as it isn't assigned an IP address, an interface would be up but unused. It wouldn't hurt to just set it that way:
/etc/rc.conf
Code:
ifconfig_re1="up"
As an alternate question: is a second NIC even needed? Well, yes, if it's connected to a different physical network. But can you bridge more than one VM onto a single physical card? Haven't tested, but I'd think so.
Thank you for your response. Following your advice I added:

/etc/rc.conf
Code:
ifconfig_re1="up"
This worked partially, in that the NIC is up without IPv4 TCP/IP properties assigned, but another concern has arisen. When I run ifconfig it appears that FreeBSD is still assigning IPv6 local-link addresses.

Specifically, the following output is returned:

Code:
bge0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=8009b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,LINKSTATE>
        ether [secret]
        inet 192.168.Y.X netmask 0xffffff00 broadcast 192.168.Y.255
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
        media: Ethernet autoselect (1000baseT <full-duplex>)
        status: active

rl0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=3808<VLAN_MTU,WOL_UCAST,WOL_MCAST,WOL_MAGIC>
        ether [secret]
        inet6 fe80::220:18ff:fed9:f864%rl0 prefixlen 64 scopeid 0x7 
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
        media: Ethernet autoselect (100baseTX <full-duplex>)
        status: active

lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
        options=3<RXCSUM,TXCSUM>
        inet6 ::1 prefixlen 128 
        inet6 fe80::1%lo0 prefixlen 64 scopeid 0x8 
        inet 127.0.0.1 netmask 0xff000000 
        nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>

vboxnet0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500
        ether [secret]
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
I do not use IPv6 on the Host and would prefer the Realtek NIC not be assigned ANY address on the Host, as it is physically connected directly to my cable modem.

So I researched a bit (on this excellent site!) and, following this thread,
I added:

/etc/rc.conf
Code:
auto_linklocal="NO"
and

/boot/loader.conf
Code:
sysctl net.inet6.ip6.auto_linklocal=0
Despite those additions, as the above-quoted ifconfig report shows, the Ipv6 link-local address continues to be assigned.

So... any ideas on how to remove that assignment?

Thanks again for your help so far.
Reply With Quote
  #5  
Old August 30th, 2011, 04:41
phoenix's Avatar
phoenix phoenix is offline
Moderator
 
Join Date: Nov 2008
Location: Kamloops, BC, Canada
Posts: 3,178
Thanks: 43
Thanked 715 Times in 587 Posts
Default

Add
Code:
WITHOUT_IPV6=yes
to /etc/src.conf, recompile the world and the kernel, and you'll never see an IPv6 address again.
__________________
Freddie

Help for FreeBSD: Handbook, FAQ, man pages, mailing lists.

Last edited by DutchDaemon; August 30th, 2011 at 18:01.
Reply With Quote
  #6  
Old August 30th, 2011, 06:08
wblock@'s Avatar
wblock@ wblock@ is offline
Moderator
 
Join Date: Sep 2009
Location: Milky Way galaxy
Posts: 7,850
Thanks: 444
Thanked 1,828 Times in 1,494 Posts
Default

Quote:
Originally Posted by LSDave View Post
Thank you for your response. Following your advice I added:

/etc/rc.conf
Code:
ifconfig_re1="up"
It was an example, I was just guessing the interface name for a second card. For your system, it would be
Code:
ifconfig_rl0="up"
So it didn't really change anything, it just shows that the interface defaults to up anyway.

Quote:
I do not use IPv6 on the Host and would prefer the Realtek NIC not be assigned ANY address on the Host, as it is physically connected directly to my cable modem.
Haven't messed with IPv6 at all, but ifconfig(8) mentions the ifdisabled option to disable all IPv6 on a specific interface.

phoenix's suggestion doesn't even build IPv6, but you can also just build a kernel without it by commenting out the INET6 option.
Code:
#options        INET6
Or use "nooptions".
Code:
nooptions       INET6
Reply With Quote
  #7  
Old September 11th, 2011, 06:10
pauljames pauljames is offline
Junior Member
 
Join Date: Sep 2011
Posts: 19
Thanks: 2
Thanked 0 Times in 0 Posts
Default

You can run pf firewall and use it to redirect IP traffic bound for your VMs. Since you have two nics, you might want to use one NIC as a private subnet like 192.168.1.0 (VM IP's) and then you have your other NIC answering requests from the Internet (Routeable addresses).

So what you might have (and the NICs in this example are just that, an example) in your /etc/pf.conf is,

Code:
ext_if="em0" #outside 
int_if="em1" #inside
.
.
rdr on $ext_if inet proto tcp from any to x.x.x.x -> 192.168.1.3

or rdr pass on $ext_if inet proto tcp from any to x.x.x.x -> 192.168.1.3
x.x.x.x = the IP address you want traffic bound to your VM from the internet. The actual VM you will assign it the non routeable IP address of 192.168.1.3.

If you don't want to use a firewall then don't assign the IP address you want to give to the VM on any NIC on the FreeBSD Host. Just give it the IP to the VM.

We use both methods depending on what the requirements are.

Hope that helps you.
Reply With Quote
Reply

Tags
dedicated nic, dual-homed, virtualbox

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
FBSD Host Compiz Fusion - VirtualBox Guest Slow ter2007 GNOME 0 September 28th, 2010 23:02
[Solved] virtualbox-ose in freeBSD_7.2+ KDE_3.5 (host) gianD748 Installation and Maintenance of FreeBSD Ports or Packages 0 September 7th, 2010 16:51
Virtualbox and PAE kernel for host machine roy2098 Installation and Maintenance of FreeBSD Ports or Packages 0 August 3rd, 2010 17:24
[Solved] VirtualBox and bridged nic? xiaoj Networking 2 October 19th, 2009 21:07
FreeBSD as Host System for Sun VirtualBox quakerdoomer Installation and Maintenance of FreeBSD Ports or Packages 8 October 19th, 2009 21:06


All times are GMT +1. The time now is 04:19.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
The mark FreeBSD is a registered trademark of The FreeBSD Foundation and is used by The FreeBSD Project with the permission of The FreeBSD Foundation.
Web protection and acceleration provided by CloudFlare
0