[Simh] Using TAP/TUN
Michael Bloom
mabloom at dslextreme.com
Sun Mar 4 23:17:34 EST 2012
Here's a relatively simple shell script I cobbled together to automate
setting up TAP/TUN on Linux:
---------- CUT HERE ------------
#! /bin/sh
USERNAME=mab
ETH_IF=wlan3
TUNNEL_IF=tap0
NET_BITS=24
SUB=0
LAN_NET=192.168.$SUB
TUNNEL_NET=192.168.$SUB
# Addresses for both sides of the tunnel
SIMH_HOST=$TUNNEL_NET.253
TUNNEL_GATE=$TUNNEL_NET.254
#################### END OF STUFF YOU CAN EDIT
# If tunnel doesn't exist, create it.
ifconfig $TUNNEL_IF > /dev/null 2>&1 || tunctl -u $USERNAME
ifconfig $TUNNEL_IF $TUNNEL_GATE up
if [ x$LAN_NET = x$TUNNEL_NET ]
then
# The above ifconfig of tap0 created a default route through our
tunnel,
# superceding the default route via $ETH_IF to our router. Remove it.
route delete -net $TUNNEL_NET/$NET_BITS gw 0.0.0.0 dev $TUNNEL_IF
else
echo Your router probably has at least a default route going to the
internet,
echo and a route for your lan. If your tunnel and lan are on
different nets,
echo you should make sure the router knows to try to send packets
intended
echo for $TUNNEL_NET through $LAN_NET. Linux is supposed to
automagically
echo proxy arp for a whole subnet when forwarding, but there must
echo still be a route to this host from your router for $TUNNEL_NET.
fi
echo 1 > /proc/sys/net/ipv4/conf/$TUNNEL_IF/proxy_arp
# create a route to SIMH's system host through our tunnel
route add -host $SIMH_HOST dev $TUNNEL_IF
# prepare to answer arps for the simulated machine
arp -Ds $SIMH_HOST $ETH_IF pub
exit 0
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.trailing-edge.com/pipermail/simh/attachments/20120304/7dcf6635/attachment-0002.html>
More information about the Simh
mailing list