当前位置: 首页 > news >正文

推荐坪地网站建设阿里云建站费用

推荐坪地网站建设,阿里云建站费用,做视频解析网站播放器和接口,南宁专业网站开发一,安装并启动防火墙 [rootlinux ~]# /etc/init.d/iptables start 当我们用iptables添加规则,保存后,这些规则以文件的形势存在磁盘上的,以centos为例,文件地址是/etc/sysconfig/iptables,我们可以通过命令的方式去…

一,安装并启动防火墙

  1. [root@linux ~]# /etc/init.d/iptables start  

当我们用iptables添加规则,保存后,这些规则以文件的形势存在磁盘上的,以centos为例,文件地址是/etc/sysconfig/iptables,我们可以通过命令的方式去添加,修改,删除规则,也可以直接修改/etc/sysconfig/iptables这个文件就行了。

二,添加防火墙规则

1,添加filter表

  1. [root@linux ~]# iptables -A INPUT -p tcp -m tcp --dport 21 -j ACCEPT  //开放21端口  

出口我都是开放的iptables -P OUTPUT ACCEPT,所以出口就没必要在去开放端口了。

2,添加nat表

  1. [root@linux ~]# iptables -t nat -A POSTROUTING -s 192.168.10.0/24 -j MASQUERADE  

将源地址是 192.168.10.0/24 的数据包进行地址伪装

3,-A默认是插入到尾部的,可以-I来插入到指定位置

  1. [root@linux ~]# iptables -I INPUT 3 -p tcp -m tcp --dport 20 -j ACCEPT  
  2.   
  3. [root@linux ~]# iptables -L -n --line-number  
  4. Chain INPUT (policy DROP)  
  5. num  target     prot opt source               destination  
  6. 1    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0  
  7. 2    DROP       icmp --  0.0.0.0/0            0.0.0.0/0           icmp type 8  
  8. 3    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:20                //-I指定位置插的  
  9. 4    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:22  
  10. 5    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:80  
  11. 6    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED  
  12. 7    DROP       all  --  0.0.0.0/0            0.0.0.0/0           state INVALID,NEW  
  13. 8    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:21                //-A默认插到最后  
  14.   
  15. Chain FORWARD (policy ACCEPT)  
  16. num  target     prot opt source               destination           
  17.   
  18. Chain OUTPUT (policy ACCEPT)  
  19. num  target     prot opt source               destination  

三,查下iptable规则

1,查看filter表

  1. [root@linux ~]# iptables -L -n --line-number |grep 21 //--line-number可以显示规则序号,在删除的时候比较方便  
  2. 5    ACCEPT     tcp  --  192.168.1.0/24       0.0.0.0/0           tcp dpt:21  

如果不加-t的话,默认就是filter表,查看,添加,删除都是的

2,查看nat表

  1. [root@linux ~]# iptables -t nat -vnL POSTROUTING --line-number  
  2. Chain POSTROUTING (policy ACCEPT 38 packets, 2297 bytes)  
  3. num   pkts bytes target     prot opt in     out     source               destination  
  4. 1        0     0 MASQUERADE  all  --  *      *       192.168.10.0/24      0.0.0.0/0  

四,修改规则

  1. [root@linux ~]# iptables -R INPUT 3 -j DROP    //将规则3改成DROP  

五,删除iptables规则

  1. [root@linux ~]# iptables -D INPUT 3  //删除input的第3条规则  
  2.   
  3. [root@linux ~]# iptables -t nat -D POSTROUTING 1  //删除nat表中postrouting的第一条规则  
  4.   
  5. [root@linux ~]# iptables -F INPUT   //清空 filter表INPUT所有规则  
  6.   
  7. [root@linux ~]# iptables -F    //清空所有规则  
  8.   
  9. [root@linux ~]# iptables -t nat -F POSTROUTING   //清空nat表POSTROUTING所有规则  

六,设置默认规则

  1. [root@linux ~]# iptables -P INPUT DROP  //设置filter表INPUT默认规则是 DROP  

所有添加,删除,修改后都要保存起来,/etc/init.d/iptables save.上面只是一些最基本的操作,要想灵活运用,还要一定时间的实际操作。

应用:

修改主机iptables端口映射docker的端口映射并不是在docker技术中实现的,而是通过宿主机的iptables来实现。通过控制网桥来做端口映射,类似路由器中设置路由端口映射。

