- AWS account
-
Create an EC2 key-pair,
- required for ssh access into the EC2 that will be created: https://eu-west-1.console.aws.amazon.com/ec2/v2/home?region=eu-west-1#KeyPairs
-
Move the key to your desired directory and change the permission to read by owner only
- Mac/Linux: Run
chmod 400 4in6tunnel.pem
(replace 4in6tunnel.pem with your key name) - Windows: Check out https://superuser.com/questions/1296024/windows-ssh-permissions-for-private-key-are-too-open
- Mac/Linux: Run
-
Go to CloudFormation
-
Copy paste the stack.json and create the stack in CloudFormation
-
Navigate to the EC2 services
-
Copy the Public IPv4 DNS
- e.g. ec2-18-203-30-246.eu-west-1.compute.amazonaws.com
-
Open the terminal an SSH into the server using the ubuntu username and the key you generated in step 1
- e.g. ssh -i "ipForwardTest.pem" ubuntu@ec2-54-74-193-16.eu-west-1.compute.amazonaws.com
- Note: Windows users may need to setup SSH: https://www.howtogeek.com/336775/how-to-enable-and-use-windows-10s-built-in-ssh-commands/
-
Setup Node Version Manager
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
-
Activate the Node Version Manager
. ~/.nvm/nvm.sh
-
Install Node
nvm install node
-
Create a test directory on the EC2 server
git clone https://github.com/ResoluteError/4in6tunnel.git
-
Setup test project
cd 4in6tunnel/expressHelloWorld
npm install
-
Run the test express app to respond on port 8080
node index.js
-
In your aws console, get the "Public IPv4 address" & "IPv6 IPs" of your EC2 instance
-
Visit the IPs on the 8080 port
http://18.203.30.246:8080
http://[2a05:d018:a60:1f00:ea4b:72ae:8e81:390d]:8080
(don't forget the braces)
-
If you see the "Hello World" message, you are ready to go.
-
Setup the IPTables to map port 80 to 8080 and 443 to 8443 on the EC2 instance
- sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
- sudo iptables -t nat -A PREROUTING -p tcp --dport 443 -j REDIRECT --to-port 8443
-
Persist the IPTables to remain active after reboots
sudo apt-get update
sudo apt-get install iptables-persistent
(Say yes to all options)- Optional: If you created the node script, make sure it is running (
node index.js
) and check if you get the expected "Hello World" response from the IPv4 and IPv6 addresses without any port information (defaults to 80)
Before you continue, make sure port 8080 and 8443 are freed up again by stopping the node script
-
Install 6tunnel
sudo apt-get install 6tunnel
-
Identify the IPv6 address of your raspberryPi
- e.g.
2a02:8070:4ad:eaa0:4fc6:e7b5:6879:2eff
- e.g.
-
Create the 6tunnel setup script
- run
nano /home/ubuntu/6tunnel-setup.sh
- copy/paste the contents of
./serverSetup/6tunnel-setup.sh
- IMPORTANT: replace the IPV6_ADDRESS in line 2 with the IPv6 from the previous step
- run
chmod 755 /home/ubuntu/6tunnel-setup.sh
- run
-
Run the setup script and test the url to make sure the tunnel is working
- run
/home/ubuntu/6tunnel-setup.sh
- visit the public IPv4 of your EC2 instance in your browser
- run
-
Add daemon to run the setup script on reboot
- run
sudo nano /etc/systemd/system/6tunnel.service
- copy/paste the contents of
./serverSetup/6tunnel.service
- run
sudo chmod 755 /etc/systemd/system/6tunnel.service
- run
sudo systemctl daemon-reload && sudo systemctl enable 6tunnel
- run
-
Go to your domain provider (e.g. Route53 on AWS or UnitedDomains or Strato)
-
Set the A record to point to the public IPv4 of your EC2 instance
-
Set the AAAA record to point to the public IPv6 of your RaspberryPi
-
Wait for the records to activate and test