https://github.com/mirage/qubes-mirage-firewall/releases/tag/v0.5
This is a unikernel that can run as a QubesOS ProxyVM, replacing sys-firewall. It may be useful if you want something smaller or faster-to-start than the Linux-based sys-firewall. It requires around 32MB of RAM when running and requires 0.0s of CPU time to boot, according to "xl list". It does not need or use a hard-disk, and does not persist any state between reboots.
For installation instructions, see:
https://github.com/mirage/qubes-mirage-firewall/blob/master/README.md
For a blog post explaining the background for this, with a walk-through of the code (it's written in OCaml), see:
http://roscidus.com/blog/blog/2016/01/01/a-unikernel-firewall-for-qubesos/
Changes since 0.4:
- Update to the latest mirage-net-xen, mirage-nat and tcpip libraries (@yomimono, @talex5, #45, #47). In iperf benchmarks between a client VM and sys-net, this more than doubled the reported bandwidth!
- Don't wait for the Qubes GUI daemon to connect before attaching client VMs (@talex5, #38). If the firewall is restarted while AppVMs are connected, qubesd tries to reconnect them before starting the GUI agent. However, the firewall was waiting for the GUI agent to connect before handling the connections. This led to a 10s delay on restart for each client VM. Reported by @xaki23.
- Add stub makefile for qubes-builder (@xaki23, #37).
- Update build instructions for latest Fedora (@talex5, #36). yum no longer exists. Also, show how to create a symlink for /var/lib/docker on build VMs that aren't standalone. Reported by @xaki23.
- Add installation instructions for Qubes 4 (@yomimono, @reynir, @talex5, #27).
- Use Ethernet_wire.sizeof_ethernet instead of a magic 14 (@hannesm, #46).
Note that the repository has moved from github.com/talex5 to the github.com/mirage organisation, as it's no longer just my personal project.
Q: The build-with-docker script hard-codes /home/opam. What if your user has a different name?
The Docker build creates a virtual environment based on the `ocaml/opam2:debian-9-ocaml-4.07` image (template). In this image, the user is always called "opam".
Using Docker means that every build is exactly the same, regardless of whether you're using Fedora or Debian as the OS for your Qube. The build script contains the hash of the expected image, so you can be sure the unikernel you built is byte-for-byte identical with the one we built.
It also means that you don't have to install any special tools (except Docker itself). The build is isolated from your own files, except that it shares the `_build` directory, which is where you will find the output files.
Q: Can I build on Debian without using Docker?
Yes. I got it working with this:
sudo apt-get update
sudo apt-get install rsync pkg-config git gcc make m4 patch unzip bubblewrap curl 0install-core
0install add opam http://tools.ocaml.org/opam.xml
opam init --compiler=4.07.1 --disable-sandboxing
eval $(opam env)
opam install mirage
mirage configure -t xen && make depend && make tar
Trying to keep these instructions up-to-date wastes a lot of volunteer time however, so I would much prefer people to use the Dockerfile if they have any problems building with their own OS.
Q: Why does installing opam without Docker want to modify my .profile?
So it can make commands such as `ocaml` point to the ones that it has installed in your home directory. If you're worried about what opam is doing to your system, I suggest using the build-with-docker script to sandbox everything.
Q: Do I need some standalone system that docker can 'mess up' and that I delete after build?
Feel free to create a `firewall-builder` VM for this if you don't trust Docker to sandbox things correctly in your existing qubes.
Q: You have binaries on the github site, but neither checksums nor signatures
There is a checksum in the build-with-docker file which should match the binary. In the case of the 0.5 release, you should see:
$ sha256sum vmlinuz
1f72adad30cbd4f8315983240bd150811084cb93d360c14740fadb36394c7aa8 vmlinuz
Perhaps future releases will come with signatures.
Q: Where can I ask questions about this?
- You can reply to this thread, where I will see it along with other Qubes users (I know several people here are using it; see previous discussions).
- You can file issues at https://github.com/mirage/qubes-mirage-firewall/issues
- You can ask on the Mirage mailing list - see https://mirage.io/community/
- To report a security bug, see https://mirage.io/security
Did you use Docker to build it in your standalone qube? It should match if so. If not, it's unlikely to match because you're probably building against different library versions.
> I stored the output of find . -type f -exec sha256sum \{} \; of the
> qubes-mirage-firewall folder in this file
>
> https://framabin.org/p/?d9b2b5de724e5c2a#20uFbk/hVlaZnMqHYQ/DXjv9Lav3+Y8Fw7rU05k1IhY=
>
> to avoid sending 260 lines here. If someone has recently build the
> version 0.5, could you run a diff on that to see what happened ? Cheers,
> Bernhard
If you want to check that building without Docker gives exactly the same result as building with it (which might not be too easy...) you'll need to make sure that every installed OCaml library has the same version at least.
I'd suggest copying the firewall directory and building the copy with Docker (be sure to delete the copied _build directory first). Then you can compare between the two on your own computer.
For example, running "opam list" will show you the local (non-Docker) versions chosen.
To enter the Docker virtual build environment (after building), do:
$ docker run --rm -it --entrypoint bash qubes-mirage-firewall
That will get you a bash prompt, and you can run "opam list" there to see which versions the Docker build is using, and compare.
Note that any changes you make within the Docker build environment will be lost when you exit the shell.
To make sure it always uses the same version, the Docker image contains a Git clone of the opam repository, which it pins (in Dockerfile) to a particular commit. That means that the build-with-docker script will always build against the versions available at that fixed point in time, not the latest ones.
You might also find that Debian packages affect it (e.g. make sure you have the same version of gcc, as there are a few C source files used too).
If you need to get things in or out of the Docker environment, you can use -v to share a directory. e.g.
$ docker run --rm -it -v $(pwd):/mnt --entrypoint bash qubes-mirage-firewall
will share the current directory with Docker, mounted at `/mnt` in the virtual environment.
You might also be interested in the console output from the Travis CI build (this also lists the versions used):
https://travis-ci.org/mirage/qubes-mirage-firewall/builds/515629873
Hope that helps.
I'd like to announce the release of qubes-mirage-firewall 0.5:
https://github.com/mirage/qubes-mirage-firewall/releases/tag/v0.5
(...)
For installation instructions, see:
https://github.com/mirage/qubes-mirage-firewall/blob/master/README.md,
build-with-docker.sh
script:
sudo ln -s /var/lib/docker /home/user/docker
sudo dnf install docker
sudo systemctl start docker
git clone https://github.com/mirage/qubes-mirage-firewall.git
cd qubes-mirage-firewall
sudo ./build-with-docker.sh
[...]
- O
(...) So: I did it, actually
three times, more and more frustrated.
Run from any recent fedora-based AppVM (standalone or not).
I've proposed some extra text suggesting users should "Create a new Fedora-29 AppVM (or reuse an existing one)":
https://github.com/mirage/qubes-mirage-firewall/pull/51
Does that help?
I believe that the Qubes sys-firewall by default prevents template VMs from connecting to anything except their package repositories. It's OK to install Docker in a template VM if you want, but everything else should be done in an AppVM.
I've added more details at https://github.com/mirage/qubes-mirage-firewall/pull/51/files
I tested this with Debian 9, but I assume it would work the same on Debian 10.
By the way, while testing it I found one case where the hash can change even with Docker, and proposed a fix for that at https://github.com/mirage/qubes-mirage-firewall/pull/52
`_build` is your _build directory, which is mounted into the chroot by the -v option. You can go into the environment yourself and try making it manually to find out what the problem is:
$ docker run --rm -it --entrypoint bash -v $(pwd):/home/opam/qubes-mirage-firewall qubes-mirage-firewall
opam@aaa050f3779c:~/qubes-mirage-firewall$ mkdir _build
The Docker build user has UID 1000, which should be the same as the default qubes user (use "id" inside and outside of the build environment to see).
To test that PR:
git pull origin pull/52/head
rm -rf _build
sudo ./build-with-docker.sh
(...)
This is what I do:
(...)
MirageTemplateVM=
t-fedora-29-mirage
# create a new template VM qvm-clone fedora-29-minimal $MirageTemplateVM
# Resize private disk to 10 GB qvm-volume extend$
:private 10GB # Create a symbolic link to safe docker into the home directory qvm-run --auto --user root --pass-io --no-guiMirageTemplateVM
$
\ 'ln -s /var/lib/docker /home/user/docker' # Install docker and git qvm-run --user root --pass-io --no-guiMirageTemplateVM
$
\ 'dnf -y install docker git' # To get networking in the template VM qvm-run --auto --user root --pass-io --no-guiMirageTemplateVM
$
\ 'dnf install qubes-core-agent-networking' qvm-shutdown --waitMirageTemplateVM
$
qvm-prefsMirageTemplateVM
$
sys-firewall qvm-startMirageTemplateVM
$
# Launch docker qvm-run --user root --pass-io --no-guiMirageTemplateVM
$
\ 'systemctl start docker' # Download and build mirage for qubes qvm-run --user root --pass-io --no-guiMirageTemplateVM
$
\ 'cd /home/user && \ git clone https://github.com/mirage/qubes-mirage-firewall.git && \' cd qubes-mirage-firewall && \ ./build-with-docker.sh'MirageTemplateVM
--- --- 8< --- --- --- ---
Unfortunately I run into an error during the build process:
[...]
Building Firewall...
error while executing ocamlbuild -use-ocamlfind -classic-display -tags
bin_annot -quiet -Xs _build-solo5-hvt,_build-ukvm
-pkgs mirage config.cmxs
+ mkdir /home/opam/qubes-mirage-firewall/_build
mkdir: cannot create directory '/home/opam/qubes-mirage-firewall/_build': Permission denied
Command exited with code 1.
Failure:
Error during command "mkdir /home/opam/qubes-mirage-firewall/_build": Ocamlbuild_pack.My_std.Exit_with_code(10)
Maybe because there is no folder /home/opam/... ??
I have also integrated pull request 52 via:
qvm-run --user root --pass-io --no-gui
'git pull origin pull/52/head && \$
\MirageTemplateVM
rm -rf _build && \
sudo ./build-with-docker.sh'
And I have manually created the missing folder above via
qvm-run --user root --pass-io --no-gui
'$
\MirageTemplateVM
mkdir /home/opam/qubes-mirage-firewall/'
Even then I still run into the same error.
Any ideas what I am missing?
- O
On Monday, April 8, 2019 11:40 PM, 799 <one7...@gmail.com> wrote:
> Any ideas what I am missing?
I don't know. I just did a build using fedora (based on unmodified Qubes fedora-29 template) and got no error, final checksum checks out. This is what I did:
(...)
> I don't understand why you want to do all that in a TemplateVM,
> and not an AppVM.
> Also why fight with Fedora, if my simple Debian based build gives the
> same binary as the official (equal checksum) [...]
you are right that using a full fedora-29 would not do any harm, therefore I have used this template and luckily everything was very easy to setup.
Thanks for the support!
I have compiled all info which I need to setup Mirage-FW in a short howto, which might also be helpfull to others in a way that all steps can be run from dom0 which is much easier and which can be scripted (for example to rebuild your Qubes Setup from a default installation):
@Mirage Firewall-Team:
I think creating a document/script which does the build process for the user, will improve end user experience setting up mirage.
----- 8< ----- ----- ----- -----
MirageFW-BuildVM=my-mirage-buildvm
TemplateVM=fedora-29
MirageFWAppVM=sys-mirage-fw
# create a new VM to build mirage via docker
qvm-create $MirageFW-BuildVM --class=AppVM --label=red --template=$TemplateVM
# Resize private disk to 10 GB
qvm-volume resize $MirageFW-BuildVM:private 10GB
# Create a symbolic link to safe docker into the home directory
qvm-run --auto --pass-io --no-gui $MirageFW-BuildVM \
'sudo mkdir /home/user/var_lib_docker && \
sudo ln -s /var/lib/docker /home/user/var_lib_docker'
# Install docker and git
qvm-run --pass-io --no-gui $MirageFW-BuildVM \
'sudo dnf -y install docker git'
# Launch docker
qvm-run --pass-io --no-gui $MirageFW-BuildVM \
'sudo systemctl start docker'
# Download and build mirage for qubes
qvm-run --pass-io --no-gui $MirageFW-BuildVM \
'git clone https://github.com/mirage/qubes-mirage-firewall.git && \
cd qubes-mirage-firewall && \
git pull origin pull/52/head && \
sudo ./build-with-docker.sh'
# Copy the new kernel to dom0
cd /var/lib/qubes/vm-kernels
qvm-run --pass-io $MirageFW-BuildVM 'cat qubes-mirage-firewall/mirage-firewall.tar.bz2' | tar xjf -
# create the new mirage firewall
qvm-create \
--property kernel=mirage-firewall \
--property kernelopts=None \
--property memory=32 \
--property maxmem=32 \
--property netvm=sys-net \
--property provides_network=True \
--property vcpus=1 \
--property virt_mode=pv \
--label=green \
--class StandaloneVM \
$MirageFWAppVM
# The build VM could be deleted if you don't want to keep it
# but if you want to upgrade Mirage Firewall for Qubes OS,
# you need to rebuild this VM.
qvm-shutdown --wait $MirageFW-BuildVM
qvm-remove --force $MirageFW-BuildVM
----- 8< ----- ----- ----- -----
Link: https://github.com/Qubes-Community/Contents/blob/master/docs/customization/mirage-firewall.md
Now the next steps are to learn, how to tweak the firewall to allow specific communication between AppVMs, for example ssh/http.
Thanks to all for the help/suggestions.
- O
See: https://lists.xenproject.org/archives/html/mirageos-devel/2019-04/msg00019.html
The build script uses download.camlcity.org which appears to be chronically down.
Any consideration for replacements?
B
It's up for me. What error are you seeing?
On Tuesday, April 23, 2019 at 5:02:36 PM UTC+1, brend...@gmail.com wrote:
> The build script uses download.camlcity.org which appears to be chronically down.Any consideration for replacements?
It's up for me. What error are you seeing?