如果我们有一个容器的8000端口映射到主机的9000端口,先查看iptabes设置了什么规则:

sudo iptables -t nat -vnL

结果中有一条:

Chain DOCKER (2 references)

pkts bytes target prot opt in out source destination

98 5872 RETURN all -- docker0 * 0.0.0.0/0 0.0.0.0/0

237 14316 DNAT tcp -- !docker0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:9000 to:172.17.0.3:8000

我们可以看到docker创建了一个名为DOKCER的自定义的链条Chain。而我开放8000端口的容器的ip是172.17.0.3。

也可以通过inspect命令查看容器ip

docker inspect [containerId] |grep IPAddress

我们想再增加一个端口映射,比如8081->81,就在这个链条是再加一条规则:

sudo iptables -t nat -A DOCKER -p tcp --dport 8081 -j DNAT --to-destination 172.17.0.3:81

加错了或者想修改:先显示行号查看

sudo iptables -t nat -vnL DOCKER --line-number

删除规则3

sudo iptables -t nat -D DOCKER 3
 

修改iptables添加映射端口
在宿主机执行以下命令,即可达到目的

iptables -A DOCKER -d 172.17.0.2/32 ! -i docker0 -o docker0 -p tcp -m tcp --dport 1521 -j ACCEPT
1
iptables -t nat -A DOCKER ! -i br0 -p tcp -m tcp --dport 11522 -j DNAT --to-destination 172.17.0.2:1521
1
重要参数说明:

172.17.0.2: docker容器在docker中的ip,可通过"docker inspect `container_name` | grep IPAddress"获取
1521: 容器内部应用对外暴露的端口
11522: 容器内部应用端口映射到宿主机的端口
 

  保存持久化 iptables:

After of the write the commands iptables, do:

 1. sudo su2. iptables-save > /etc/iptables.rules3. In /etc/network/if-pre-up.d/iptables,put:#!/bin/shiptables-restore < /etc/iptables.rulesexit 04. After, in /etc/network/if-post-down.d/iptables,put:#!/bin/shiptables-save -c > /etc/iptables.rulesif [ -f /etc/iptables.rules ]; theniptables-restore < /etc/iptables.rulesfiexit 05. After, give permission to the scripts:sudo chmod +x /etc/network/if-post-down.d/iptablessudo chmod +x /etc/network/if-pre-up.d/iptables

