forward a localhost in Octopi(rasberry pi) to be accessed from internet using openvpn

Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I need to access an octopi (raspberry pi) from the Internet. I cannot use a router, so I am using a wifi as my Internet source.
I need to access the raspberry pi using the Internet or any android application using IP and port.
internet > wifi > rasberrypi
What I have tried so far
sudo /bin/su -c "echo -e 'n#Enable IP Routingnnet.ipv4.ip_forward = 1' > /etc/sysctl.conf"
sudo sysctl -p
then
net.ipv4.ip_forward = 1
sudo iptables -t nat -A POSTROUTING -o tun2 -j MASQUERADE
sudo iptables -A FORWARD -i wlan0 -o tun2 -j ACCEPT
sudo iptables -A FORWARD -i tun2 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A INPUT -i lo -j ACCEPT
sudo iptables -A INPUT -i wlan0 -p icmp -j ACCEPT
sudo iptables -A INPUT -i wlan0 -p tcp --dport 22 -j ACCEPT //should it be any other port?
sudo iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
sudo iptables -P FORWARD DROP //i get error here
sudo iptables -P INPUT DROP// error input,forward is not accepted as parameter
sudo apt-get install iptables-persistent
sudo systemctl enable netfilter-persistent
sudo netfilter-persistent save
manual port forwarding
sudo iptables -t nat -A PREROUTING -p tcp --dport 666 -j DNAT --to 192.168.0.6
sudo iptables -t filter -A FORWARD -p tcp -d 192.168.0.6 --dport 666 -j ACCEPT
sudo netfilter-persistent save
I followed this website and used wlan0 insted of eth0.
I have changed my IP to static and used it for forwarding.
I don't know which port to use instead of 666? Can I use, say, 1800 or 1993?
I am really new to networking and these commands are new to me.
ip route show command output:
>ip route show
0.0.0.0/1 via 10.10.0.21 dev tun2
default via 192.168.43.1 dev wlan0 metric 303
10.10.0.1 via 10.10.0.21 dev tun2
10.10.0.21 dev tun2 proto kernel scope link src 10.10.0.22
128.0.0.0/1 via 10.10.0.21 dev tun2
176.126.237.214 via 192.168.43.1 dev wlan0
192.168.43.0/24 dev wlan0 proto kernel scope link src 192.168.43.102 metric 303
do i need control over the openvpn server?
networking raspberry-pi port-forwarding
add a comment |Â
up vote
0
down vote
favorite
I need to access an octopi (raspberry pi) from the Internet. I cannot use a router, so I am using a wifi as my Internet source.
I need to access the raspberry pi using the Internet or any android application using IP and port.
internet > wifi > rasberrypi
What I have tried so far
sudo /bin/su -c "echo -e 'n#Enable IP Routingnnet.ipv4.ip_forward = 1' > /etc/sysctl.conf"
sudo sysctl -p
then
net.ipv4.ip_forward = 1
sudo iptables -t nat -A POSTROUTING -o tun2 -j MASQUERADE
sudo iptables -A FORWARD -i wlan0 -o tun2 -j ACCEPT
sudo iptables -A FORWARD -i tun2 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A INPUT -i lo -j ACCEPT
sudo iptables -A INPUT -i wlan0 -p icmp -j ACCEPT
sudo iptables -A INPUT -i wlan0 -p tcp --dport 22 -j ACCEPT //should it be any other port?
sudo iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
sudo iptables -P FORWARD DROP //i get error here
sudo iptables -P INPUT DROP// error input,forward is not accepted as parameter
sudo apt-get install iptables-persistent
sudo systemctl enable netfilter-persistent
sudo netfilter-persistent save
manual port forwarding
sudo iptables -t nat -A PREROUTING -p tcp --dport 666 -j DNAT --to 192.168.0.6
sudo iptables -t filter -A FORWARD -p tcp -d 192.168.0.6 --dport 666 -j ACCEPT
sudo netfilter-persistent save
I followed this website and used wlan0 insted of eth0.
I have changed my IP to static and used it for forwarding.
I don't know which port to use instead of 666? Can I use, say, 1800 or 1993?
I am really new to networking and these commands are new to me.
ip route show command output:
>ip route show
0.0.0.0/1 via 10.10.0.21 dev tun2
default via 192.168.43.1 dev wlan0 metric 303
10.10.0.1 via 10.10.0.21 dev tun2
10.10.0.21 dev tun2 proto kernel scope link src 10.10.0.22
128.0.0.0/1 via 10.10.0.21 dev tun2
176.126.237.214 via 192.168.43.1 dev wlan0
192.168.43.0/24 dev wlan0 proto kernel scope link src 192.168.43.102 metric 303
do i need control over the openvpn server?
networking raspberry-pi port-forwarding
even tried this answer link
â user33207
Mar 17 at 3:57
@Jeff Schaller thank you
â user33207
Mar 19 at 5:39
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I need to access an octopi (raspberry pi) from the Internet. I cannot use a router, so I am using a wifi as my Internet source.
I need to access the raspberry pi using the Internet or any android application using IP and port.
internet > wifi > rasberrypi
What I have tried so far
sudo /bin/su -c "echo -e 'n#Enable IP Routingnnet.ipv4.ip_forward = 1' > /etc/sysctl.conf"
sudo sysctl -p
then
net.ipv4.ip_forward = 1
sudo iptables -t nat -A POSTROUTING -o tun2 -j MASQUERADE
sudo iptables -A FORWARD -i wlan0 -o tun2 -j ACCEPT
sudo iptables -A FORWARD -i tun2 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A INPUT -i lo -j ACCEPT
sudo iptables -A INPUT -i wlan0 -p icmp -j ACCEPT
sudo iptables -A INPUT -i wlan0 -p tcp --dport 22 -j ACCEPT //should it be any other port?
sudo iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
sudo iptables -P FORWARD DROP //i get error here
sudo iptables -P INPUT DROP// error input,forward is not accepted as parameter
sudo apt-get install iptables-persistent
sudo systemctl enable netfilter-persistent
sudo netfilter-persistent save
manual port forwarding
sudo iptables -t nat -A PREROUTING -p tcp --dport 666 -j DNAT --to 192.168.0.6
sudo iptables -t filter -A FORWARD -p tcp -d 192.168.0.6 --dport 666 -j ACCEPT
sudo netfilter-persistent save
I followed this website and used wlan0 insted of eth0.
I have changed my IP to static and used it for forwarding.
I don't know which port to use instead of 666? Can I use, say, 1800 or 1993?
I am really new to networking and these commands are new to me.
ip route show command output:
>ip route show
0.0.0.0/1 via 10.10.0.21 dev tun2
default via 192.168.43.1 dev wlan0 metric 303
10.10.0.1 via 10.10.0.21 dev tun2
10.10.0.21 dev tun2 proto kernel scope link src 10.10.0.22
128.0.0.0/1 via 10.10.0.21 dev tun2
176.126.237.214 via 192.168.43.1 dev wlan0
192.168.43.0/24 dev wlan0 proto kernel scope link src 192.168.43.102 metric 303
do i need control over the openvpn server?
networking raspberry-pi port-forwarding
I need to access an octopi (raspberry pi) from the Internet. I cannot use a router, so I am using a wifi as my Internet source.
I need to access the raspberry pi using the Internet or any android application using IP and port.
internet > wifi > rasberrypi
What I have tried so far
sudo /bin/su -c "echo -e 'n#Enable IP Routingnnet.ipv4.ip_forward = 1' > /etc/sysctl.conf"
sudo sysctl -p
then
net.ipv4.ip_forward = 1
sudo iptables -t nat -A POSTROUTING -o tun2 -j MASQUERADE
sudo iptables -A FORWARD -i wlan0 -o tun2 -j ACCEPT
sudo iptables -A FORWARD -i tun2 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A INPUT -i lo -j ACCEPT
sudo iptables -A INPUT -i wlan0 -p icmp -j ACCEPT
sudo iptables -A INPUT -i wlan0 -p tcp --dport 22 -j ACCEPT //should it be any other port?
sudo iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
sudo iptables -P FORWARD DROP //i get error here
sudo iptables -P INPUT DROP// error input,forward is not accepted as parameter
sudo apt-get install iptables-persistent
sudo systemctl enable netfilter-persistent
sudo netfilter-persistent save
manual port forwarding
sudo iptables -t nat -A PREROUTING -p tcp --dport 666 -j DNAT --to 192.168.0.6
sudo iptables -t filter -A FORWARD -p tcp -d 192.168.0.6 --dport 666 -j ACCEPT
sudo netfilter-persistent save
I followed this website and used wlan0 insted of eth0.
I have changed my IP to static and used it for forwarding.
I don't know which port to use instead of 666? Can I use, say, 1800 or 1993?
I am really new to networking and these commands are new to me.
ip route show command output:
>ip route show
0.0.0.0/1 via 10.10.0.21 dev tun2
default via 192.168.43.1 dev wlan0 metric 303
10.10.0.1 via 10.10.0.21 dev tun2
10.10.0.21 dev tun2 proto kernel scope link src 10.10.0.22
128.0.0.0/1 via 10.10.0.21 dev tun2
176.126.237.214 via 192.168.43.1 dev wlan0
192.168.43.0/24 dev wlan0 proto kernel scope link src 192.168.43.102 metric 303
do i need control over the openvpn server?
networking raspberry-pi port-forwarding
edited Mar 18 at 15:53
Jeff Schaller
31.2k846105
31.2k846105
asked Mar 17 at 3:55
user33207
11
11
even tried this answer link
â user33207
Mar 17 at 3:57
@Jeff Schaller thank you
â user33207
Mar 19 at 5:39
add a comment |Â
even tried this answer link
â user33207
Mar 17 at 3:57
@Jeff Schaller thank you
â user33207
Mar 19 at 5:39
even tried this answer link
â user33207
Mar 17 at 3:57
even tried this answer link
â user33207
Mar 17 at 3:57
@Jeff Schaller thank you
â user33207
Mar 19 at 5:39
@Jeff Schaller thank you
â user33207
Mar 19 at 5:39
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f430723%2fforward-a-localhost-in-octopirasberry-pi-to-be-accessed-from-internet-using-op%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
even tried this answer link
â user33207
Mar 17 at 3:57
@Jeff Schaller thank you
â user33207
Mar 19 at 5:39