Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

This quote should explain me how to do this, but I don't get it...

Next, I had added following rules to forward all http requests (coming to port 80) to the Squid server port 3128 :

iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 -j DNAT --to 192.168.1.1:3128
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3128

with

iptables -t nat -A PREROUTING -i venet0 -p tcp --dport 80 -j DNAT --to 127.0.0.1:3128
iptables -t nat -A PREROUTING -i venet0:0 -p tcp --dport 80 -j REDIRECT --to-port 3128

This should work, but it doesn't. My iptables are empty and the /etc/network/interface is the following:

auto lo
iface lo inet loopback
    address 127.0.0.1
    netmask 255.0.0.0
    broadcast 127.255.255.255
    up ip route replace 127.0.0.0/8 dev lo
# Auto generated venet0 interfaces
auto venet0
iface venet0 inet static
    address 127.0.0.1
    netmask 255.255.255.255
    broadcast 0.0.0.0
    up route add default dev venet0
iface venet0 inet6 static
    address ::2
    netmask 128
    up ip -6 r a default dev venet0
    up ip addr add {...externalIPv6...} dev venet0
auto venet0:0
iface venet0:0 inet static
    address {...externalIP...}
    netmask 255.255.255.255
share|improve this question
    
You sure the interfaces exist at all when you apply the rules? what is the output of ifconfig? –  Braiam Dec 7 '13 at 21:07
add comment

1 Answer

I'll start this as an answer, event though it is not (yet, hopefully). The reason I do this is that I believe this problem will require several iterations to be ironed out.

You iptables rules look ok to me, but your /etc/network/interfaces file has several issues, in my opinion. Did you copy it from somewhere, or did you adapt it to your needs?

The issues I see:

  1. Why specify the loopback interface? Normally, the first two lines of the stanza are ok.
  2. You are assigning two addresses to the same interface, venet0.
  3. netmask for first venet0 stanza is too restrictive, and is inconsistent with broadcast address.
  4. Your second stanza for venet0 has two addresses assigned to it, your external IPv6 address, and ::2.
  5. In the stanza for venet0, the netmask is way too restrictive.
  6. The very same interface, venet0/venet0:0, has both loopback and external addresses assigned to it, what is the point?

It would be helpful if you told us what you are trying to do with VMWare, right now I am at a loss.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.