Howdy, Stranger!

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


Shared IPv4 for VPS on Virtualizor or alternative set up
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.

Shared IPv4 for VPS on Virtualizor or alternative set up

I will be grateful if someone can explain in depth to assist me with implementing this set up.

How do I create multiple VPS using 1 IPv4?

Alternatively how can I get IPv4 at an affordable rate so I can use it to complete creating multiple VPS with minimal cost outlay compared to what is originally charged if using conventional method to set up multiple VPS?

Thanks in advance...

Comments

  • #! /bin/bash
    echo -e "Please input your server main ip"
            stty erase '^H' && read -p "(such as 8.8.8.8):" main_ip
            [[ -z "${main_ip}" ]] && echo -e "cancel..." && exit 1
    echo -e "Please input how many /24 you want to use, max is 5"
            stty erase '^H' && read -p "(such as 1):" user_ip_num
            [[ -z "${user_ip_num}" ]] && echo -e "cancel..." && exit 1
    iptables -t nat -F
    iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to ${main_ip}
    user_ip_head="10.0."
    for (( c = 1; c <= ${user_ip_num}; c++ ));do
        for (( d = 1; d <= 255; d++ ));do
            user_ip=${user_ip_head}${c}"."${d}
            if (("$d" < 10)); then
                ssh_port="6"${c}"00"${d}
                user_port_first=${c}"00"${d}"0"
                user_port_last=${c}"00"${d}"9"
            elif (("$d" < 100)); then
                ssh_port="6"${c}"0"${d}
                user_port_first=${c}"0"${d}"0"
                user_port_last=${c}"0"${d}"9"
            else
                ssh_port="6"${c}${d}
                user_port_first=${c}${d}"0"
                user_port_last=${c}${d}"9"
            fi
            iptables -t nat -A PREROUTING -i eth0 -p tcp -m tcp --dport ${ssh_port} -j DNAT --to-destination ${user_ip}:22
            iptables -t nat -A PREROUTING -i eth0 -p tcp -m tcp --dport ${user_port_first}:${user_port_last} -j DNAT --to-destination ${user_ip}
            iptables -t nat -A PREROUTING -i eth0 -p udp -m udp --dport ${user_port_first}:${user_port_last} -j DNAT --to-destination ${user_ip}    
        done
    done
    service iptables save
    service iptables restart
    echo -e "It seems done"
    

    this is an example of creating a nat forwarder
    enable your ipv4 forwarding
    then set ip 10.0.0.0/16 for your vps

  • Thank you so much @BetaRacks, advise appreciated.

Sign In or Register to comment.