Using ath0 as bridge in VMware... or almost

Well I couldn’t make my Atheros (ath0) work as a bridged network with VMware… but I made a workaround which I want to share with you guys. Anyways I’ll have it documented if I cant remember what I did later on. I have installed VMware on my Ubuntu laptop and a edgy-alternative (server) as a guest OS within VMware. The way I did this was making my laptop into a router between the “VMware host only” net and my wireless net.

You need to have configured a host only network for your VMware machines, mine is called vmnet1 and is using the network:

192.168.154.0/24

My laptop has the following ip’s:

wireless:    ath0     192.168.20.197 (provided by DHCP)
wired:       eth0     * (not used in this example)
VMware net:  vmnet1   192.168.154.1 (static)
gateway:     default  192.168.20.1

My Ubuntu edgy server has the following ip’s:

wired:       eth0     192.168.154.2 (static)

On my laptop I have made a script that does the following:

INTERNAL=vmnet1
EXTERNAL=ath0

# Enable router functionality
echo 1 > /proc/sys/net/ipv4/ip_forward

# Enabling SNAT (MASQUERADE) functionality on $EXTERNAL
iptables -t nat -A POSTROUTING -o $EXTERNAL -j MASQUERADE

All my rules are set to accept as default, if yours are not you might want to add something like this:

iptables -A FORWARD -i $EXTERNAL -o $INTERNAL -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -i $INTERNAL -o $EXTERNAL -j ACCEPT

On my VMware guest I have configured eth0 to have the static ipadress 192.168.154.2 and to use 192.168.154.1 as default gateway. The way you set this up depends on you guest OS, but you can also do this manually with:

INTERNAL=eth0

ip a add dev $INTERNAL 192.168.154.2/24
ip link set $INTERNAL up
route add default gw 192.168.154.1

Now test by pinging you host’s gateway (my laptop):

ping 192.168.20.1

Note: You propably want to set you guest OS to be able to use a DNS server.