Trying to route a port to another IP
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I have a raspberry pi on my local home network and a linux computer on an external location. The pi and the linux computer is connected with VPN (hamachi) but I want du add an IP forward rule so that all devices on my local home network can access a specified port on my linux server through my Pi. I've tried the following in the terminal on my Pi:
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A PREROUTING -p tcp -d 192.168.1.80 --dport 81 -j DNAT --to 25.61.168.0:32400
iptables -A FORWARD -p tcp -d 25.61.168.0 --dport 32400 -j ACCEPT
iptables -t nat -A POSTROUTING -p tcp --dst 25.61.168.0 -j LOG --log-level warning --log-prefix "[REQUEST_FORWARDED]"
Where my Pi's local IP is 192.168.1.80
, in the VPN interface my linux computer's IP is 25.61.168.0
. My Pi is connected to my network on interface eth0
and the VPN interface is labeled ham0
.
In the browser, when I type 192.168.1.80:81
I want it to be redirected to 25.61.168.0:32400
on the Pi.
My code is not working, it tries to connect for like a minute before it terminates. Does anyone know why? Thanks in advance!
networking iptables routing
add a comment |Â
up vote
0
down vote
favorite
I have a raspberry pi on my local home network and a linux computer on an external location. The pi and the linux computer is connected with VPN (hamachi) but I want du add an IP forward rule so that all devices on my local home network can access a specified port on my linux server through my Pi. I've tried the following in the terminal on my Pi:
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A PREROUTING -p tcp -d 192.168.1.80 --dport 81 -j DNAT --to 25.61.168.0:32400
iptables -A FORWARD -p tcp -d 25.61.168.0 --dport 32400 -j ACCEPT
iptables -t nat -A POSTROUTING -p tcp --dst 25.61.168.0 -j LOG --log-level warning --log-prefix "[REQUEST_FORWARDED]"
Where my Pi's local IP is 192.168.1.80
, in the VPN interface my linux computer's IP is 25.61.168.0
. My Pi is connected to my network on interface eth0
and the VPN interface is labeled ham0
.
In the browser, when I type 192.168.1.80:81
I want it to be redirected to 25.61.168.0:32400
on the Pi.
My code is not working, it tries to connect for like a minute before it terminates. Does anyone know why? Thanks in advance!
networking iptables routing
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have a raspberry pi on my local home network and a linux computer on an external location. The pi and the linux computer is connected with VPN (hamachi) but I want du add an IP forward rule so that all devices on my local home network can access a specified port on my linux server through my Pi. I've tried the following in the terminal on my Pi:
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A PREROUTING -p tcp -d 192.168.1.80 --dport 81 -j DNAT --to 25.61.168.0:32400
iptables -A FORWARD -p tcp -d 25.61.168.0 --dport 32400 -j ACCEPT
iptables -t nat -A POSTROUTING -p tcp --dst 25.61.168.0 -j LOG --log-level warning --log-prefix "[REQUEST_FORWARDED]"
Where my Pi's local IP is 192.168.1.80
, in the VPN interface my linux computer's IP is 25.61.168.0
. My Pi is connected to my network on interface eth0
and the VPN interface is labeled ham0
.
In the browser, when I type 192.168.1.80:81
I want it to be redirected to 25.61.168.0:32400
on the Pi.
My code is not working, it tries to connect for like a minute before it terminates. Does anyone know why? Thanks in advance!
networking iptables routing
I have a raspberry pi on my local home network and a linux computer on an external location. The pi and the linux computer is connected with VPN (hamachi) but I want du add an IP forward rule so that all devices on my local home network can access a specified port on my linux server through my Pi. I've tried the following in the terminal on my Pi:
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A PREROUTING -p tcp -d 192.168.1.80 --dport 81 -j DNAT --to 25.61.168.0:32400
iptables -A FORWARD -p tcp -d 25.61.168.0 --dport 32400 -j ACCEPT
iptables -t nat -A POSTROUTING -p tcp --dst 25.61.168.0 -j LOG --log-level warning --log-prefix "[REQUEST_FORWARDED]"
Where my Pi's local IP is 192.168.1.80
, in the VPN interface my linux computer's IP is 25.61.168.0
. My Pi is connected to my network on interface eth0
and the VPN interface is labeled ham0
.
In the browser, when I type 192.168.1.80:81
I want it to be redirected to 25.61.168.0:32400
on the Pi.
My code is not working, it tries to connect for like a minute before it terminates. Does anyone know why? Thanks in advance!
networking iptables routing
networking iptables routing
asked Sep 26 '17 at 9:38
Christian Lindland
11
11
add a comment |Â
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%2f394497%2ftrying-to-route-a-port-to-another-ip%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