Forwarding port for outgoing requests Linux [closed] - linux

Closed. This question is not about programming or software development. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 days ago.
Improve this question
I have a remote server (server A) that listens on port 9414 and I have another server (server B) that needs to connect to server A on that port, but the application on server B can only send requests to port 9623 and I need to set that any outbound requests sent to port 9623 will actually be sent to port 9414, like an alias port, nothing is listening on port 9623 in server A but still from my application side everything has to be sent supposedly to port 9623.
I have tried with firewalld:
sudo firewall-cmd --permanent --add-forward-port=port=9623:proto=tcp:toport=9414
and tried with iptables:
sudo iptables -t nat -A OUTPUT -p tcp --dport 9623 -j REDIRECT --to-port 9414
or:
sudo iptables -t nat -A PREROUTING -p tcp --dport 9623 -j REDIRECT --to-port 9414
Still no matter which rule I used, telnet to the remote server on port 9414 works, but on port 9623 fails with:
telnet: Unable to connect to remote host: Connection refused
Is there a different rule I could apply to make that port forwarding work?

Related

Docker listening only in port 8080 [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
I tried port 8080:
docker run -d --name=myweb1 -p 8080:80 -v /var/www/vhosts/domain/httpdocs/myweb:/var/www/html nginx:1.11-alpine
but when I change to 8081 (for example):
docker run -d --name=myweb2 -p 8081:80 -v /var/www/vhosts/domain/httpdocs/myweb:/var/www/html nginx:1.11-alpine
it doesn't work. I've tried having just one container up or many, it doesn't work anyway.
I installed Docker over Ubuntu 14.04.
UPDATE
First I try to create 2 containers: 1 nginx and 1 apache:
docker run -d --name=myweb8080 -p 8080:80 -v /var/www/vhosts/domain/httpdocs/miweb:/var/www/html nginx:1.11-alpine
docker run -d --name=myweb8081 -p 8081:80 -v /var/www/vhosts/domain/httpdocs/miweb:/var/www/html php:apache
The first one (nginx in port 8080) works ok. The second one (apache in port 8081) does not work and the error is ERR_CONNECTION_TIMED_OUT.
Then I stop the nginx (port 8080) and run another apache container in port 8080:
docker run -d --name=myweb8080b -p 8080:80 -v /var/www/vhosts/domain/httpdocs/miweb:/var/www/html php:apache
And this one works ok too.
I was looking around tcp and tcp6 but I inspected the containers and all of them have tcp despite of having tcp6 with 'netstat'. Also I found than docker tcp6 implies tcp too.
Any idea?
probably An application use this port. please see below command:
netstat -an | grep :8081
if you have a result, It's meaning, you have an application that uses this port.

SSH set non default port [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
I am trying to change default port of SSH from 22 to 2292, Host: RHEL 7.1
I have tried:
1)vi /etc/ssh/sshd_config
#Port 22
Port 2292
2)reboot
Error
ssh -p 2292 root#lrmi079.pll.domin.com
ssh: connect to host lrmi079.pll.domin.com port 2292: No route to host
but ping to the host works
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
Please help
It's possible that this new port 2292 is not open on your RHEL 7.1 host and the inbuilt firewall (also known as iptables) is declining the connectivity.
Check the current firewall rules:
$ sudo iptables -L
To open up a new port - port 2292 - in your case:
$ sudo firewall-cmd --zone=public --add-port=2292/tcp --permanent
$ sudo firewall-cmd --reload
Check the updated rules:
$ firewall-cmd --list-all
Let me know if it worked.

