LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 02-27-2024, 03:16 PM   #1
ario
Member
 
Registered: Nov 2010
Posts: 65

Rep: Reputation: 2
iptables REDIRECT works locally but not from outside


Hi Folks,
I have a server that can only listen to port 23006
I want it to be publicly accessible. But only on port 443 (https).
I have systemctl setup:
Code:
$ sudo sysctl --system
* Applying /usr/lib/sysctl.d/50-pid-max.conf ...
* Applying /usr/lib/sysctl.d/99-protect-links.conf ...
* Applying /etc/sysctl.d/99-sysctl.conf ...
* Applying /etc/sysctl.conf ...
kernel.pid_max = 4194304
fs.protected_fifos = 1
fs.protected_hardlinks = 1
fs.protected_regular = 2
fs.protected_symlinks = 1
net.ipv4.ip_forward = 1
net.ipv4.conf.all.route_localnet = 1
net.ipv4.ip_forward = 1
net.ipv4.conf.all.route_localnet = 1
If I run another test server to listen on port 443 it works and can respond to requests.
If I run curl on port 23006 my actual server reponds:
Code:
$ curl 127.0.0.1:23006
<html>
<head><title>400 The plain HTTP request was sent to HTTPS port</title></head>
<body>
<center><h1>400 Bad Request</h1></center>
<center>The plain HTTP request was sent to HTTPS port</center>
<hr><center>nginx/1.24.0</center>
</body>
</html>
If I run this iptables command:
Code:
sudo iptables -t nat -A OUTPUT -o lo -p tcp --dport 443 -j REDIRECT --to-port 23006
then I can also access my server through port 443 but ONLY from local:
Code:
$ curl 127.0.0.1:443
The problem is: I cannot access my server from outside. Please help. Thanks in advance.
 
Old 02-27-2024, 03:37 PM   #2
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,638

Rep: Reputation: 2697Reputation: 2697Reputation: 2697Reputation: 2697Reputation: 2697Reputation: 2697Reputation: 2697Reputation: 2697Reputation: 2697Reputation: 2697Reputation: 2697
#1 that seems really stupid and insecure!

#2 you do not make it clear what your full network map looks like, or what things are going on at your edge device (router?) and which on your target node. External traffic must be allowed in at your edge device and routed to the desired address and port on your target node.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Iptables: how to redirect locally-generated packets to a remote server? briwood Linux - Networking 28 02-16-2016 09:35 PM
centos 4.2: terminal bell works remotely, but not locally hawarden Linux - General 2 10-28-2005 02:39 PM
apache works, website works, but not from outside? kahn Linux - Software 7 08-05-2005 02:38 AM
tightVNC works locally but not remotely? mikeli Linux - Software 2 02-01-2005 04:48 AM
sendmail - works locally but not from outside ereeno Linux - Software 5 02-03-2004 12:40 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 05:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration