9.12. Using the 'slirp' networking module

Slirp is a software program that emulates a PPP, SLIP, or CSLIP connection to the Internet via a shell account. The original version has been written by Danny Gasparovski in 1995. It has been integrated in QEMU to provide user mode networking. Now a port of the QEMU Slirp implementation is available in Bochs.

Features and limitations:

This example shows how to use the 'slirp' module with the NE2000 adapter. The line is very similar for the E1000 or PCI Pseudo NIC.

ne2k: mac=52:54:00:12:34:56, ethmod=slirp, ethdev=/home/volker/tests/bochs, script=""
The "ethdev" value specifies the TFTP root directory. All other options for Slirp must be set in a config file specified with "script" parameter. If no config file is set up, Bochs uses this "classic" Slirp configuration shown in the "Default" column below.

9.12.1. Advanced Slirp setup with config file

An example for a Slirp config file can be found in the Bochs sources and in binary packages (misc/slirp.conf).

Table 9-2. Slirp config file options

OptionDescriptionDefault value
restrictedif set to 1, only built-in services are available0
netbase IP address of the virtual network10.0.2.0
masknetmask of the virtual network255.255.255.0
hostIP address of the DHCP and TFTP server10.0.2.2
hostnameDHCP client hostnameundefined
dhcpstartstart address of DHCP pool10.0.2.15
dnsIP address of the virtual DNS server10.0.2.3
bootfileboot filename returned by DHCPundefined
dnssearchcomma-separated list of DNS suffixes to search (DHCP extension)undefined
smb_exportabsolute path to the shared folder (non-Windows SMB support)undefined
smb_srvalternative IP address of the SMB server10.0.2.4
hostfwdmap guest port to host port for host-to-guest access (see below for details)undefined
pktlogspecify log file to enable packet logging in text formatdisabled

9.12.2. Access to guest services from the host

With the config file option "hostfwd" you can map guest ports to ports on the host system. This is the format of the directive:

  hostfwd = protocol:hostaddr:hostport-guestaddr:guestport
The host and guest IP addresses are optional. This example shows how to access the guest SSH server using the host port 12345.
  hostfwd = tcp::12345-:22
Up to 5 port redirection rules are supported per slirp instance.