English
Deutsch
  

Code


About Matthias Nott
Business Objects
Picture Galleries
Code
Technical
Download





Locations of visitors to this page

I tried to figure out how to start VMWare on Linux so that the guest OS has transparent network access using NAT. Here is a way:

  1. #!/bin/bash
  2. #
  3. # This scripts sets the forwarding rules for VMWare
  4. #
  5. # We assume that we have VMWare set up with NAT and
  6. # have given the following IP addresses:
  7. #
  8. # Physical Network Adapter: PN=192.168.1.xxx
  9. # VMWare   Network Adapter: VN=192.168.2.xxx
  10. #
  11. # We do not know exactly which Interface and which
  12. # IP address we have for the physical network - so
  13. # we have to find these out first among eth0, eth1
  14. #
  15.  
  16. PN=192.168.1
  17. VN=192.168.2
  18.  
  19. IP=`ifconfig | grep -e "inet.\+:$PN.[^d]*\S" | sed "s/.*\($PN.*\?\) Bcast.*/\1/1"`
  20. IF=`for i in eth0 eth1 ; do ifconfig $i | grep $IP >/dev/null && echo $i ; done`
  21.  
  22. sudo /sbin/iptables --flush
  23. sudo /sbin/iptables -t nat --flush
  24. sudo /sbin/iptables -t nat -P PREROUTING ACCEPT
  25. sudo /sbin/iptables -t nat -P POSTROUTING ACCEPT
  26. sudo /sbin/iptables -P FORWARD ACCEPT
  27. sudo /sbin/iptables -P OUTPUT ACCEPT
  28. sudo /sbin/iptables -P INPUT ACCEPT
  29. sudo /sbin/iptables -t nat -A POSTROUTING -s $VN.0/24 -o $IF -j SNAT --to $IP
  30. echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward >/dev/null
  31.  
  32. /usr/bin/vmware
 


26.03.2007, 11:42 Copyright © 2005 MN Soft Industry Software, 108, route de la Fin, CH-1874 Champéry
Tel.: +41 797 844554; Fax: +41 860 797 844554, Responsible: Matthias Nott., mn(at)mnsoft.org
Top of Page