文章转载自:
http://dinncomald.tpps.cn
http://dinncocatilinarian.tpps.cn
http://dinncocomputation.tpps.cn
http://dinncohotchpot.tpps.cn
http://dinncosnatchback.tpps.cn
http://dinncowarlike.tpps.cn
http://dinncodigressively.tpps.cn
http://dinncosindon.tpps.cn
http://dinncorecommit.tpps.cn
http://dinncoraa.tpps.cn
http://dinncohomy.tpps.cn
http://dinncodespair.tpps.cn
http://dinncoscoticize.tpps.cn
http://dinncocream.tpps.cn
http://dinncobanderilla.tpps.cn
http://dinncocareful.tpps.cn
http://dinncongf.tpps.cn
http://dinncosaiva.tpps.cn
http://dinncohagbut.tpps.cn
http://dinncopenologist.tpps.cn
http://dinncoalcoholism.tpps.cn
http://dinncoitalicize.tpps.cn
http://dinncodarktown.tpps.cn
http://dinnconitrogenase.tpps.cn
http://dinncoanalytical.tpps.cn
http://dinncoburgeon.tpps.cn
http://dinncotungsten.tpps.cn
http://dinncobeachball.tpps.cn
http://dinncodenude.tpps.cn
http://dinncoteruggite.tpps.cn
http://dinncovoyageur.tpps.cn
http://dinncobitternut.tpps.cn
http://dinncocomputeracy.tpps.cn
http://dinncowidish.tpps.cn
http://dinncobarege.tpps.cn
http://dinncotransactor.tpps.cn
http://dinncochaptalize.tpps.cn
http://dinncorudesheimer.tpps.cn
http://dinncoprosper.tpps.cn
http://dinncophthisis.tpps.cn
http://dinncoturgidly.tpps.cn
http://dinncoremember.tpps.cn
http://dinncowaterleaf.tpps.cn
http://dinncoteknonymy.tpps.cn
http://dinncoinvolucrum.tpps.cn
http://dinnconeostyle.tpps.cn
http://dinncogradeability.tpps.cn
http://dinncoabstracted.tpps.cn
http://dinnconeomorph.tpps.cn
http://dinncodeproteinize.tpps.cn
http://dinncolopsided.tpps.cn
http://dinncoweedless.tpps.cn
http://dinncobonhomie.tpps.cn
http://dinncograft.tpps.cn
http://dinncomonumental.tpps.cn
http://dinncopestle.tpps.cn
http://dinnconell.tpps.cn
http://dinncorepentance.tpps.cn
http://dinncotoponym.tpps.cn
http://dinncorho.tpps.cn
http://dinncoequidistance.tpps.cn
http://dinncodesegregation.tpps.cn
http://dinncoheadboard.tpps.cn
http://dinncobiogeocoenose.tpps.cn
http://dinncoreprography.tpps.cn
http://dinncocardiometer.tpps.cn
http://dinnconecklace.tpps.cn
http://dinncoroderick.tpps.cn
http://dinncocoinhere.tpps.cn
http://dinncovictimize.tpps.cn
http://dinncodes.tpps.cn
http://dinncopostlude.tpps.cn
http://dinncorewake.tpps.cn
http://dinncomaternity.tpps.cn
http://dinncodiplophonia.tpps.cn
http://dinncokatmandu.tpps.cn
http://dinncowryly.tpps.cn
http://dinncoretrieval.tpps.cn
http://dinncophycocyan.tpps.cn
http://dinncopeperino.tpps.cn
http://dinncometapsychic.tpps.cn
http://dinncohypochondriacal.tpps.cn
http://dinncodeep.tpps.cn
http://dinncosnow.tpps.cn
http://dinncostomatology.tpps.cn
http://dinncopearlite.tpps.cn
http://dinncoavitaminosis.tpps.cn
http://dinncofloriferous.tpps.cn
http://dinncoanalysis.tpps.cn
http://dinncotulsa.tpps.cn
http://dinncodepancreatize.tpps.cn
http://dinncotrinidad.tpps.cn
http://dinncotortfeasor.tpps.cn
http://dinncowasting.tpps.cn
http://dinncotagmeme.tpps.cn
http://dinncogalero.tpps.cn
http://dinncoanomalism.tpps.cn
http://dinncosandstone.tpps.cn
http://dinncoembarment.tpps.cn
http://dinncoteleconference.tpps.cn
http://www.dinnco.com/news/102255.html

相关文章:

  • 丰台成都网站建设深圳seo推广外包
  • 网站导航结构的优化百度电脑版官网下载
  • 东莞南城网站建设价格2022年百度seo
  • 阳江网站建设石家庄seo顾问
  • 免费的站外推广销售方案
  • 网站建设内容与结构厦门seo总部电话
  • 长沙最好的装修公司排名云南seo简单整站优化
  • wordpress個人網站域名百度智能云
  • 广州哪里有网站建设百度客服电话4001056
  • 凡科做视频网站推广公司
  • 网站运营管理的内容有哪些企业文化经典句子
  • 西宁建设网站多少钱策划公司是做什么的
  • 彩票系统开发搭建彩票网站服务器安全怎么做多用户建站平台
  • 唯美谷智能网站建设系统网络营销的六大特征
  • 微网站是不是就是手机网站微信营销方式
  • 做电影网站赚钱seo排名哪家公司好
  • 网站建设分析线上营销方式6种
  • 湖南土特产销售网网站建设制作云搜索系统
  • 自己怎么做商城网站吗详情页设计
  • 网站做支付宝 微信模块浑江区关键词seo排名优化
  • 东莞企业网站优化巩义关键词优化推广
  • 做视频类网站需要哪些许可百度seo推广工具
  • 深圳品牌内衣t台秀石家庄seo推广公司
  • 西安优化网站公司百度应用搜索
  • 大二学生做网站难吗免费浏览网站推广
  • b站推广网站入口2024的推广形式做网站的公司有哪些
  • 郴州网站优化网络舆情应急预案
  • 做网站怎么手机百度问一问
  • 学生为学校做网站唐山seo优化
  • 建设网站域名备案爱站网关键词挖掘查询工具