Answer the question
In order to leave comments, you need to log in
How to connect from Windows to centos on port 5555?
Hello! help me figure it out...
I have:
[1] Home host on Centos, IP: 192.168.1.5 (here the socket server sits at 127.0.0.1:5555)
host external IP: xxxx
[2] Home server on Windows, IP: 192.168.1.6 (there is a program on it, it polls 192.168.1.5:5555)
[1] and [2] are in the local network:
cmd>ping 192.168.1.5
...
Статистика Ping для 192.168.1.5: Пакетов: отправлено = 4, получено = 4, потеряно = 0 (0% потерь)
Приблизительное время приема-передачи в мс: Минимальное = 0мсек, Максимальное = 1 мсек, Среднее = 0 мсек
iptables -A INPUT -p tcp -m tcp --dport 5555 -m state --state NEW -j ACCEPT
iptables -A INPUT -i enp2s0 -p tcp -m tcp --dport 5555 -j ACCEPT
iptables -A INPUT -i enp2s0 -p tcp -m conntrack --ctstate NEW -m multiport --dports 5554:5556 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 5555 -m state --state NEW -j ACCEPT
iptables -A INPUT -s 192.168.1.6/32 -p tcp -m conntrack --ctstate NEW -m multiport --dports 5554:5556 -j ACCEPT
service iptables save
/bin/systemctl restart iptables.service
// сокетсервер забинден на localhost:5555
[[email protected] ~]# fuser -vn tcp 5555
ПОЛЬЗ-ЛЬ PID ДОСТУП КОМАНДА
5555/tcp: chel 8336 F.... php
// прослушивание есть
[[email protected] ~]# netstat -na | grep 555
tcp 0 0 127.0.0.1:5555 0.0.0.0:* LISTEN
cmd> telnet
telnet> o 192.168.1.5 5555
Подключение к 192.168.1.5...Не удалось открыть подключение к этому узлу, на порт
5555: Сбой подключения
telnet> o x.x.x.x 5555
Подключение к x.x.x.x...Не удалось открыть подключение к этому узлу, на порт
5555: Сбой подключения
iptables -t nat -A PREROUTING -p tcp -m tcp -d 192.168.1.6 --dport 5555 -j DNAT --to-destination 192.168.1.5
iptables -t nat -A POSTROUTING -p tcp -m tcp -s 192.168.1.5 --sport 5555 -j SNAT --to-source 192.168.1.6:5555
Answer the question
In order to leave comments, you need to log in
If Centos version 7+, then it is easier to forward ports like this:
firewall-cmd --add-port=5555/tcp --permanent
firewall-cmd --reload
Spheniscus, it turns out that firewalld is a replacement for Iptables and fail2ban (based on the article https://xakep.ru/2017/02/15/firewalld/ )?
Unfortunately, there are sites on the host and iptables contains 93 lines, I'm afraid that I won't be able to configure firewalld correctly :)
Spheniscus, thanks for the information on how one of the solutions will work for the future.
But still I would like to know how to configure iptables?
2 local servers seem to be complicated, connected via a router, the port does not go from Windows to Centos (although they see each other on the network), or maybe vice versa?
from Centos to Windows on port 5555 can it be easier?
iptables -I INPUT -s 192.168.1.0/24 -m tcp -p tcp --dport 5555 -j ACCEPT
Note that there is an append to the front of the list (-I) option, and you used the append to the end (-A) option list of rules. I saw a list in CentOS in which the last rule was REJECT, i.e. everything below did not work. Check for yourself.
It is good to show all the rules at once in such questions:
iptables-save
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question