Hello peps, this is going to be my first post here and I want to take this as opportunity to express my congrats with the FreeBSD team for maintaining this great resource.
Now back to my question. I have FreeBSD running as guest on VirtualBox and it is connected to the internet through a bridged interface with the host.
* What I want to achieve * The FreeBSD box is connected to the internet through the em0 interface on the subnet 192.168.1.0/24, and I need to share the internet connection with the Ethernet card which is em1 and on a different subnet, I'd go with 192.168.2.0/24.
* Scenario *
{ Internet > host > em0 } > { em1 > *we need internet* }
Essentially FreeBSD is sharing both the Wireless and Ethernet NIC's with the host via virtual bridged, and the host is connected to the internet through the wireless.
I have spent two days on this, and the only way I got this to work is with natd(). However I was told (and I sort of knew it) that this is not the right way to do it, and that I should simply need to set up a bridge and bridge the subnets between em0() and em1(), and was suggested to follow the bridge section from the handbook, specifically the chapter 30.6.1 http://www.freebsd.org/doc/handbook/network-bridging.html.
* Gap *
However though I can't seem to be able get it to work. When I set up the bridge between em0 and em1 with no firewall whatsoever, the FreeBSD box is no longer able to access the internet.
If I assign to the bridge0 an IP on a subnet other than 192.168.1.0/24 it will not do anything beside setting the bridge on that subnet. The interesting part is if I run
As you can see I have left em0 and em1 not configured in rc.conf, just as mentioned on the handbook: "If the bridge host needs an IP address, set it on the bridge interface, not on the member interfaces. The address can be set statically or via DHCP.".
I would appreciate any effort to strain this out once and for good..
Thanks in advantage and I do apologise for the long post.
Now back to my question. I have FreeBSD running as guest on VirtualBox and it is connected to the internet through a bridged interface with the host.
* What I want to achieve * The FreeBSD box is connected to the internet through the em0 interface on the subnet 192.168.1.0/24, and I need to share the internet connection with the Ethernet card which is em1 and on a different subnet, I'd go with 192.168.2.0/24.
* Scenario *
{ Internet > host > em0 } > { em1 > *we need internet* }
Essentially FreeBSD is sharing both the Wireless and Ethernet NIC's with the host via virtual bridged, and the host is connected to the internet through the wireless.
I have spent two days on this, and the only way I got this to work is with natd(). However I was told (and I sort of knew it) that this is not the right way to do it, and that I should simply need to set up a bridge and bridge the subnets between em0() and em1(), and was suggested to follow the bridge section from the handbook, specifically the chapter 30.6.1 http://www.freebsd.org/doc/handbook/network-bridging.html.
* Gap *
However though I can't seem to be able get it to work. When I set up the bridge between em0 and em1 with no firewall whatsoever, the FreeBSD box is no longer able to access the internet.
If I assign to the bridge0 an IP on a subnet other than 192.168.1.0/24 it will not do anything beside setting the bridge on that subnet. The interesting part is if I run
dhclient bridge0
, it will associate an IP under the 192.168.1.0/24 (which is the subnet where the host is connected to) and I will get permission denied when pinging any IP's either from within the local network or a public IP.
Code:
em0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=9b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM>
ether 08:00:27:a2:09:94
inet6 fe80::a00:27ff:fea2:994%em0 prefixlen 64 scopeid 0x1
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
media: Ethernet autoselect (1000baseT <full-duplex>)
status: active
em1: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=9b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM>
ether 08:00:27:e3:41:fa
inet6 fe80::a00:27ff:fee3:41fa%em1 prefixlen 64 scopeid 0x2
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
media: Ethernet autoselect (1000baseT <full-duplex>)
status: active
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
options=600003<RXCSUM,TXCSUM,RXCSUM_IPV6,TXCSUM_IPV6>
inet6 ::1 prefixlen 128
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3
inet 127.0.0.1 netmask 0xff000000
nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
bridge0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
ether 02:e1:41:20:a5:00
inet 192.168.1.208 netmask 0xffffff00 broadcast 192.168.1.255
nd6 options=9<PERFORMNUD,IFDISABLED>
id 00:00:00:00:00:00 priority 32768 hellotime 2 fwddelay 15
maxage 20 holdcnt 6 proto rstp maxaddr 2000 timeout 1200
root id 00:00:00:00:00:00 priority 32768 ifcost 0 port 0
member: em1 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
ifmaxaddr 0 port 2 priority 128 path cost 20000
member: em0 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
ifmaxaddr 0 port 1 priority 128 path cost 20000
Code:
default 192.168.1.1 UGS 0 9 bridge
127.0.0.1 link#3 UH 0 0 lo0
192.168.1.0/24 link#4 U 0 16 bridge
192.168.1.208 link#4 UHS 0 0 lo0
Internet6:
Destination Gateway Flags Netif Expire
::/96 ::1 UGRS lo0
::1 link#3 UH lo0
::ffff:0.0.0.0/96 ::1 UGRS lo0
fe80::/10 ::1 UGRS lo0
fe80::%em0/64 link#1 U em0
fe80::a00:27ff:fea2:994%em0 link#1 UHS lo0
fe80::%em1/64 link#2 U em1
fe80::a00:27ff:fee3:41fa%em1 link#2 UHS lo0
fe80::%lo0/64 link#3 U lo0
fe80::1%lo0 link#3 UHS lo0
ff01::%em0/32 fe80::a00:27ff:fea2:994%em0 U em0
ff01::%em1/32 fe80::a00:27ff:fee3:41fa%em1 U em1
ff01::%lo0/32 ::1 U lo0
ff02::/16 ::1 UGRS lo0
ff02::%em0/32 fe80::a00:27ff:fea2:994%em0 U em0
ff02::%em1/32 fe80::a00:27ff:fee3:41fa%em1 U em1
ff02::%lo0/32 ::1 U lo0
Code:
hostname="vboxbsd"
keymap="it.iso.kbd"
sshd_enable="YES"
ntpd_enable="YES"
# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="AUTO"
vboxguest_enable=YES
vboxservice_enable=YES
hald_enable="YES"
dbus_enable="YES"
rpcbind_enable="YES"
# enable inetd server
inetd_enable="YES"
# Enable as LAN gateway
gateway_enable="YES"
# dhcpd
dhcpd_enable="YES" # dhcpd enabled?
dhcpd_flags="-q" # command option(s)
dhcpd_conf="/usr/local/etc/dhcpd.conf" # configuration file
dhcpd_ifaces="bridge0" # ethernet interface(s)
#dhcpd_withumask="022" # file creation mask
cloned_interfaces="bridge0"
ifconfig_bridge0="addm em0 addm em1 up"
ifconfig_em0="up"
ifconfig_em1="up"
As you can see I have left em0 and em1 not configured in rc.conf, just as mentioned on the handbook: "If the bridge host needs an IP address, set it on the bridge interface, not on the member interfaces. The address can be set statically or via DHCP.".
I would appreciate any effort to strain this out once and for good..
Thanks in advantage and I do apologise for the long post.