| 357 | Otherwise, this feature is pretty handy for quickly adding a IP interface to an interface for, say (as a silly example), creating a carted-off piece of network for a host you don't want to put on the main network, but you still need to access. |
| 358 | |
| 359 | == FreeBSD , mininet, and `qemu/kvm`.== |
| 360 | |
| 361 | [http://mininet.org Mininet] is an SDN prototyping platform/data plane emulator. It uses Linux network namespaces, so it can only be natively installed on Linux. However, they provide a pre-installed VM that can be run with some virtualization. `qemu` is one such platform that can be used to run this VM. We need to diverge a bit from the Mininet page tutorials to get this working on FreeBSD. |
| 362 | |
| 363 | Note,we do need a machine that meets the prereqs for running `qemu` for this to work. |
| 364 | |
| 365 | === references === |
| 366 | * https://wiki.freebsd.org/qemu - basic configs/setup |
| 367 | * http://www.cyberciti.biz/faq/howto-configure-freebsd-vlans-with-ifconfig-command/ - figuring out some of the configs in the link above do |
| 368 | * http://mininet.org/vm-setup-notes/ - starting the mininet VM |
| 369 | |
| 370 | === the steps. === |
| 371 | Installation. [[BR]] |
| 372 | Repeating the steps on the first link above: |
| 373 | |
| 374 | 1. Install `qemu` and `kqemu-kmod`. The first is qemu itself. the latter is the accelerator. |
| 375 | 2. Add to /boot/loader.conf: |
| 376 | {{{ |
| 377 | if_bridge_load="YES" |
| 378 | if_tap_load="YES" |
| 379 | aio_load="YES" |
| 380 | kqemu_load="YES" |
| 381 | }}} |
| 382 | 3. add `kqemu_enable="YES"` to /etc/rc.conf so `aio` and `kqemu` are loaded at startup (optional). |
| 383 | 4. force re-reading of configs by rebooting or dropping to single-user mode and returning. |
| 384 | |
| 385 | Network configuration. [[BR]] |
| 386 | We need to configure network settings so the VM can communicate with the outside world. |
| 387 | |
| 388 | 1. add/set sysctl's in /etc/sysctl.conf : |
| 389 | {{{ |
| 390 | echo net.link.tap.user_open=1 >> /etc/sysctl.conf |
| 391 | echo net.link.tap.up_on_open=1 >> /etc/sysctl.conf |
| 392 | }}} |
| 393 | 2. force read by service restart: `/etc/rc.d/sysctl start` |
| 394 | 3. create/bridge interfaces: |
| 395 | {{{ |
| 396 | ifconfig bridge0 create |
| 397 | ifconfig tap0 create |
| 398 | ifconfig bridge0 addm $iface addm tap0 up |
| 399 | chmod 0660 /dev/tap0 |
| 400 | }}} |
| 401 | where $iface is your main networked interface. |
| 402 | |
| 403 | Convert/run Mininet VM. [[BR]] |
| 404 | |
| 405 | 1. Acquire VM from mininet site. |
| 406 | 2. convert .vmdk to .qcow2" |
| 407 | {{{ |
| 408 | qemu-img convert -O qcow2 mininet-vm-disk1.vmdk mininet-vm-disk1.qcow2 |
| 409 | }}} |
| 410 | 3. start VM (we don't use an ifup/ifdown script here): |
| 411 | {{{ |
| 412 | qemu -m 1024 mininet-vm-disk1.qcow2 -net nic,model=virtio -net tap,name=tap0,script=no |
| 413 | }}} |
| 414 | |
| 415 | Configure guest. [[BR]] |
| 416 | |
| 417 | 1. To the guest's eth0, assign an address in the same IP block as your host's interface bound to tap0. For example, if tap0 is bound to fxp0 with address 192.168.1.100/24, assign something like 192.168.1.200. |
| 418 | 2. set default gateway. If my host's gateway is 192.168.1.1: |
| 419 | {{{ |
| 420 | sudo route add default gw 192.168.1.1 |
| 421 | }}} |
| 422 | 3. fix /etc/resolv.conf to match your network's DNS settings. |
| 423 | |
| 424 | You should be able to reach the VM from the network now/vice versa. |