Map the IP address on the VPS to the dedicated server through IPIP tunneling

Map the IP address on the VPS to the dedicated server through IPIP tunneling

Given that some service providers will launch very cheap servers, but limit the number of independent IPs that can be purchased.
However, you can purchase a lot of independent IP addresses for your own VPS at a relatively cheap price.
Here, I will introduce to you a tutorial on how to map the IP of a VPS to a dedicated server.
The VPS system used in this tutorial is Debian 7, and the system of the independent server is Ubuntu 16.04.

1. Add an IP address on the VPS :
Edit the file /etc/network/interfaces. If the network card corresponding to the default IP is eth0, add a new network card eth0:0 and add the following:

 auto eth0:0 iface eth0:0 inet static address VPS_EXTRA_IP netmask 255.255.255.255

Replace VPS_EXTRA_IP with the IP address that needs to be mapped to your dedicated server. If there are multiple IPs, add them one by one.
After saving, execute ifup eth0:0 to activate the new IP. After completion, please ping the IP address to be mapped from the independent server to see if it can be pinged.

2. Enable forwarding :
Edit the /etc/sysctl.conf file of the VPS and set;

 net.ipv4.ip_forward=1

Save and exit after editing. and make it effective.

 sysctl -p

3. Set up IPIP tunnel :
Execute on the VPS in sequence;
Note: Replace Dedicated_Servers_IP with the address of your dedicated server.

 iptunnel add shc mode ipip local VPS_EXTRA_IP remote Dedicated_Servers_IP ttl 255 ip addr add 192.168.100.1/30 dev shc ip link set shc up

Then execute on the standalone server in sequence:

 iptunnel add shc mode ipip local Dedicated_Servers_IP remote VPS_EXTRA_IP ttl 255 ip addr add 192.168.100.2/30 dev shc ip link set shc up

4. Set up routing table and mapping :
Execute on the VPS:

 iptables -t nat -A POSTROUTING -s 192.168.100.0/30 -j SNAT --to-source VPS_EXTRA_IP iptables -t nat -A PREROUTING -d VPS_EXTRA_IP -j DNAT --to-destination 192.168.100.2 iptables -A FORWARD -d 192.168.100.2 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT

Execute on a standalone server:

 echo '100 SHC' >> /etc/iproute2/rt_tables ip rule add from 192.168.100.0/30 table SHC ip route add default via 192.168.100.1 table SHC

At this point, IP mapping is set up.

via:newbug.top

<<:  FlowVPS: $3.6/month/2GB memory/15GB NVMe space/250GB traffic/KVM/Australia

>>:  NFPHosting: $15/year/1GB memory/20GB space/1.5TB traffic/KVM/Los Angeles/New York/Chicago

Recommend

GreenValueHost: $3.5/month/3 CPU/2GB RAM/100GB space/4TB/4 IP/OpenVZ

GreenValueHost has been introduced many times in ...

$10/year/2G space/50G traffic/virtual host: ShockWave Servers

ShockWave Servers is an American hosting company ...

Reliable online storage at home and abroad

I looked it up and found that it is commonly seen...

Ethernet Servers The server has been hacked, please change the password

I received an email from Ethernet Servers saying ...

Telecom Call Center: $25/month/8GB RAM/1TB hard drive/unlimited data/Romania

Telecom Call Center, a Romanian hosting provider,...

ioZoom: $7/month/1GB RAM/20GB SSD space/2TB bandwidth/KVM/Los Angeles

I/O Zoom, an American hosting provider, was estab...