成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

配置Linux 內(nèi)核并利用iptables 做端口映射

運(yùn)維 系統(tǒng)運(yùn)維
iptables 是與最新的 2.6.x 版本Linux 內(nèi)核集成的 IP 信息包過(guò)濾系統(tǒng)。配置Linux 內(nèi)核后,我們應(yīng)該利用iptables 做端口映射,把映射做好就能正常工作了,本文講下他的具體流程!

配置Linux 內(nèi)核并利用iptables 做端口映射的具體工作如下:

  主機(jī) IP:192.168.1.100

  目標(biāo)機(jī) IP:192.168.2.101

  要求將到主機(jī) 192.168.1.100:11101 的請(qǐng)求映射到內(nèi)部網(wǎng)目標(biāo)機(jī)的 sshd 服務(wù)端口上,即:192.168.2.101:22。

  配置Linux內(nèi)核(以 2.6.18 為例)

  如果執(zhí)行 iptable -L 出現(xiàn)以下信息,那么就需要重新配置和編譯內(nèi)核:

  iptables v1.4.2: can't initialize iptables table `filter': Table does not exist (do you need to insmod?)

  Perhaps iptables or your kernel needs to be upgraded.

  配置選項(xiàng):

  Networking —->

  Networking options —->

  [*] Network packet filtering (replaces ipchains) —>

  Core Netfilter Configuration —>

  <*> Netfilter Xtables support (required for ip_tables)

  IP: Netfilter Configuration —>

  <*> Connection tracking (required for masq/NAT)

  <*> IP tables support (required for filtering/masq/NAT)

  <*> IP range match support

  <*> Packet filtering

  <*> REJECT target support

  <*> Full NAT

  以上配置只為端口映射準(zhǔn)備,如果需要其它功能,請(qǐng)根據(jù)需要增加相關(guān)的配置。

  編譯安裝內(nèi)核步驟略過(guò)。

  iptabes

  iptables 規(guī)則如下:

  iptables -t nat -A PREROUTING -p tcp –dport 11101 -d 192.168.1.100 -j DNAT –to-destination 192.168.2.101:22

#p#

  查看 iptables 規(guī)則定義:

  # iptables -t nat -L

  Chain PREROUTING (policy ACCEPT)

  target prot opt source destination

  DNAT tcp – anywhere 192.168.1.100 tcp dpt:11101 to:192.168.2.101:22

  Chain POSTROUTING (policy ACCEPT)

  target prot opt source destination

  Chain OUTPUT (policy ACCEPT)

  target prot opt source destination

  ip_forward

  除此之外,需要在主機(jī)上打開 ip 轉(zhuǎn)發(fā)以保持連接通道。

  查看是否已打開 ip 轉(zhuǎn)發(fā)(1 表示打開):

  cat /proc/sys/net/ipv4/ip_forward

  如果未打開,則用以下命令打開:

  echo 1 > /proc/sys/net/ipv4/ip_forward

  保存設(shè)置

  以上 iptables 設(shè)置和 ip 轉(zhuǎn)發(fā)設(shè)置在重啟系統(tǒng)之后就會(huì)消失,因此如果有需要,請(qǐng)將設(shè)置保存。

  保存 iptables 設(shè)置:

  /etc/init.d/iptables save

  設(shè)置系統(tǒng)啟動(dòng)時(shí)自動(dòng)加載 iptables 設(shè)置(以 gentoo 為例):

  rc-update add iptables default

  保存 ip_forward 設(shè)置(在 /etc/sysctl.conf 中設(shè)置):

  net.ipv4.ip_forward = 1

  安全隱患

  在打開了 ip_forward 后,一般要同時(shí)打開 rp_filter (Reverse Path filter),對(duì)數(shù)據(jù)包的源地址進(jìn)行檢查。

  如果在沒(méi)有打開這個(gè)設(shè)置,就很容易受到來(lái)自內(nèi)部網(wǎng)的 IP 欺騙。

  打開 rp_filter:

  for f in /proc/sys/net/ipv4/conf/*/rp_filter ; do echo 1 > $f ; done

  保存設(shè)置(在 /etc/sysctl.conf 中設(shè)置):

  net.ipv4.conf.default.rp_filter = 1

  net.ipv4.conf.all.rp_filter = 1

  測(cè)試

  ssh root@192.168.1.100 -p 11101

  看看是不是能夠連接到 192.168.2.101 主機(jī)上了?

通過(guò)上文的描述,我們清楚的知道了配置Linux內(nèi)核和利用iptables 做端口映射的具體過(guò)程,希望對(duì)大家有幫助!

【編輯推薦】

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

2011-03-16 13:09:10

iptables 端口

2011-03-16 10:43:36

2011-03-17 13:55:23

iptablesNAT端口映射

2011-03-16 13:29:33

iptables 端口

2009-09-16 08:49:29

linux端口映射linux端口linux

2011-03-16 12:55:00

iptables 端口

2013-06-07 17:25:46

路由技術(shù)路由器

2019-07-25 15:15:54

端口映射服務(wù)器

2021-08-17 00:02:11

LinuxWindows服務(wù)器

2020-11-19 10:35:19

LinuxWindows端口映射

2010-08-02 12:00:06

ADSL Modem端口映射

2009-12-11 17:33:10

2011-03-17 14:26:45

iptables 端口

2011-03-16 16:59:46

iptables 映射

2010-09-02 14:47:56

2011-03-14 14:40:10

2011-08-25 14:35:04

Nth端口映射ftp服務(wù)器

2011-03-17 10:11:13

2011-03-17 09:06:58

iptables映射端口

2009-12-15 15:50:22

路由器端口映射
點(diǎn)贊
收藏

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

主站蜘蛛池模板: 91av免费看| 中文福利视频 | 精品久久久久久亚洲精品 | 九九免费在线视频 | 亚洲一区二区三区四区五区中文 | 成人综合视频在线观看 | 99re视频| 天天爽天天操 | 亚洲精选久久 | 亚洲女人天堂成人av在线 | 在线不卡 | 一区二区av | 欧美精品福利 | 国产一级视频在线 | 日韩成人在线视频 | 国产三区精品 | 欧美日韩精品区 | 超碰在线免费公开 | 91社区在线观看 | 国产精品一区二区日韩 | 日韩午夜电影在线观看 | 国产免费一区二区 | 精品国产伦一区二区三区观看体验 | 日韩欧美一级片 | 男人天堂久久 | jlzzjlzz欧美大全 | 久久国产传媒 | 99热播精品 | 成人精品在线视频 | 午夜男人视频 | 国产精品久久 | 91视频大全 | 亚洲国产高清高潮精品美女 | 色橹橹欧美在线观看视频高清 | 一本色道久久综合亚洲精品高清 | 中文字幕第100页 | 中文字幕 在线观看 | 亚洲午夜精品视频 | av中文字幕在线观看 | 国产日韩一区 | 日本一区二区不卡 |