Simultaneous Internet Access with MirageOS kernels on Solo5

Hi,

I have written a MirageOS kernel which will make an HTTP GET request.
I want to be able to run multiple instances of these simultaneously on Solo5 but am having difficulties setting up the network, I have tried setting up multiple tap devices but this has not worked for me.

Thanks

Hello again,

to run multiple unikernels, you have to setup a tap interface for each of them. And then, instead of configuring IP addresses on each tap device on the host system, I recommend to use a bridge interface (a virtual switch - see https://www.tldp.org/HOWTO/BRIDGE-STP-HOWTO/set-up-the-bridge.html):

  1. Create a bridge with brctl add mybridge
  2. Configure an IP address on the bridge ip addr add 10.0.0.1/24 dev mybridge ; ip link set dev mybridge up
  3. Create your tap interfaces [tap100; tap101] (here, only the two steps ip tuntap add tap100 mode tap ; ip link set dev tap100 up are necessary – no need to configure an IP address on it)
  4. For each tap interface, add it to the bridge: brctl addif mybridge tapN
  5. Boot your unikernels, assigning a custom IP each: `solo5-hvt --net:service=tap100 – my_unikernel.hvt --ipv4=10.0.0.2/24 --ipv4-gateway=10.0.0.1
  6. Boot your next unikernel solo5-hvt --net:service=tap102 -- my_other_unikernel.hvt --ipv4=10.0.0.3/24 --ipv4-gateway=10.0.0.1

Don’t forget the (adjusted tap100 -> mybridge) firewall/NAT setup (from https://github.com/mirage/mirage-skeleton/issues/287):

If you’re using linux and iptables, this guide may be helpful (copy & pasted the instructions from there):

$ echo 1 > /proc/sys/net/ipv4/ip_forward # enables IP forwarding

# assuming "eth0" is your default network interface where all the traffic goes to the Internet.
$ /sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
$ /sbin/iptables -A FORWARD -i eth0 -o mybridge -m state --state RELATED,ESTABLISHED -j ACCEPT
$ /sbin/iptables -A FORWARD -i mybridge -o eth0 -j ACCEPT
1 Like

This has sorted it out, I can’t thank you enough!

1 Like