netkit-jh / netkit-jh-build

Build scripts for the kernel, filesystem and assisting scripts/programs for Netkit-JH.
https://netkit-jh.github.io/
GNU General Public License v3.0
22 stars 12 forks source link

Slirp Networking Support #32

Closed b177y closed 3 years ago

b177y commented 3 years ago

Is your feature request related to a problem? Please describe. Currently we are limited to one tap device, and although thats being worked on it still has the issue of requiring root privileges to run, so it would be good to implement a network interface that can reach the internet without root privs.

Describe the solution you'd like Slirp is an option for uml networking, which like most uml stuff has been mostly abandoned and unmaintained - however it would be useful for giving access to internet / the host's networks.

This shows a demonstration of uml with slirp networking, using a patched slirp binary from here

It is probably worth researching elsewhere for more up to date slirp source code, which we could then compile ourselves like with the uml_tools

Additional context Slirp runs at the ip level so would not be useful for showing any physical layer stuff in netkit, but most likely you will be using it as a way of getting resources from the internet / giving your host access to the machine, so low level networking is likely not required.

b177y commented 3 years ago

I've looked further into slirp and realised its an awful idea :)

I was aware that the original release was from 1996, but I thought more patches would be available. I wasn't able to compile the code (with patches) on arch (maybe theres some patches i didnt see) but I found that a somewhat maintained version is available on ubuntu in the default repos. I tested that out and booted a machine with slirp:

$ sudo apt install slirp
$ ./netkit-kernel name=a title=a umid=a mem=132M ubd0=/home/csc/a.disk,/home/csc/netkit-jh/fs/netkit-fs root=98:0 uml_dir=/home/csc/.netkit/mconsole hosthome=/home/csc con0=fd:0,fd:1 con1=null SELINUX_INIT=0 quiet eth0=slirp,,/usr/bin/slirp

Then on the uml vm (these are the networking settings that slirp uses by default:

root@a:~# ifconfig eth0 10.0.2.14 netmask 255.255.255.240 10.0.2.15
root@a:~# route add default gw 10.0.2.2

I was then able to ping 10.0.2.2 but nothing else. I wasnt able to connect with netcat from the vm to the host (nc -lvp 1337 on host and nc 10.0.2.2 1337 on the netkit machine)

I'm sure there's something I'm missing which would fix this, but while researching further I found that slirp is now a legacy method of uml networking - here are some links which cover this:

I have therefore decided that it's not worth looking into this any further, and am now closing this issue.