中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

在Debian Linux中架設(shè)網(wǎng)關(guān)的詳細(xì)教程

2018-10-06    來(lái)源:愛(ài)站科技

容器云強(qiáng)勢(shì)上線!快速搭建集群,上萬(wàn)Linux鏡像隨意使用

  今天小編跟大家分享一篇關(guān)于在Debian Linux中架設(shè)網(wǎng)關(guān)的詳細(xì)教程,感興趣的朋友跟小編一起來(lái)了解一下吧!

  1、網(wǎng)關(guān)主機(jī)設(shè)置

  服務(wù)器上有兩塊網(wǎng)卡,eth0使用*.*.*.*IP地址連接Internet,eth1連接LAN,則其/etc/network/interfaces的設(shè)置如下:

  auto lo

  iface lo inet loopback

  auto eth0

  iface eth0 inetstatic address *.*.*.* netmask 255.255.255.0 gateway *.*.*.254

  auto eth1

  iface eth1 inet static

  address 192.168.0.1

  network 192.168.0.0

  netmask 255.255.255.0

  broadcast 192.168.0.255

  當(dāng)然也可以使用ifconfig進(jìn)行配置:

  $ ifconfig eth0 *.*.*.* netmask 255.255.255.0 $ route add default gw *.*.*.254 $ ifconfig eth1 192.168.0.1 netmask 255.255.255.0

  dns在/etc/resolv.conf中設(shè)置,修改或添加nameserver字段:

  nameserver 202.120.2.101

  如果ip地址是與mac綁定的,還要修改mac地址:

  $ ifconfig eth0 down $ ifconfig eth0 hw ether *:*:*:*:*:* $ ifconfig eth0 up

  這時(shí)將lan內(nèi)主機(jī)網(wǎng)關(guān)改為192.168.0.1,應(yīng)該能ping通該網(wǎng)關(guān),但是還是連不上internet。要實(shí)現(xiàn)LAN內(nèi)的機(jī)器通過(guò)共享一個(gè)單獨(dú)的可訪問(wèn)外網(wǎng)的IP地址來(lái)訪問(wèn)Internet資源,還需要在網(wǎng)關(guān)上安裝ipmasq。

  $ sudo apt-get install ipmasq

  會(huì)提示進(jìn)行一些設(shè)置,都默認(rèn)即可。之后lan內(nèi)主機(jī)應(yīng)該就能連上internet了。

  3、端口映射

  假設(shè)lan內(nèi)有一ftp192.168.0.2,要從internet上訪問(wèn)該ftp,需要在網(wǎng)關(guān)主機(jī)上進(jìn)行一定的端口映射?墒褂胕ptables完成。下面是具體實(shí)現(xiàn)的腳本例子:

  #!/bin/sh

  /sbin/modprobe iptable_filter

  /sbin/modprobe ip_tables

  /sbin/modprobe iptable_nat

  /sbin/modprobe ip_nat_ftp

  /sbin/modprobe ip_conntrack

  /sbin/modprobe ip_conntrack_ftp

  iptables -F

  iptables -P INPUT ACCEPT

  iptables -P FORWARD ACCEPT

  iptables -P OUTPUT ACCEPT

  iptables -F -t nat

  iptables -t nat -A PREROUTING -p tcp -i eth0 -d202.120.2.101--dport 21 -j DNAT --to192.168.123.6:21

  iptables -t nat -A PREROUTING -p tcp -i eth0 -d202.120.2.101 --dport 2345 -j DNAT --to192.168.123.116:3389

  iptables -t nat -A POSTROUTING -s 192.168.123.0/24 -o eth0 -j SNAT --to 202.120.16.34

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

  以上就是在Debian Linux中架設(shè)網(wǎng)關(guān)的詳細(xì)教程,想必都了解了吧,更多相關(guān)內(nèi)容請(qǐng)繼續(xù)關(guān)注愛(ài)站技術(shù)頻道。

標(biāo)簽: dns linux 服務(wù)器 腳本

版權(quán)申明:本站文章部分自網(wǎng)絡(luò),如有侵權(quán),請(qǐng)聯(lián)系:west999com@outlook.com
特別注意:本站所有轉(zhuǎn)載文章言論不代表本站觀點(diǎn)!
本站所提供的圖片等素材,版權(quán)歸原作者所有,如需使用,請(qǐng)與原作者聯(lián)系。

上一篇:Linux系統(tǒng)優(yōu)化和安全配置的深度解析

下一篇:在Linux下配置DNS的詳細(xì)解析