Pages : 1
#1 Le 07/10/2007, à 01:23
- Helldream
Ouvrir un port sous Ubuntu
Bonjour,
JE développe une application client/serveur multi-plateforme. Sous Windows, tout se passe bien : lorsque je lance mon serveur et que je vérifie sur internet l'état du port que j'utilise pour l'écoute, ce dernier est bien marqué "ouvert". Lorsque le serveur est étaint, il est marqué "bloqué"... Normal. Et si un client tente de se connecter, la communication fonctionne
Sous Ubuntu par contre, mon port reste marqué "caché", que mon application serveur soit lancée ou non. Et si un client essaie de se connecter, il reçoit une erreur comme quoi le temps d'attente est dépassée. Mon serveur n'est donc pas joignable par internet (en LAN par contre, il fonctionne parfaitement).
N'ayant pas installé de firewall, auriez-vous une idée de la cause de ce problème? Un firewall est-il installé d'office avec Ubuntu Feisty (version que j'utilise)? Y a-t'il une manip à faire pour rendre visible ce port?
Merci d'avance pour vos réponses!
Hors ligne
#2 Le 07/10/2007, à 02:36
- nainbuss
Re : Ouvrir un port sous Ubuntu
Iptables est installé par défaut.
http://doc.ubuntu-fr.org/iptables
Perso, j'aime bien Firestarter.
Quel numéro de port utilises-tu?
Hors ligne
#3 Le 07/10/2007, à 16:54
- Helldream
Re : Ouvrir un port sous Ubuntu
J'ai pris le port 7779 pour le moment, mais ça n'est rien de fixe : je l'ai pris au hasard pour faire mes tests
Si j'ai bien survolé, je devrais donc écrire un truc de ce genre, dans la console :
iptables -A INPUT -p tcp -i eth0 --dport 7779 -j ACCEPT
c'est bien ça? Ai-je besoin de l'ouvrir aussi en OUTPUT? (au pire je testerais )
En tous cas merci pour l'info, je ne savais pas qu'un firewall était installé par défaut ^^ Une petite icone (à coté de l'heure par exemple) permettant de le configurer graphiquement et de montrer sa présence aurait été sympa d'ailleur...
Dernière modification par Helldream (Le 07/10/2007, à 17:00)
Hors ligne
#4 Le 07/10/2007, à 18:03
- nainbuss
Re : Ouvrir un port sous Ubuntu
Il y a un firewall, mais il laisse tout passer par défaut.
Ce serait peut-être bien que tu donnes le code que tu utilises pour te connecter à ton port.
Qu'est-ce que tu utilises pour vérifier l'état d'un port?
Hors ligne
#5 Le 07/10/2007, à 22:06
- Helldream
Re : Ouvrir un port sous Ubuntu
Pour ce qui est de la vérification du port, je vais sur ce site : https://www.grc.com/x/ne.dll?bh0bkyd2 . Avec, je peux taper le numéro du port à controler, et en connaitre son état (firewall activé par exemple, mon port est à "stealth". Firewall désactivé, il est à "Blocked", et serveur lancé à l'écoute, il est à "Open", sous Windows).
Pour le programme je veux bien, mais programmant en C++, ça va pas être facile
Pour le serveur :
[...]
m_sockfd = socket (AF_INET, SOCK_STREAM, 0);addr.sin_family = AF_INET;
addr.sin_port = htons (port); //7779
addr.sin_addr.s_addr = INADDR_ANY;bind (m_sockfd, (struct sockaddr *) &addr, sizeof (addr));
[...]
Pour le client :
[...]
socklen_t addrLenght = sizeof (addr);m_sockfd = socket (AF_INET, SOCK_STREAM, 0);
addr.sin_addr.s_addr = inet_addr ("82.128.70.50"); // ip publique de mon serveur, que je réactualise chaque fois que mon IP change, pour mes test
addr.sin_family = AF_INET;
addr.sin_port = htons (port); // 7779connect (m_sockfd, (sockaddr *) &addr, addrLenght);
[...]
Mais je ne pense pas que le soucis vienne du code : il marche parfaitement lorsque j'entre une ip locale (ip d'un autre PC de mon réseau) ou la boucle locale (127.0.0.1) aussi bien sous Linux que Windows, et marche aussi bien en passant par internet, sous Windows. Si le code avait un soucis, je pense que le bug se répercuterait avec un test local, ou ne fonctionnerait pas sur internet, même sous Windows...
Je pense que le soucis vient du fait que mon port d'écoute soit marqué comme "caché" sous Linux, ce qui empêche forcément le client de se connecter dessus :S
Dernière modification par Helldream (Le 07/10/2007, à 22:07)
Hors ligne
#6 Le 08/10/2007, à 15:34
- Helldream
Re : Ouvrir un port sous Ubuntu
Up?
Hors ligne
#7 Le 09/10/2007, à 00:07
- Helldream
Re : Ouvrir un port sous Ubuntu
Personne n'a d'idées? J'ai continué à chercher, mais rien... Mes ports sont toujours marqué "stealth" :S
Hors ligne
#8 Le 09/10/2007, à 01:02
- reeth
Re : Ouvrir un port sous Ubuntu
Déjà il faut savoir si tu as un firewall de configuré ou pas (parce que dans ce cas ouvrir un port sert pas à grand chose...)
donc sudo iptables -L ??
Si tu n'as rien (chaines vides), alors installes-en un : firehol en fichier de configuration, ou firestarter (gnome) / guarddog (kde) pour une interface graphique. Ensuite la configuration est très simple (pour firehol un petit google te renseignera vite ).
Hors ligne
#9 Le 09/10/2007, à 02:46
- Helldream
Re : Ouvrir un port sous Ubuntu
Voici le résultat :
lionel@lionel-desktop:~$ sudo iptables -L
Password:
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
J'ai donc installé Firestarter, comme tu me l'as conseillé. Puis j'ai été dans l'onglet "Politique", et ai ajouté dans le tableau "Autoriser le service/Port/Pour" la ligne "Inconnu/7779/Everyone".
J'obtiens donc ce résultat :
lionel@lionel-desktop:~$ sudo iptables -L
Chain INPUT (policy DROP)
target prot opt source destination
ACCEPT tcp -- 192.168.1.1 anywhere tcp flags:!FIN,SYN,RST,ACK/SYN
ACCEPT udp -- 192.168.1.1 anywhere
ACCEPT tcp -- 0.0.0.0 anywhere tcp flags:!FIN,SYN,RST,ACK/SYN
ACCEPT udp -- 0.0.0.0 anywhere
ACCEPT 0 -- anywhere anywhere
ACCEPT icmp -- anywhere anywhere limit: avg 10/sec burst 5
DROP 0 -- BASE-ADDRESS.MCAST.NET/8 anywhere
DROP 0 -- anywhere BASE-ADDRESS.MCAST.NET/8
DROP 0 -- 255.255.255.255 anywhere
DROP 0 -- anywhere 0.0.0.0
DROP 0 -- anywhere anywhere state INVALID
LSI 0 -f anywhere anywhere limit: avg 10/min burst 5
INBOUND 0 -- anywhere anywhere
LOG_FILTER 0 -- anywhere anywhere
LOG 0 -- anywhere anywhere LOG level info prefix `Unknown Input'
Chain FORWARD (policy DROP)
target prot opt source destination
ACCEPT icmp -- anywhere anywhere limit: avg 10/sec burst 5
LOG_FILTER 0 -- anywhere anywhere
LOG 0 -- anywhere anywhere LOG level info prefix `Unknown Forward'
Chain OUTPUT (policy DROP)
target prot opt source destination
ACCEPT tcp -- 192.168.1.10 192.168.1.1 tcp dpt:domain
ACCEPT udp -- 192.168.1.10 192.168.1.1 udp dpt:domain
ACCEPT tcp -- 192.168.1.10 0.0.0.0 tcp dpt:domain
ACCEPT udp -- 192.168.1.10 0.0.0.0 udp dpt:domain
ACCEPT 0 -- anywhere anywhere
DROP 0 -- BASE-ADDRESS.MCAST.NET/8 anywhere
DROP 0 -- anywhere BASE-ADDRESS.MCAST.NET/8
DROP 0 -- 255.255.255.255 anywhere
DROP 0 -- anywhere 0.0.0.0
DROP 0 -- anywhere anywhere state INVALID
OUTBOUND 0 -- anywhere anywhere
LOG_FILTER 0 -- anywhere anywhere
LOG 0 -- anywhere anywhere LOG level info prefix `Unknown Output'
Chain INBOUND (1 references)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere state RELATED,ESTABLISHED
ACCEPT udp -- anywhere anywhere state RELATED,ESTABLISHED
ACCEPT tcp -- anywhere anywhere tcp dpt:7779
ACCEPT udp -- anywhere anywhere udp dpt:7779
LSI 0 -- anywhere anywhere
Chain LOG_FILTER (5 references)
target prot opt source destination
Chain LSI (2 references)
target prot opt source destination
LOG_FILTER 0 -- anywhere anywhere
LOG tcp -- anywhere anywhere tcp flags:FIN,SYN,RST,ACK/SYN limit: avg 1/sec burst 5 LOG level info prefix `Inbound '
REJECT tcp -- anywhere anywhere tcp flags:FIN,SYN,RST,ACK/SYN reject-with icmp-port-unreachable
LOG tcp -- anywhere anywhere tcp flags:FIN,SYN,RST,ACK/RST limit: avg 1/sec burst 5 LOG level info prefix `Inbound '
REJECT tcp -- anywhere anywhere tcp flags:FIN,SYN,RST,ACK/RST reject-with icmp-port-unreachable
LOG icmp -- anywhere anywhere icmp echo-request limit: avg 1/sec burst 5 LOG level info prefix `Inbound '
REJECT icmp -- anywhere anywhere icmp echo-request reject-with icmp-port-unreachable
LOG 0 -- anywhere anywhere limit: avg 5/sec burst 5 LOG level info prefix `Inbound '
REJECT 0 -- anywhere anywhere reject-with icmp-port-unreachable
Chain LSO (0 references)
target prot opt source destination
LOG_FILTER 0 -- anywhere anywhere
LOG 0 -- anywhere anywhere limit: avg 5/sec burst 5 LOG level info prefix `Outbound '
REJECT 0 -- anywhere anywhere reject-with icmp-port-unreachable
Chain OUTBOUND (1 references)
target prot opt source destination
ACCEPT icmp -- anywhere anywhere
ACCEPT tcp -- anywhere anywhere state RELATED,ESTABLISHED
ACCEPT udp -- anywhere anywhere state RELATED,ESTABLISHED
ACCEPT 0 -- anywhere anywhere
lionel@lionel-desktop:~$
Ai-je tout bien fait? Mon port est toujours marqué "Stealth" même lorsque le serveur est lancé, mais je n'ai pas pu tester si un client pouvait s'y connecter (pas d'ame charitable pour tester avec moi à cette heure tardive ^^)...
Dernière modification par Helldream (Le 09/10/2007, à 02:51)
Hors ligne
#10 Le 09/10/2007, à 15:35
- reeth
Re : Ouvrir un port sous Ubuntu
En fait je pense que tu es derrière une *box. Si c'est le cas alors il est logique que le port soit à stealth. D'ailleur c'est une bonne chose : cela veut dire (furtif en anglais) que l'on ne sais pas si le port est ouvert ou fermé, en fait cela permet d'éviter de te repérer (pour les méchant crackers ). Donc je pense que tout est ok. Maintenant je pense que si tu veux que tu accèdes à ce pc d'un autre poste sur internet, il faut faire un port forwarding au niveau de ton routeur vers ton pc, et utiliser un service du style dyndns car tu doit avoir une ip dynamique.
Hors ligne
#11 Le 09/10/2007, à 17:07
- Helldream
Re : Ouvrir un port sous Ubuntu
Voila, tout marche nickel! En fait, j'ai trouvé la source du problème : mon ip locale n'était pas la même sous Windows et Linux -_- . Donc forcément, la règle que j'avais créée sur ma Livebox pour ouvrir le port ne s'appliquait pas sous Linux.
En tous cas maintenant j'ai un beau firewall en bonus, ce qui ne fait jamais de mal Merci beaucoup à tous pour votre patience et vos explications, elles m'ont bien aidées
Hors ligne
#12 Le 10/10/2007, à 00:10
- reeth
Re : Ouvrir un port sous Ubuntu
Tant mieux
Maintenant tu peux rajouter [résolu] dans le titre de ton premier message
Hors ligne
#13 Le 04/05/2015, à 20:38
- nouslescombattants
Re : Ouvrir un port sous Ubuntu
Bonjour,
je remercie tout le monde pour cette entraide sur forum. Je suis nouveau sur ce forum et j'ai bien lu ce sujet. De ma part j'ai un souci sous linux Ubuntu. J'utilise un serveur VPS pour faire fonctionner ma radio sur mon site. ça fait 2 semaines j'ai un grand souci sur un port 8075 que j'utilise pour la radio.Comme je ne suis pas de domaine j'ai essayé de chercher sur le net et je suis tombé à ce forum. je chercher comment faire pour ouvrir mon port 8075 sans oublier que j'essayé cette formule : iptables -A INPUT -p tcp -i eth0 --dport 8075 -j ACCEPT pas de solution en plus iptables -L me donne ça
Chain INPUT (policy ACCEPT)
target prot opt source destination
fail2ban-vsftpd tcp -- anywhere anywhere multiport dp orts ftp,ftp-data,ftps,ftps-data
fail2ban-ssh-ddos tcp -- anywhere anywhere multiport dports ssh
fail2ban-ssh tcp -- anywhere anywhere multiport dport s ssh
sshguard all -- anywhere anywhere
ACCEPT udp -- anywhere anywhere udp dpt:domain
ACCEPT tcp -- anywhere anywhere tcp dpt:domain
ACCEPT udp -- anywhere anywhere udp dpt:bootps
ACCEPT tcp -- anywhere anywhere tcp dpt:bootps
Chain FORWARD (policy ACCEPT)
target prot opt source destination
ACCEPT all -- anywhere 192.168.122.0/24 state RELATED,ESTA BLISHED
ACCEPT all -- 192.168.122.0/24 anywhere
ACCEPT all -- anywhere anywhere
REJECT all -- anywhere anywhere reject-with icmp-p ort-unreachable
REJECT all -- anywhere anywhere reject-with icmp-p ort-unreachable
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain fail2ban-ssh (1 references)
target prot opt source destination
RETURN all -- anywhere anywhere
Chain fail2ban-ssh-ddos (1 references)
target prot opt source destination
RETURN all -- anywhere anywhere
Chain fail2ban-vsftpd (1 references)
target prot opt source destination
RETURN all -- anywhere anywhere
Chain sshguard (1 references)
target prot opt source destination
DROP all -- 58.218.204.213 anywhere
DROP all -- 222.186.134.87 anywhere
DROP all -- 27.223.74.219 anywhere
DROP all -- 58.218.201.19 anywhere
DROP all -- 222.186.134.89 anywhere
DROP all -- 222.186.21.133 anywhere
DROP all -- 58.218.204.36 anywhere
DROP all -- 58.218.204.46 anywhere
DROP all -- 222.186.160.50 anywhere
DROP all -- 221.229.166.28 anywhere
DROP all -- 222.186.58.131 anywhere
DROP all -- 222.186.160.51 anywhere
DROP all -- 58.218.204.52 anywhere
DROP all -- 222.186.160.52 anywhere
DROP all -- 222.186.134.96 anywhere
DROP all -- 115.239.248.74 anywhere
DROP all -- 222.89.166.12 anywhere
DROP all -- 222.186.21.209 anywhere
DROP all -- 221.229.166.30 anywhere
DROP all -- 221.229.166.29 anywhere
DROP all -- 221.229.166.4 anywhere
root@vps-72969:~# anywhere
anywhere: command not found
root@vps-72969:~# anywhere
anywhere: command not found
root@vps-72969:~# anywhere
anywhere: command not found
root@vps-72969:~# anywhere
anywhere: command not found
root@vps-72969:~# anywhere
anywhere: command not found
root@vps-72969:~# anywhere
anywhere: command not found
root@vps-72969:~# anywhere
anywhere: command not found
root@vps-72969:~# anywhere
anywhere: command not found
root@vps-72969:~# root@vps-72969:~# iptables -L
fail2ban-ssh tcp -- anywhere anywhere multiport dport s ssh
sshguard all -- anywhere anywhere
ACCEPT udp -- anywhere anywhere udp dpt:domain
ACCEPT tcp -- anywhere anywhere tcp dpt:domain
ACCEPT udp -- anywhere anywhere udp dpt:bootps
ACCEPT tcp -- anywhere anywhere tcp dpt:bootps
Chain FORWARD (policy ACCEPT)
target prot opt source destination
ACCEPT all -- anywhere 192.168.122.0/24 state RELATED,ESTA BLISHED
ACCEPT all -- 192.168.122.0/24 anywhere
ACCEPT all -- anywhere anywhere
REJECT all -- anywhere anywhere reject-with icmp-p ort-unreachable
REJECT all -- anywhere anywhere reject-with icmp-p ort-unreachable
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain fail2ban-ssh (1 references)
target prot opt source destination
RETURN all -- anywhere anywhere
Chain fail2ban-ssh-ddos (1 references)
target prot opt source destination
RETURN all -- anywhere anywhere
Chain fail2ban-vsftpd (1 references)
target prot opt source destination
RETURN all -- anywhere anywhere
Chain sshguard (1 references)
target prot opt source destination
DROP all -- 58.218.204.213 anywhere
DROP all -- 222.186.134.87 anywhere
DROP all -- 27.223.74.219 anywhere
DROP all -- 58.218.201.19 anywhere
DROP all -- 222.186.134.89 anywhere
DROP all -- 222.186.21.133 anywhere
DROP all -- 58.218.204.36 anywhere
DROP all -- 58.218.204.46 anywhere
DROP all -- 222.186.160.50 anywhere
DROP all -- 221.229.166.28 anywhere
DROP all -- 222.186.58.131 anywhere
DROP all -- 222.186.160.51 anywhere
DROP all -- 58.218.204.52 anywhere
DROP all -- 222.186.160.52 anywhere
DROP all -- 222.186.134.96 anywhere
DROP all -- 115.239.248.74 anywhere
DROP all -- 222.89.166.12 anywhere
DROP all -- 222.186.21.209 anywhere
DROP all -- 221.229.166.30 anywhere
DROP all -- 221.229.166.29 anywhere
DROP all -- 221.229.166.4 anywhere
root@vps-72969:~# anywhere
anywhere: command not found
root@vps-72969:~# anywhere
anywhere: command not found
root@vps-72969:~# anywhere
anywhere: command not found
root@vps-72969:~# anywhere
anywhere: command not found
root@vps-72969:~# anywhere
anywhere: command not found
root@vps-72969:~# anywhere
anywhere: command not found
root@vps-72969:~# anywhere
anywhere: command not found
root@vps-72969:~# anywhere
anywhere: command not found
root@vps-72969:~#
root@vps-72969:~#: command not found
root@vps-72969:~# Chain INPUT (policy ACCEPT)
-bash: syntax error near unexpected token `('
root@vps-72969:~# target prot opt source destination
No command 'target' found, did you mean:
Command 'targen' from package 'argyll' (universe)
target: command not found
root@vps-72969:~# fail2ban-vsftpd tcp -- anywhere anywhere multiport dports ftp,ftp-data,ftps,ftps-data
fail2ban-vsftpd: command not found
root@vps-72969:~# fail2ban-ssh-ddos tcp -- anywhere anywhere multiport dports ssh
fail2ban-ssh-ddos: command not found
root@vps-72969:~# fail2ban-ssh tcp -- anywhere anywhere multiport dports ssh
fail2ban-ssh: command not found
root@vps-72969:~# sshguard all -- anywhere anywhere
Chain INPUT (policy ACCEPT)
target prot opt source destination
fail2ban-vsftpd tcp -- anywhere anywhere multiport dp orts ftp,ftp-data,ftps,ftps-data
fail2ban-ssh-ddos tcp -- anywhere anywhere multiport dports ssh
fail2ban-ssh tcp -- anywhere anywhere multiport dport s ssh
sshguard all -- anywhere anywhere
ACCEPT udp -- anywhere anywhere udp dpt:domain
ACCEPT tcp -- anywhere anywhere tcp dpt:domain
ACCEPT udp -- anywhere anywhere udp dpt:bootps
ACCEPT tcp -- anywhere anywhere tcp dpt:bootps
Chain FORWARD (policy ACCEPT)
target prot opt source destination
ACCEPT all -- anywhere 192.168.122.0/24 state RELATED,ESTA BLISHED
ACCEPT all -- 192.168.122.0/24 anywhere
ACCEPT all -- anywhere anywhere
REJECT all -- anywhere anywhere reject-with icmp-p ort-unreachable
REJECT all -- anywhere anywhere reject-with icmp-p ort-unreachable
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain fail2ban-ssh (1 references)
target prot opt source destination
RETURN all -- anywhere anywhere
Chain fail2ban-ssh-ddos (1 references)
target prot opt source destination
RETURN all -- anywhere anywhere
Chain fail2ban-vsftpd (1 references)
target prot opt source destination
RETURN all -- anywhere anywhere
Chain sshguard (1 references)
target prot opt source destination
DROP all -- 58.218.204.213 anywhere
DROP all -- 222.186.134.87 anywhere
DROP all -- 27.223.74.219 anywhere
DROP all -- 58.218.201.19 anywhere
DROP all -- 222.186.134.89 anywhere
DROP all -- 222.186.21.133 anywhere
DROP all -- 58.218.204.36 anywhere
DROP all -- 58.218.204.46 anywhere
DROP all -- 222.186.160.50 anywhere
DROP all -- 221.229.166.28 anywhere
DROP all -- 222.186.58.131 anywhere
DROP all -- 222.186.160.51 anywhere
DROP all -- 58.218.204.52 anywhere
DROP all -- 222.186.160.52 anywhere
DROP all -- 222.186.134.96 anywhere
DROP all -- 115.239.248.74 anywhere
DROP all -- 222.89.166.12 anywhere
DROP all -- 222.186.21.209 anywhere
DROP all -- 221.229.166.30 anywhere
DROP all -- 221.229.166.29 anywhere
DROP all -- 221.229.166.4 anywhere
Modération : merci à l'avenir d'utiliser les balises code (explications ici).
Dernière modification par cqfd93 (Le 04/05/2015, à 21:15)
Hors ligne
#14 Le 04/05/2015, à 21:26
- cqfd93
Re : Ouvrir un port sous Ubuntu
Bonsoir,
Tu as fait très fort pour ton premier message !!! Déterrer une discussion vieille de plus de 7 ans,... wow !
Sérieusement, tu aurais intérêt à créer une nouvelle discussion, ça te donnerait plus de visibilité !
− cqfd93 −
Hors ligne
#15 Le 04/05/2015, à 21:43
- nouslescombattants
Re : Ouvrir un port sous Ubuntu
Bonsoir,
Merci bcp
Hors ligne
Pages : 1