#!/bin/bash # # uml-net - a script to set up a UML's network # Copyright (C) 2005 Frank Sorenson (frank@tuxrocks.com) # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. UMID=uml1 MAC_ADDRESS='FE:FD:AB:CD:EF:02' ARP_UML_IP=10.0.0.14 MASK=255.255.255.0 BCAST=10.0.0.255 ### export HOST_IF=`route -n |egrep "^0\.0\.0\.0"|cut -c 73-` export HOST_IP=`ifconfig ${HOST_IF} | grep "inet addr:" | cut -f 2 -d ":"|cut -f 1 -d " "` modprobe tun chmod 666 /dev/net/tun tunctl -d ${UMID} tunctl -t ${UMID} ifconfig ${UMID} ${HOST_IP} broadcast ${BCAST} netmask ${MASK} up echo 1 > /proc/sys/net/ipv4/ip_forward route add -host ${ARP_UML_IP} dev ${UMID} echo 1 > /proc/sys/net/ipv4/conf/${UMID}/proxy_arp arp -Ds ${ARP_UML_IP} ${HOST_IF} pub export NET_SETUP="eth0=tuntap,${UMID},${MAC_ADDRESS}" echo "Add ${NET_SETUP} to the UML command line"