Skip to content

Instantly share code, notes, and snippets.

@dev1lsconf
Forked from tvlooy/vmm_howto.md
Created September 10, 2022 02:35
Show Gist options
  • Save dev1lsconf/5870f33ae19873c2e1d170026b4ea0e4 to your computer and use it in GitHub Desktop.
Save dev1lsconf/5870f33ae19873c2e1d170026b4ea0e4 to your computer and use it in GitHub Desktop.

Revisions

  1. @tvlooy tvlooy revised this gist Sep 21, 2017. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions vmm_howto.md
    Original file line number Diff line number Diff line change
    @@ -15,7 +15,7 @@ ntpd_flags="-s"
    inet 192.168.30.1 255.255.255.0 NONE
    ```

    /etc/dhcd.conf
    /etc/dhcpd.conf
    ```
    # Network: 192.168.11.0/255.255.255.0
    # Domain name: vmm.home.ctors.net
    @@ -96,5 +96,5 @@ vmctl console 1
    cu /dev/ttyp0
    vmctl create /vmm/vm1.img -s 500M
    vmctl start -c -k /bsd.rd -m 512M -i 1 -d /vmm/vm1.img
    vmctl start -c -b /bsd.rd -m 512M -i 1 -d /vmm/vm1.img
    ```
  2. @tvlooy tvlooy revised this gist Nov 14, 2016. 1 changed file with 8 additions and 0 deletions.
    8 changes: 8 additions & 0 deletions vmm_howto.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,7 @@
    # OpenBSD VMM howto

    ## Setup

    /etc/rc.conf.local
    ```
    apmd_flags="-A"
    @@ -83,10 +87,14 @@ vm "vm1.vm" {
    }
    ```

    ## Commands

    ```
    vmmctl status
    vmctl console 1
    cu /dev/ttyp0
    vmctl create /vmm/vm1.img -s 500M
    vmctl start -c -k /bsd.rd -m 512M -i 1 -d /vmm/vm1.img
    ```
  3. @tvlooy tvlooy revised this gist Nov 14, 2016. 2 changed files with 92 additions and 64 deletions.
    92 changes: 92 additions & 0 deletions vmm_howto.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,92 @@
    /etc/rc.conf.local
    ```
    apmd_flags="-A"
    dhcpd_flags=vether0
    vmd_flags=
    ntpd_flags="-s"
    ```

    /etc/hostname.vether0
    ```
    inet 192.168.30.1 255.255.255.0 NONE
    ```

    /etc/dhcd.conf
    ```
    # Network: 192.168.11.0/255.255.255.0
    # Domain name: vmm.home.ctors.net
    # Name servers: 192.168.11.1
    # Default router: 192.168.11.1
    # Addresses: 192.168.30.100 - 192.168.30.200
    shared-network VMM-HOME-CTORS-NET {
    subnet 192.168.30.0 netmask 255.255.255.0 {
    range 192.168.30.100 192.168.30.200;
    option subnet-mask 255.255.255.0;
    option broadcast-address 192.168.30.255;
    option routers 192.168.30.1;
    option domain-name-servers 192.168.11.1;
    filename "auto_install";
    next-server pxe.home.ctors.net;
    # host vm1 {
    # hardware ethernet 00:20:91:00:00:01;
    # fixed-address vm1.vmm.home.ctors.net;
    # }
    }
    }
    ```

    /etc/sysctl.conf
    ```
    net.inet.ip.forwarding=1
    ```

    /etc/pf.conf
    ```
    set skip on lo
    block return # block stateless traffic
    pass # establish keep-state
    # By default, do not permit remote connections to X11
    block return in on ! lo0 proto tcp to port 6000:6010
    ext_if="em0"
    int_if="{ vether0 tap0 }"
    set block-policy drop
    set loginterface egress
    match in all scrub (no-df random-id max-mss 1440)
    match out on egress inet from !(egress:network) to any nat-to (egress:0)
    pass out quick inet
    pass in on $int_if inet
    pass in on egress inet proto tcp from any to (egress) port 22
    ```

    /etc/vm.conf
    ```
    switch "local" {
    add vether0
    add tap0
    }
    vm "vm1.vm" {
    memory 512M
    kernel "/bsd.rd"
    disk "/vmm/vm1.img"
    interface {
    switch "local"
    lladdr 00:20:91:00:00:01
    }
    }
    ```

    vmmctl status

    vmctl console 1
    cu /dev/ttyp0

    vmctl create /vmm/vm1.img -s 500M
    vmctl start -c -k /bsd.rd -m 512M -i 1 -d /vmm/vm1.img
    64 changes: 0 additions & 64 deletions vmm_howto.txt
    Original file line number Diff line number Diff line change
    @@ -1,64 +0,0 @@
    /etc/rc.conf.local
    apmd_flags="-A"
    dhcpd_flags=vether0
    pkg_scripts=slim
    vmd_flags-
    ntpd_flags="-s"

    vmctl

    /etc/vm.conf

    switch "local" {
    add vether0
    add tap0
    add tap1
    add tap2
    }

    vm "OBSD-snap.vm" {
    memory 512M
    kernel "/bsd"
    disk "/home/axon/vmm/OBSD-snap.img"
    interface {
    switch "local"
    laddr 00:d3:ad:b3:3f:41
    }
    }

    vm "OBSD-RELa.vm" {
    memory 512M
    kernel "/home/axon/obsd/amd64/bsd"
    disk "/home/axon/vmm/OBSD-RELa.img"
    interface {
    switch "local"
    laddr 00:d3:ad:b3:3f:41
    }
    }


    vmmctl status

    doas vmctl console 1

    doas cu /dev/ttyp0

    doas vmctl create "testvmm.img" -s 500M

    doas vmctl start -c -k /bsd.rd -m 512M -i 1 -d testvmm.img

    doas vmctl console 4

    /etc/pf.conf
    ext_if="bge0"
    int_if="{ vether0 tap0 }"
    set block-policy drop
    set loginterface egress
    set skip on lo0
    match in all scrub (no-df random-id max-mss 1440)
    match out on egress inet from !(egress:network) to any nat-to (egress:0)
    pass out quick inet
    pass in on $int_if inet
    pass in on egress inet proto tcp from any to (egress) port 22

    enable ip forwarding
  4. @tvlooy tvlooy created this gist Nov 14, 2016.
    64 changes: 64 additions & 0 deletions vmm_howto.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,64 @@
    /etc/rc.conf.local
    apmd_flags="-A"
    dhcpd_flags=vether0
    pkg_scripts=slim
    vmd_flags-
    ntpd_flags="-s"

    vmctl

    /etc/vm.conf

    switch "local" {
    add vether0
    add tap0
    add tap1
    add tap2
    }

    vm "OBSD-snap.vm" {
    memory 512M
    kernel "/bsd"
    disk "/home/axon/vmm/OBSD-snap.img"
    interface {
    switch "local"
    laddr 00:d3:ad:b3:3f:41
    }
    }

    vm "OBSD-RELa.vm" {
    memory 512M
    kernel "/home/axon/obsd/amd64/bsd"
    disk "/home/axon/vmm/OBSD-RELa.img"
    interface {
    switch "local"
    laddr 00:d3:ad:b3:3f:41
    }
    }


    vmmctl status

    doas vmctl console 1

    doas cu /dev/ttyp0

    doas vmctl create "testvmm.img" -s 500M

    doas vmctl start -c -k /bsd.rd -m 512M -i 1 -d testvmm.img

    doas vmctl console 4

    /etc/pf.conf
    ext_if="bge0"
    int_if="{ vether0 tap0 }"
    set block-policy drop
    set loginterface egress
    set skip on lo0
    match in all scrub (no-df random-id max-mss 1440)
    match out on egress inet from !(egress:network) to any nat-to (egress:0)
    pass out quick inet
    pass in on $int_if inet
    pass in on egress inet proto tcp from any to (egress) port 22

    enable ip forwarding