Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Adding extra INTERNAL ip's on my OpenVZ container
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Adding extra INTERNAL ip's on my OpenVZ container

jeromezajeromeza Member
edited July 2014 in General

Hi guys,

I need to add several INTERNAL IP's for a virtual interface for some DNAT stuff I want to try.

How would I go about doing so?

Thanks,

Comments

  • I've tried to do the following to /etc/network/interfaces as an example, but no luck:

    auto venet0:1
    iface venet0:1 inet static
    address 192.168.1.1
    netmask 255.255.255.0

  • rmlhhdrmlhhd Member
    auto vmbr0
    iface vmbr0 inet static
            address  10.10.10.1
            netmask  255.255.255.0
            bridge_ports none
            bridge_stp off
            bridge_fd 0
    
            post-up echo 1 > /proc/sys/net/ipv4/ip_forward
            post-up   iptables -t nat -A POSTROUTING -s '10.10.10.0/24' -o eth0 -j MASQUERADE
            post-down iptables -t nat -D POSTROUTING -s '10.10.10.0/24' -o eth0 -j MASQUERADE
    

    Then assign the VZ VPS with an IP like 10.10.10.25

  • @rmlhhd - Thanks so much.

    Is that all stored in /etc/network/interfaces?

    Thanks,

  • Yes, that's all in /etc/network/interfaces.

    And if you don't know this already, you can forward services to your VMs with internal IPs too:

    iptables -t nat -A PREROUTING -i vmbr0 -p tcp -m tcp --dport 33389 -j DNAT --to-destination 10.10.10.10:3389

    A connection to the host on external.IP:33389 will be forwarded to the VM at 10.10.10.10:3389.

  • Hmmm thanks :)

Sign In or Register to comment.