Personal Proxy IPv6 Input and IPv4 Output

Here's how to make a personal proxy server which takes input on IPv6 and outputs it to the IPv4 web. For the proxy software we're going to use V2Ray, and for the IPv6 to IPv4 conversion we'll use socat. Our server here runs Ubuntu 20.04. We are logged in as root. Before the tutorial starts, we've already created a DNS record type AAAA pointing from the server name (vps.example.com) to the server's IPv6 address.

So let's get going. Install V2Ray using the official install script:

apt update && apt upgrade -y

apt install curl -y

curl -Ls https://install.direct/go.sh | bash

Toward the end of its run, the script displays a port and a UUID, which will look like this:

PORT:33423
UUID:dbc9eb16-3d9c-4276-b77e-c0ce50b33bd3

Of course, these are just examples.

To configure V2Ray, edit the configuration file /etc/v2ray/config.json. Make V2Ray listen only on IPv4 localhost:

    "listen": "127.0.0.1",

Also add logging if you wish:

  "log": {
    "loglevel": "warning",
    "access": "/var/log/v2ray/access.log",
    "error": "/var/log/v2ray/error.log"
  },

The completed V2Ray configuration file, with everything in place, looks like this:

{
  "log": {
    "loglevel": "warning",
    "access": "/var/log/v2ray/access.log",
    "error": "/var/log/v2ray/error.log"
  },
  "inbounds": [{
    "listen": "127.0.0.1",
    "port": 33423,
    "protocol": "vmess",
    "settings": {
      "clients": [
        {
          "id": "dbc9eb16-3d9c-4276-b77e-c0ce50b33bd3",
          "level": 1,
          "alterId": 64
        }
      ]
    }
  }],
  "outbounds": [{
    "protocol": "freedom",
    "settings": {}
  },{
    "protocol": "blackhole",
    "settings": {},
    "tag": "blocked"
  }],
  "routing": {
    "rules": [
      {
        "type": "field",
        "ip": ["geoip:private"],
        "outboundTag": "blocked"
      }
    ]
  }
}

Your configuration file will have your own port and id in place of the sample values given above. Start the V2Ray service with your new configuration:

systemctl start v2ray

To convert from IPv6 to IPv4 we'll use socat. Install socat from the Ubuntu repositories:

apt install socat -y

Create a systemd service file for the conversion of IPv6 to IPv4. In our example, the generated port number was 33423. Name the service file /lib/systemd/system/socat33423.service. Insert the following contents to send TCP IPv6 input on port 33423 to localhost IPv4 port 33423.

[Unit]
Description=Convert IPv6 to IPv4 for TCP/33423

[Service]
User=root
ExecStart=/usr/bin/socat TCP6-LISTEN:33423,reuseaddr,fork TCP4:127.0.0.1:33423

[Install]
WantedBy=multi-user.target

After you've saved the file, start the new service you just created.

systemctl enable socat33423

systemctl start socat33423

Now for the V2Ray client. We'll use Android as an example, although there are V2Ray clients for many other platforms. Install the V2RayNG app by Captain Iron (2dust on Github). Add a profile that matches your server:

  • Remarks = vps.example.com
  • Host = vps.example.com
  • Port = 33423 (from the V2Ray install script)
  • Id = dbc9eb16-3d9c-4276-b77e-c0ce50b33bd3 (from the V2Ray install script)
  • AlterId = 64 (from the V2Ray install script)
  • Security = auto
  • Network = tcp

Save the profile and connect from client to server. You'll be asked to confirm that you want to allow V2RayNG to connect (on Android, V2Ray functions like a VPN).

Check your IP address at a service such as https://www.iplocation.net.

Comments

Sign In or Register to comment.