自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

iptables 與 asterisk

運(yùn)維 系統(tǒng)運(yùn)維
iptables 是與最新的 2.6.x 版本Linux 內(nèi)核集成的 IP 信息包過(guò)濾系統(tǒng)。上篇我給大家講了iptables下開(kāi)放ftp連接,本文為大家講下iptables 與 asterisk 的故事。

iptables asterisk

  iptables fo asterisk

  SIP on UDP port 5060. Other SIP servers may need TCP port 5060 as well

  iptables -A INPUT -p udp -m udp—dport 5004:5082 -j ACCEPT

  IAX2 - the IAX protocol

  iptables -A INPUT -p udp -m udp—dport 4569 -j ACCEPT

  IAX – most have switched to IAX v2, or ought to

  iptables -A INPUT -p udp -m udp—dport 5036 -j ACCEPT

  RTP – the media stream

  iptables -A INPUT -p udp -m udp—dport 10000:20000 -j ACCEPT

  MGCP – if you use media gateway control protocol in your configuration

  iptables -A INPUT -p udp -m udp—dport 2727 -j ACCEPT

  參考:http://www.voip-info.org/wiki-Asterisk+firewall+rules

#p#

  iptables 詳解

  iptables—version來(lái)查看系統(tǒng)是否安裝了iptables

  iptables -help來(lái)查看一個(gè)快速幫助

  man iptables來(lái)查看所有命令和選項(xiàng)的完整介紹

  iptables—list 查看系統(tǒng)中現(xiàn)有的iptables規(guī)劃集

  一般語(yǔ)法如下:

  iptables [-t table] command [match] [target]

  table

  filter用于一般的信息包過(guò)濾,包含INPUT,OUTPUT和FORWARD鏈。nat用于要轉(zhuǎn)發(fā)的信息包。

  command

  command部分是iptables命令最重要的部分。它告訴iptables命令要做什么,例如插入規(guī)則、將規(guī)則添加到鏈的末尾或刪除規(guī)則。

  -A 或—append:將一條規(guī)則附加到鏈的末尾。如 iptables -A INPUT -s 210.12.1.23 -j ACCEPT (接受來(lái)自源210.12.1.23地?cái)?shù)據(jù)包)

  - D 或—delete:從鏈中刪除規(guī)則。如iptables -D INPUT —dport 80 -j DROP (丟棄前往端口80的包);iptalbes -D OUTPUT 3 (刪除鏈編號(hào)為3的規(guī)則)

  -P 或—policy,設(shè)置鏈的缺少策略(處理與其它規(guī)則不匹配的包)。如iptables -P INPUT DROP (丟棄與所有規(guī)則都不匹配的包)

  -N 或—new-chain:用指定名稱(chēng)創(chuàng)建一個(gè)新鏈。如iptables -N alowed-chain

  - F 或—flush:刪除指定鏈或所有鏈(未指定名稱(chēng)時(shí))。如iptables -F FORWARD 或iptables -F

  -L 或—list,列出鏈中的所有規(guī)則。如iptables -L allowed-chain

  match

  iptables命令的可選match部分指定信息包與規(guī)則匹配所應(yīng)具有的特征(如源地址、目的地址、協(xié)議等)。

  -p 或—protocal:檢查特定協(xié)議(TCP、UDP、ICMP、ALL),可用!表示非。如iptables -A INPUT -p TCP ,UDP或iptables -A INPUT -p !ICMP,兩條命令作用一樣。

  -s 或—source:根據(jù)信息的源IP來(lái)匹配。如iptables -A OUTPUT -s 192.168.1.1,iptables -A OUTPUT -s 192.168.0.0/24(從0.0到0.24),iptables -A OUTPUT -s !203.16.1.89

  -d 或—destination,根據(jù)目標(biāo)IP來(lái)匹配。如 iptables -A INPUT -d 192.168.1.1

  target

  目標(biāo)是由規(guī)則指定的操作,對(duì)與那些規(guī)則匹配的信息包執(zhí)行這些操作。除了允許用戶定義的目標(biāo)之外,還有許多可用的目標(biāo)選項(xiàng)。

  ACCEPT , DROP, REJECT , RETURN

  示例

  本例中的規(guī)則將會(huì)阻止來(lái)自某一特定IP范圍內(nèi)的數(shù)據(jù)包,因?yàn)樵揑P地址范圍被管理員懷疑有大量惡意攻擊者在活動(dòng):

  iptables -t filter -A INPUT -s 123.456.789.0/24 -j DROP

  也可以很輕易地阻止所有流向攻擊者IP地址的數(shù)據(jù)包,該命令稍有不同:

  iptables -t filter -A OUTPUT -d 123.456.789.0/24 -j DROP

  為每一個(gè)鏈設(shè)置缺省的規(guī)則:

  iptables -P INPUT DROP

  iptables -P FORWARD DROP

  iptables -P OUTPUT ACCEPT 這里選項(xiàng)-P用于設(shè)置鏈的策略,只有三個(gè)內(nèi)建的鏈才有策略。這些策略可以讓信息毫無(wú)限制地流出,但不允許信息流入。

  允許來(lái)自網(wǎng)絡(luò)接口ppp0(internet接口),并且來(lái)源端口是80的數(shù)據(jù)進(jìn)入你的計(jì)算機(jī)

  iptables -A INPUT -i ppp0 -p tcp—sport 80 -j ACCEPT

  要提供www服務(wù)

  iptables -A INPUT -i ppp0 -p tcp—dport 80 -j ACCEPT

  阻止所有沒(méi)有經(jīng)過(guò)你系統(tǒng)授權(quán)的TCP連接:

  iptables -t filter -A INPUT -i eth0 -p tcp—syn -j DROP 這里的-i指的是網(wǎng)卡,-p則是指協(xié)議,—syn則表示帶有syn標(biāo)識(shí)設(shè)置的TCP數(shù)據(jù)包。SYN用于初始化一個(gè)TCP連接,如果自己機(jī)器上沒(méi)有運(yùn)行任何服務(wù)器,別人也就不會(huì)向你發(fā)送SYN數(shù)據(jù)包。

  規(guī)則的保存與恢復(fù)

  iptables-save > iptables-script

  iptables-restore iptables-script

通過(guò)文章,我們知道了iptables 和 asterisk,希望本文對(duì)大家有所幫助!

【編輯推薦】

責(zé)任編輯:趙鵬 來(lái)源: 網(wǎng)絡(luò)轉(zhuǎn)載
相關(guān)推薦

2011-03-15 13:39:14

iptablesstun

2011-03-17 15:32:25

2011-03-15 15:47:25

iptables安裝命令

2011-03-15 11:05:03

2010-01-04 14:44:23

Ubuntu Aste

2011-03-15 09:10:42

Linux防火墻Iptables

2011-03-15 17:25:38

2011-03-17 17:19:24

iptables

2011-03-18 09:26:13

Iptables規(guī)則

2011-03-15 09:59:59

iptables實(shí)例

2021-10-13 16:00:53

KubeProxyIptables

2011-03-16 11:17:56

IptablesICMP

2011-03-15 16:26:46

iptablesnat

2011-03-15 16:34:36

Iptables性能

2011-03-17 17:45:45

iptables規(guī)則

2011-03-15 14:01:13

2011-03-15 09:46:31

2011-03-14 14:40:11

iptables編譯

2011-03-15 14:50:03

使用IPTables

2011-03-15 15:06:27

iptables腳本
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)