How to connect to ftp server from within LAN when the router port-forwards external connection away from it [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
Sorry for the long question.
What it means is this:
I am managing a small LAN that is protected by a router.
router 192.168.1.1
server 192.168.1.9
client 192.168.1.2
client 192.168.1.4
Since I have a static IP from my ISP, which is lets say 245.34.344.34, I can access my LAN at that address.
Now, I have set up my router's port forwarding config to this: when I SSH to 245.34.344.34 out from the internet, it forwards it to server 192.168.1.9:22. And when I FTP to 245.34.344.34, forwards it to client 192.168.1.2:21. Fine.
Then, when I am working from within the LAN, on my client 192.168.1.2 computer and that I want to access 192.168.1.9 through FTP, the router tries to forward it back to 192.168.1.2. But I am not sure what is happening.
On server 192.168.1.9 (which runs ubuntu 14.04.3 LTS (GNU/Linux 3.19.0-47-generic i686), when I sudo ufw status:
To Action From
-- ------ ----
80 ALLOW Anywhere
443 ALLOW Anywhere
22 ALLOW Anywhere
3000 ALLOW Anywhere
21/tcp ALLOW Anywhere
21 ALLOW Anywhere
80 (v6) ALLOW Anywhere (v6)
443 (v6) ALLOW Anywhere (v6)
22 (v6) ALLOW Anywhere (v6)
3000 (v6) ALLOW Anywhere (v6)
21/tcp (v6) ALLOW Anywhere (v6)
21 (v6) ALLOW Anywhere (v6)
But if I do nmap localhost:
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
631/tcp open ipp
3306/tcp open mysql
Now on client 192.168.1.2, nmap 192.168.1.9:
PORT STATE SERVICE
21/tcp closed ftp
22/tcp open ssh
80/tcp open http
443/tcp closed https
3000/tcp closed ppp
It shows that the server's port 21 is closed.
I don't get it.
Can someone please help me understand how to reach my server through FTP from within the LAN?
Thanks
As I understand it your FTP daemon is supposed to be running on 192.168.1.9. If so you should forward port 21 to 192.168.1.9 not 192.168.1.2. That is one problem.
Another problem is that based on the output of nmap from 192.168.1.2 against 192.168.1.9 there is no FTP daemon on 192.168.1.9. Make sure it is installed, properly configured, and is running.
If you have networking properly configured on 192.168.1.2, it should be bypassing the router to access 192.168.1.9.

How to open port in Linux [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
I have installed and web application which is running on port 8080 on RHEL (centOS). I only have command line access to that machine. I have tried to access that application from my windows machine from which I am connected to server via command-line, but it is giving connection time out error.
Then I have tried to open port 8080. I have added following entry into the iptables.
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
After adding this into the iptables I have restarted it with -
/etc/init.d/iptables restart
But still I am not able to access that application from my windows machine.
Am I doing any mistake or missing something?
The following configs works on Cent OS 6 or earlier
As stated above first have to disable selinux.
Step 1
nano /etc/sysconfig/selinux
Make sure the file has this configurations
SELINUX=disabled
SELINUXTYPE=targeted
Then restart the system
Step 2
iptables -A INPUT -m state --state NEW -p tcp --dport 8080 -j ACCEPT
Step 3
sudo service iptables save
For Cent OS 7
step 1
firewall-cmd --zone=public --permanent --add-port=8080/tcp
Step 2
firewall-cmd --reload
First, you should disable selinux, edit file /etc/sysconfig/selinux so it looks like this:
SELINUX=disabled
SELINUXTYPE=targeted
Save file and restart system.
Then you can add the new rule to iptables:
iptables -A INPUT -m state --state NEW -p tcp --dport 8080 -j ACCEPT
and restart iptables with /etc/init.d/iptables restart
If it doesn't work you should check other network settings.

iptables port forwarding doesn't persist after restart [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I have server instance running on amazon ec2. I want to forward from port 80 to 8080 using iptables. Which works fine until restart when it stops forwarding. I have used
iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to 8080
to set up fowarding. What do I need to do to make it persistant?
Thanks
I found a good blog post explaining how to do it
https://help.ubuntu.com/community/IptablesHowTo
You have to run your firewall rules at boot time.

Resources