-
iptables規(guī)則中SNAT規(guī)則設(shè)置(下)
netstat -luntp | grep 80
ip addr????#查看網(wǎng)關(guān)服務(wù)器上的兩張網(wǎng)卡,在這臺服務(wù)器上做NAT;
vim /etc/sysctl.conf????#數(shù)據(jù)包轉(zhuǎn)發(fā)需打開內(nèi)核的參數(shù);
????net.ipv4.ip_forward = 0????改為1;
????sysctl -p????#讓配置全部執(zhí)行;
????sysctl -a | grep ip_forward????#查看是生效;
iptables -t nat -A POSTROUTING -s 10.10.177.0/24 -j SNAT --to 10.10.188.232? ? #制定轉(zhuǎn)發(fā)規(guī)則;
iptables -t nat -L????#查看nat表內(nèi)容
netstat -rn????#在客戶端pc上查看當(dāng)前路由表;
route add 0.0.0.0 gw 10.10.177.232? ? #在客戶端pc上加入路由;
curl http://101.101.101.101/xxxxx/????#進(jìn)行測試;
查看全部 -
iptables -I INPUT -i lo -j ACCEPT????#允許本地回環(huán)地址訪問;
iptables -I INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -s 192.168.235.0/24 -j ACCEPT
iptables -A INPUT -s 192.168.8.0/24 -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 1723 -j ACCEPT????#VPN端口;
iptables -I INPUT -p icmp -j ACCEPT
iptables -A INPUT -j REJECT
service iptables save????#讓配置的防火墻策略永久生效
vi /etc/sysconfig/iptables
查看全部 -
1、公司內(nèi)部(192.168.6.0/24、192.168.8.0/24)能訪問服務(wù)器上的任何服務(wù);
2、員工出差,通過撥號連到公司VPN,再連接公司內(nèi)網(wǎng)FTP、SAMBA、NFS、SSH;
3、公司網(wǎng)站允許公網(wǎng)訪問;
查看全部 -
iptables -I INPUT -p tcp -s 192.168.235.1 --dport 80 -j ACCEPT????#只允許主機(jī)192.168.235.1訪問服務(wù)器80服務(wù);
查看全部 -
iptables -I INPUT -i lo -j ACCEPT????#允許本機(jī)telnet訪問本機(jī);
iptables -I INPUT -m state --state ESTABLISHED -j ACCEPT????#允許本機(jī)訪問其它主機(jī);
查看全部 -
netstat -luntp????#查看當(dāng)前開放的端口;
iptables -V? ? #查看iptables版本;
iptables -L? ? #列出已有規(guī)則;
iptables -nL? ? #列出已有規(guī)則;
????-n????讓主機(jī)名等不顯示;
iptables -I? ? #在第一列插入一條規(guī)則;
iptables -A? ? #在最后一列添加一條規(guī)則;
iptables -F? ? #清除已有規(guī)則;
iptables -I INPUT -p tcp --dport 22 -j ACCEPT????#允許所有地址訪問22端口;
iptables -I INPUT -p tcp --dport 80 -j ACCEPT? ? #允許所有地址訪問80端口;
iptables -D INPUT -p tcp --dport 80 -j ACCEPT? ? #刪除允許所有地址訪問80端口;
iptables -I INPUT -p tcp --dport 10:21 -j ACCEPT????#允許所有地址訪問10到21端口;
iptables -I INPUT -p icmp -j ACCEPT????#允許所有地址基于ICMP協(xié)議的數(shù)據(jù)包訪問;
iptables -A INPUT -j REJECT????#其它未被允許端口則禁止訪問;
netstat -lntp
iptables -nL
查看全部 -
iptables規(guī)則組成
數(shù)據(jù)包訪問控制:accept(接收允許通過)、drop(丟棄)、reject(丟棄并反饋)
數(shù)據(jù)包改寫:snat(對源地址改寫)、dnat(對目的地址改寫)
信息記錄:log(日志)
查看全部 -
iptables規(guī)則組成:四張表+五條鏈(Hook point)+規(guī)則
四張表:filter表、nat表、managle表、raw表;
五條鏈:input、output、forward、prerouting、postrouting
查看全部 -
netfilter是由Rusty Russell提出的Linux 2.4內(nèi)核防火墻框架,該框架既簡潔又靈活,可實(shí)現(xiàn)安全策略應(yīng)用中的許多功能,如數(shù)據(jù)包過濾、數(shù)據(jù)包處理、地址偽裝、透明代理、動(dòng)態(tài)網(wǎng)絡(luò)地址轉(zhuǎn)換(Network Address?Translation,NAT),以及基于用戶及媒體訪問控制(Media Access Control,MAC)地址的過濾和基于狀態(tài)的過濾、包速率限制等。
查看全部 -
iptables????#Linux系統(tǒng)下的應(yīng)用層防火墻工具。
查看全部 -
http 80 ?pop3 110 ?smtp 25
查看全部 -
iptables -I FORWARD -p udp --dport 53 -m string --string "tencent" -m time --timestart 8:15 --timestop 12:30 --days Mon,Tue, Wed, Thu, Fri, Sat -j DROP # 工作時(shí)間禁止聊qq
iptables清理工作 /bin/sh modprobe ipt_MASQUERADE modprobe ip_conntrack_ftp modprobe ip_nat_ftp iptables -F
防止SYN攻擊訪問限制 iptables -N syn-flood iptables -A INPUT -p tcp --syn -j syn-flood iptables -I syn-flood -p tcp -m limit --limit 3/s --limit-burst 6 -j RETURN iptables -A syn-flood -j REJECT
查看全部 -
iptables -F
iptables -I INPUT -i lo -j ACCEPT允許本地訪問
iptables -I INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT允許對外訪問
iptables -A INPUT -s 10.10.155.0/24 -j ACCEPT允許155網(wǎng)端的訪問我的服務(wù)
iptables -A INPUT -s 10.10.188.0/24 -j ACCEPT
iptables -A INPUT -s 10.10.140.0/24 -j ACCEPT允許本機(jī)訪問
iptables -A INPUT -p tcp --dport 80 -j ACCEPT允許所有機(jī)器訪問80端口
iptables -A INPUT -p tcp --dport 1723 -j ACCEPT常用vpn的接口都是1723
iptables -I INPUT -p icmp -j ACCEPT icmp允許訪問
iptables -A INPUT -j REJECT 其他的都拒絕
/etc/init.d/iptables save 保存設(shè)置
chkconfig iptables on 設(shè)置為開機(jī)啟動(dòng)
chkconfig --list|grep iptables 跟隨系統(tǒng)
查看全部 -
iptables -I INPUT -p tcp -s 10.10.188.233 --dport 80 -j ACCEPT允許ip為10.10.188.233的主機(jī)訪問80端口
查看全部 -
對本地的網(wǎng)卡設(shè)備允許訪問
iptables -I INPUT -i lo -j ACCEPT允許對lo過來的數(shù)據(jù)包
iptables -I INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT對外訪問時(shí),如果ftp的狀態(tài)為established和related時(shí)允許訪問
查看全部
舉報(bào)