refs:
http://askubuntu.com/questions/293356/how-to-open-a-particular-port-in-ubuntu
Run this on the commandline; it should solve issue: sudo iptables -A INPUT -m conntrack –ctstate NEW,RELATED,ESTABLISHED -j ACCEPT
To do a specific port:
sudo iptables -A INPUT -p <tcp OR udp> <--dport OR --sport> <port> -j ACCEPT
INPUT is the chain for incoming traffic. -p is protocol (either tcp or udp –dport or –sportspecify allowing for destination or source port. -j is “jump” and its where you ACCEPT, REJECT, orDROP the packet(s)
所以,开放5600端口接收广播,结果:
sudo iptables -A INPUT -p udp -d 0/0 -s 0/0 --dport 5600 -j ACCEPT
开放8000端口接收tcp,结果:
sudo iptables -A INPUT -p tcp -d 0/0 -s 0/0 --dport 8000 -j ACCEPT
设置防火墙的规则,允许5600端口进入
sudo ufw allow 5600
sudo ufw allow 8000
查看状态:
sudo netstat -ntlup
nc 用法:
refs:
http://manpages.ubuntu.com/manpages/hardy/man1/nc_openbsd.1.html
CLIENT/SERVER MODEL
It is quite simple to build a very basic client/server model using nc.
On one console, start nc listening on a specific port for a connection.
For example:
$ nc -l 1234
nc is now listening on port 1234 for a connection. On a second console
(or a second machine), connect to the machine and port being listened on:
$ nc 127.0.0.1 1234