I followed a tutorial and have a setup that routes all Virtualbox traffic through TOR. I use Ubuntu 10.04 as both guest and host.

Now I'd like to connect an additional physical device with a second network card and route it's traffic through the guest OS so that it is anonymous as well.

I've done some searching and can't find anything (that I can understand as a novice) that would guide me through this. I've looked at many articles that talk about setting up Linux as a router, but none seem to fit my particular needs.

My bridge interface in /etc/network/interfaces looks like this:

# VirtualBox NAT bridge
auto vnet0
iface vnet0 inet static
bridge_ports none
bridge_maxwait 0
bridge_fd 1

up iptables -t nat -I POSTROUTING -s -j MASQUERADE
down iptables -t nat -D POSTROUTING -s -j MASQUERADE

/etc/dnsmasq.conf includes this:


/etc/tor/torrc includes this:

AutomapHostsOnResolve 1
TransPort 9040
DNSPort 53

Lastly, there is a new file middlebox.sh that looks like this:


# destinations you don't want routed through Tor

# Tor's TransPort

# your internal interface

iptables -F
iptables -t nat -F

for NET in $NON_TOR; do
iptables -t nat -A PREROUTING -i $INT_IF -d $NET -j RETURN
iptables -t nat -A PREROUTING -i $INT_IF -p udp --dport 53 -j REDIRECT --to-ports 53
iptables -t nat -A PREROUTING -i $INT_IF -p tcp --syn -j REDIRECT --to-ports $TRANS_PORT

Once TOR is restarted and middlebox.sh is run, it works perfectly.

Again this is NOT my work and I'm totally unqualified to modify it to route a second NIC through the VM without screwing it up royally.

Right now the HM shows it's connected to eth1 and the VM shows eth0.
I haven't yet physically installed the 2nd NIC, but presumably it will be eth2.