开放ubuntu server的指定端口

57 篇文章 0 订阅

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 ACCEPTREJECT, 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



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值