linux iptables 相關應用

iptables 規則應用:
防火牆端口重定向:
iptables -t nat -I PREROUTING -i eth1  -p tcp --dport 80 -j REDIRECT --to 8080
反向代理防火牆規則:
iptables -I INPUT  -d 123.125.168.130 -i eth0 -p tcp  --dport 80 -j ACCEPT
#iptables -I INPUT -s 10.10.10.0/24 -i eth1 -p tcp  --sport 9999 -j ACCEPT
# 此包爲input狀態檢測可省略
iptables -I OUTPUT -p tcp -o eth1 -s 10.10.10.1  -d 10.10.10.10 --dport 9999  -j ACCEPT
iptables -I OUTPUT -p tcp -o eth0 -s 123.125.168.130  --sport 80 -j ACCEPT
目標地址轉換:
iptables -t nat -I PREROUTING -i eth0 -d 123.125.168.130  -p tcp --dport 80 -j DNAT \
>  --to 10.10.10.10:9999
iptables -A FORWARD -d 10.10.10.10 -p tcp  --dport 9999 -j ACCEPT
iptables -A FORWARD -s 10.10.10.10 -p tcp  --sport 9999 -j ACCEPT
如果10.10.10.10機器默認網關不是10.10.10.1或沒有指網關,則網關防火牆需如下:有點奇怪的規則
iptables -t nat -I POSTROUTING -d 10.10.10.10 -p tcp --dport 9999 -j SNAT --to 10.10.10.1
源地址轉換:
iptables -t nat -I POSTROUTING -s  10.10.10.0/24 -o eth0 -j SNAT --to 123.125.168.130
iptables -t nat -I POSTROUTING -s  10.10.10.0/24 -o eth0 -j MASQUERADE 
# 此條開銷較大,與上條可二選一
iptables  -I FORWARD -s 10.10.10.0/24 -j ACCEPT  注:forward不指網卡,要指也是內網卡
iptables  -I FORWARD -d 10.10.10.0/24 -j ACCEPT
額外:
use  glance;
show variables like '%char%';       查看整個mysql字符集
show create table migrate_version;  查看錶字符集
alter table migrate_version character set utf8;  設置表字符集或者如下條:
alter table migrate_version default character set utf8 collate utf8_general_ci;
curl http://localhost
elinks -dump http://localhost
tcpdump -nn -i eth1 tcp port 80


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章