前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >CentOS 7 Linux iptables 开放端口映射

CentOS 7 Linux iptables 开放端口映射

作者头像
全栈程序员站长
发布2022-09-27 11:10:25
2.3K0
发布2022-09-27 11:10:25
举报
文章被收录于专栏:全栈程序员必看

大家好,又见面了,我是你们的朋友全栈君。

/bin/systemctl stop firewalld.service

systemctl disable firewalld.service

yum install iptables-services

Package iptables-services-1.4.21-17.el7.x86_64 already installed and latest version

vi /etc/sysconfig/iptables

-A INPUT -m state –state NEW -m tcp -p tcp –dport 6070 -j ACCEPT

/bin/systemctl start iptables.service

systemctl enable iptables.service

iptables -L

yum install nc

nc 106.14.21.223 6070

rpm –q telnet-client

[root@iZuf6492eksiqtd5hy86f8Z pay]# iptables -t nat -A PREROUTING -p tcp –dport 80 -j REDIRECT –to-port 8080

[root@iZuf6492eksiqtd5hy86f8Z pay]# iptables -t nat -A PREROUTING -p tcp –dport 16070 -j REDIRECT –to-port 6070

[root@iZuf6492eksiqtd5hy86f8Z pay]# service iptables save

iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ]

service iptables status

/bin/systemctl restart iptables iptables.service

/bin/systemctl start iptables iptables.service

/bin/systemctl stop iptables iptables.service

#查看已经开放的端口

[root@localhost bin]# netstat -tln

#查看网络连接

netstat -apn

#查看端口使用情况

[root@localhost bin]# lsof -i:3306

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME

mysqld 2728 mysql 30u IPv6 27628 0t0 TCP *:mysql (LISTEN)

lsof -i TCP| fgrep LISTEN

[root@localhost bin]# netstat -anlp | grep 3306

tcp6 0 0 :::3306 :::* LISTEN 2728/mysqld

unix 3 [ ] STREAM CONNECTED 33068 3360/pulseaudio

[root@localhost bin]# nc -lp 9393 &

[root@localhost bin]# netstat -an | grep 9393

tcp 0 0 0.0.0.0:9393 0.0.0.0:* LISTEN

tcp6 0 0 :::9393 :::* LISTEN

vi /etc/sysconfig/iptables

-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 9393 -j ACCEPT

[root@localhost nescafe]# /bin/systemctl start firewalld.service

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/179200.html原文链接:https://javaforall.cn

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档