I'm trying to make a rumpkernel (https://github.com/rumpkernel) run on KVM, connect to a socket on the host and send some data.
I am able to make the host access the guest using the nginx example here: https://github.com/rumpkernel/wiki/wiki/Tutorial%3A-Serve-a-static-website-as-a-Unikernel
Pretty much what I do is:
ip tuntap add tap0 mode tap
ip addr add 10.0.0.10/24 dev tap0
ip link set dev tap0 up
Then launch rumprun with the parameters:
rumprun kvm -i -M 128 \
-I if,vioif,'-net tap,script=no,ifname=tap0'\
-W if,inet,static,10.0.0.11/24 \
-b images/data.iso,/data \
-- <my python script>
Where the python script opens a socket (0.0.0.0:2010) and listens. Then on the host I can do:
nc 10.0.0.11 2010
And I can see it connecting. The problem is that I can't do the other way around. Now I have the kvm guest opening a socket and trying to connect:
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
ip = "10.0.0.10"
try:
s.connect( (ip, 9999) )
#send some data
And running the same script that does listen as before, binding on 10.0.0.10:9999. The guest just gets stuck on trying to connect and eventually times out.
I tried almost everything I could find online, ended up with a bridge with IP 10.0.0.10 and adding tap0 to it. Then I snooped br0 and got the following (removed some lines):
15:38:46.173914 ARP, Request who-has 10.0.0.11 tell 10.0.0.11, length 28
...
15:38:46.500262 ARP, Request who-has 10.0.0.10 tell 10.0.0.11, length 28
15:38:46.500288 ARP, Reply 10.0.0.10 is-at 0e:ec:XX:XX:XX:XX (oui Unknown), length 28
15:38:46.500440 IP 10.0.0.11.52886 > 10.0.0.10.9999: Flags [S], seq 20858086, win 32768, options [mss 1460,nop,wscale 3,sackOK,nop,nop,nop,nop,TS val 1 ecr 0], length 0
Which makes me think there is a route, but somehow the packet doesn't reach. I've tried disabling filtering within sys.d
net.bridge.bridge-nf-call-ip6tables = 0
net.bridge.bridge-nf-call-iptables = 0
net.bridge.bridge-nf-call-arptables = 0
And still nothing.
Any ideas on how to make this works? I don't want to bridge my eth0 because it's a remote server and the guest doesn't need outside connections at this moment.