-# Create NUMTAPINTERFACES tap interfaces on the host, and prepare UML command
-# line params to use them. The interfaces are called <user>TAP0, <user>TAP1,
-# ..., on the host, and eth0, eth1, ..., in the VM.
-user=${USER:0:10}
-tapinterfaces=
-netconfig=
-for id in $(seq 0 $(( NUMTAPINTERFACES - 1 )) ); do
- tap=${user}TAP$id
- tapinterfaces="$tapinterfaces $tap"
- mac=$(printf fe:fd:00:00:00:%02x $id)
- netconfig="$netconfig eth$id=tuntap,$tap,$mac"
-done
-
-for tap in $tapinterfaces; do
- if ! ip link list $tap > /dev/null; then
- echo "Creating tap interface $tap" >&2
- sudo tunctl -u $USER -t $tap
- sudo ip link set $tap up
- fi
-done
+# If network access was requested, create NUMTAPINTERFACES tap interfaces on
+# the host, and prepare UML command line params to use them. The interfaces are
+# called <user>TAP0, <user>TAP1, on the host, and eth0, eth1, ..., in the VM.
+if (( $NUMTAPINTERFACES > 0 )); then
+ user=${USER:0:10}
+ tapinterfaces=
+ netconfig=
+ for id in $(seq 0 $(( NUMTAPINTERFACES - 1 )) ); do
+ tap=${user}TAP$id
+ tapinterfaces="$tapinterfaces $tap"
+ mac=$(printf fe:fd:00:00:00:%02x $id)
+ netconfig="$netconfig eth$id=tuntap,$tap,$mac"
+ done
+
+ for tap in $tapinterfaces; do
+ if ! ip link list $tap > /dev/null; then
+ echo "Creating tap interface $tap" >&2
+ sudo tunctl -u $USER -t $tap
+ sudo ip link set $tap up
+ fi
+ done
+fi