setting up virtual box to SNAT/DNAT

Dave Cramer davec-zxk95TxsVYDyHADnj0MGvQC/G2K4zDHf at public.gmane.org
Wed Jan 13 17:15:05 UTC 2010


On Wed, Jan 13, 2010 at 11:45 AM, Madison Kelly <linux-5ZoueyuiTZhBDgjK7y7TUQ at public.gmane.org> wrote:
> Dave Cramer wrote:
>>
>> I'm trying to setup asterisk inside a virtual box vm on a host with
>> only one interface. The host is running ubuntu 6.06, and virtualbox
>> 2.2
>>
>> I can get the host to talk out, but I can't DNAT ports
>>
>> I've setup a bridge device
>>
>> # VirtualBox NAT bridge
>> auto vnet0
>> iface vnet0 inet static
>>        address 172.16.0.1
>>        netmask 255.255.255.0
>>        bridge_ports none
>>        bridge_maxwait 0
>>        bridge_fd 1
>>
>>
>> Here are the iptables rules
>>
>>  iptables -t nat -A PREROUTING -i eth0 -p tcp -m tcp --dport 10022 -j
>> DNAT --to-destination 172.16.0.113:22
>>  iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
>>  iptables -A FORWARD -i eth0 -o vnet0 -m state --state NEW -j ACCEPT
>>  iptables -A FORWARD -o eth0 -i vnet0 -m state --state NEW -j ACCEPT
>>  iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
>>
>>
>> if I telnet into port 10022 the guest sees the incoming packet on port
>> 22, but it doesn't go back properly.
>>
>> Any help would be greatly appreciated.
>>
>> Dave
>
> There is a difference:
>
>>         address 172.16.0.1
>
> and
>
>>  iptables -t nat -A PREROUTING -i eth0 -p tcp -m tcp --dport 10022 -j
>> DNAT --to-destination 172.16.0.113:22
>
> Is this intentional, or a type? I know I make enough of them. :P If not, how
> do you route traffic?
>

Figured it out, can't used bridged network in virtual box, have to use
host only interface and use their interface, then it all works
Dave
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list