Redhat9+ADSL+IPTABLES+DHCPD解決方案(轉)
Redhat9+ADSL+IPTABLES+DHCPD解決方案(轉)[@more@]本解決方案要用到服務有 ppp0 , dhcp ,iptables ,squid (其中dhcp和squid可選擇不裝)最終實現目標: 伺服器redhat用adsl撥號上網,下面區域網的其他機器透過伺服器的iptables服務上網,並且基本上網服務都不受影響。如果你的客戶端比較多的話,可以選擇安裝squid服務,使客戶端訪問網頁速度快一點。當然如果你覺的你懶的去配置客戶端的TCP/IP設定,那你可以啟動DHCP服務。伺服器: redhat9.0 3com905b X 2 中興的ZXDSL831 北京網通ADSL線路(非包月)IP地址分配:redhat伺服器:eth0: 192.168.0.1 255.255.255.0 其他閘道器,dns等都不要配置(如圖),此網路卡用於連線區域網其他機器[myimg]upload/adslg1.png[/myimg]eht1: 192.168.1.2 255.255.255.0其他閘道器,dns等都不要配置(如圖),此網路卡用於ADSL撥號用,注意大家千萬不要設定成192.168.1.1,因為我的中興的ADSL有個預設的配置地址就是192.168.1.1[myimg]upload/adslg2.png[/myimg]以上我們伺服器的兩塊網路卡都是靜態設定,而不是大家常說的ADSL網路卡要設定成DHCP獲取地址。客戶端的IP地址設定我們這裡選擇DHCP獲取。如果你要靜態設定,那你可以設定成192.168.0.2-192.168.0.254之間的ip地址,子網掩碼都是255.255.255.0,閘道器都指向192.168.0.1,DNS指向192.168.0.1或者其他你知道的ISP的DNS地址好伺服器的網路卡基本配置完成,現在我們來配置adsl連線,網上有很多人說redhat的自ADSL有問題,可我配置卻沒有任何問題。我是直接用命令adsl-setup來配置輸入:adsl-setup 進入配置對話Welcome to the ADSL client setup. First, I will run some checks onyour system to make sure the PPPoE client is installed properly...The following DSL config was found on your system:Device: Name:ppp0 DSLppp0Please enter the device if you want to configure the present DSL config(default ppp0) or enter n if you want to create a new one: 建立的撥號連線名字,預設就行LOGIN NAMEEnter your Login Name (default ): 輸入ADSL賬號的登陸使用者名稱INTERFACEEnter the Ethernet interface connected to the ADSL modemFor Solaris, this is likely to be something like /dev/hme0.For Linux, it will be ethX, where X is a number.(default eth1): ADSL裝置所繫結的網路卡,我們這裡是eht1Do you want the link to come up on demand, or stay up continuously?If you want it to come up on demand, enter the idle time in secondsafter which the link should be dropped. If you want the link tostay up permanently, enter no (two letters, lower-case.)NOTE: Demand-activated links do not interact well with dynamic IPaddresses. You may have some problems with demand-activated links.Enter the demand value (default no): 預設就行DNSPlease enter the IP address of your ISPs primary DNS server.If your ISP claims that the server will provide dynamic DNS addresses,enter server (all lower-case) here. 注意這裡我們不要填寫任何DNS地址,後面我們會配置ADSL自動從ISP中獲取dns地址If you just press enter, I will assume you know what you aredoing and not modify your DNS setup.Enter the DNS information here:PASSWORDPlease enter your Password: 輸入ADSL賬號的密碼Please re-enter your Password: 密碼驗證USERCTRLPlease enter yes (two letters, lower-case.) if you want to allownormal user to start or stop DSL connection (default yes): 預設就行FIREWALLINGPlease choose the firewall rules to use. Note that these rules arevery basic. You are strongly encouraged to use a more sophisticatedfirewall setup; however, these will provide basic security. If youare running any servers on your machine, you must choose NONE andset up firewalling yourself. Otherwise, the firewall rules will denyaccess to all standard servers like Web, e-mail, ftp, etc. If youare using SSH, the rules will block outgoing SSH connections whichallocate a privileged source port.The firewall choices are:0 - NONE: This script will not set any firewall rules. You are responsiblefor ensuring the security of your machine. You are STRONGLYrecommended to use some kind of firewall rules.1 - STANDALONE: Appropriate for a basic stand-alone web-surfing workstation2 - MASQUERADE: Appropriate for a machine acting as an Internet gatewayfor a LANChoose a type of firewall (0-2): 由於我們要在後面使用iptables,所以選擇2Start this connection at boot timeDo you want to start this connection at boot time?Please enter no or yes (default no): 我這裡不是包月,所以選擇no,如果你是包月的話就選yes** Summary of what you entered **Ethernet Interface: eth1User name: usernameActivate-on-demand: NoDNS: Do not adjustFirewalling: MASQUERADEUser Control: yesAccept these settings and adjust configuration files (y/n)? 選擇yes,儲存設定.用adslsetup命令配置好ppp0後,我們在Xwindows下看一下ppp0的配置[myimg]upload/adslg3.png[/myimg]注意這裡我們把自動從提供商處獲取DNS資訊選上,這部非常關鍵,否則到後面即使客戶端能上網,本地伺服器也看不了網頁。好了到此位置,adsl配置完成,我們用命令adsl-start來啟用ADSL連線基本如果你能ping通外面的IP地址就行了,最多再用nslookup命令來測試一下DNS是否正常。只有在確認ADSL連線沒問題後,我們才來配置iptables.修改/etc/sysconfig/iptables(把原有的內容都刪除),修改完如下# Firewall configuration written by lokkit# Manual customization of this file is not recommended.# Note: ifup-post will punch the current nameservers through the# firewall; such entries will *not* be listed here.*mangle:PREROUTING ACCEPT [0:0]:INPUT ACCEPT [0:0]:FORWARD ACCEPT [0:0]:OUTPUT ACCEPT [0:0]:POSTROUTING ACCEPT [0:0]*nat:PREROUTING ACCEPT [0:0]:POSTROUTING ACCEPT [0:0]:OUTPUT ACCEPT [0:0][0:0]-A POSTROUTING -o ppp0 -j MASQUERADECOMMIT*filter:INPUT ACCEPT [0:0]:FORWARD ACCEPT [0:0]:OUTPUT ACCEPT [0:0]COMMIT修改/etc/sysctl.conf,把net.ipv4.ip_forward設定成1,如下:net.ipv4.ip_forward = 1如此一來,每次你重新啟動機器或重新啟動網路服務(/etc/init.d/network restart)時就會自動啟動ip轉發功能!重起iptables服務:/etc/rc.d/init.d/iptables restartiptables -t nat -L -n 看代理規則是否正確,結果如下:[root@localhost root]# iptables -t nat -L -nChain PREROUTING (policy ACCEPT)target prot opt source destinationChain POSTROUTING (policy ACCEPT)target prot opt source destinationMASQUERADE all -- 0.0.0.0/0 0.0.0.0/0Chain OUTPUT (policy ACCEPT)target prot opt source destinationcat /proc/sys/net/ipv4/ip_forward 看值是否為1,結果如下:[root@localhost root]$ cat /proc/sys/net/ipv4/ip_forward1其實到現在如果你的客戶段是靜態設定ip地址,現在就可以透過伺服器共享上網了,如果你還要配置DHCP伺服器的話,修改/etc/dhcpd.conf#Start of /etc/dhcpd.confddns-update-style interim;ignore client-updates;subnet 192.168.0.0 netmask 255.255.255.0 {# --- default gatewayoption routers 192.168.0.1;option subnet-mask 255.255.255.0;# --- option domain-name-servers ISPs DNS1,ISPs DNS2;option domain-name-servers 192.168.0.1,202.106.0.20,202.106.148.1;option time-offset -18000; # Eastern Standard Time# --- Selects point-to-point node (default is hybrid). Dont change this unless# -- you understand Netbios very well# option netbios-node-type 2;range dynamic-bootp 192.168.0.2 192.168.0.254;default-lease-time 21600;max-lease-time 43200;}#End of /etc/dhcpd.conf關於squid的配置我就不講了,非常簡單哦,只不過在配置過程中需要主要配置dns地址。預設使沒有的,否則你在adsl沒連線的情況下,squid是啟動不了的,可參考dhcpd.conf的dns地址。好了,redhat伺服器reboot後,所有windows客戶端ipconfig/renew一下幸地址,伺服器adsl-start後,一切都ok!什麼時候想停止上網,只要在伺服器端輸入以下命令adsl-stop就可以
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8225414/viewspace-940747/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 視訊轉碼解決方案
- iOS螢幕旋轉解決方案iOS
- 銀行數字化轉型解決方案
- 食品行業數字化轉型解決方案行業
- 解決方案| anyRTC金融音視訊解決方案
- 玩轉dnmp之埠對映問題解決方案
- MRO工業品數字化轉型解決方案
- 服裝行業數字化轉型解決方案行業
- 大資管行業數字化轉型解決方案 | 行業方案行業
- UnexpectedRollbackException解決方案Exception
- 資料庫容災、複製解決方案全分析(轉)資料庫
- 高併發解決方案詳解(9大常見解決方案)
- 阿里巴巴開源分散式事務解決方案 FESCAR【轉】阿里分散式
- 【轉】 android獲取裝置唯一標識完美解決方案Android
- 加工行業數字化轉型解決方案-數商雲行業
- 數商雲工程行業數智化轉型解決方案行業
- 高可用解決方案
- Redis bigkey解決方案Redis
- 前端整合解決方案前端
- Feast on Amazon 解決方案AST
- 技術創新助力數字轉型|綠盟科技兩款解決方案獲評2021年度解決方案之星
- minikube配置代理:解決方案以及解決思路
- 智慧停車場解決方案,反向尋車系統解決方案
- 綠盟一體化安全運營解決方案榮獲“2021年度數字化轉型優秀解決方案獎”
- echarts圖表X軸文字過長解決解決方案:根據文字長度自動旋轉Echarts
- [轉]Android Studio匯入工程報錯 Error:Cause: peer not authenticated 解決方案AndroidError
- 穩穩的數字化轉型!華為雲SAP解決方案
- html轉PDF檔案,完美解決方案——jsPDF,htmltocanvas,pdfmake,wkhtmltopdf,TuesPechkin,snappyHTMLJSCanvasAPP
- 海信推出SAP零售業解決方案Hisense-SAP Retail(轉)AI
- 數商雲服裝行業數智化轉型解決方案行業
- 一種中文數字轉阿拉伯數字的解決方案
- mysql Index column size too large 超過767錯誤解決方案(轉)MySqlIndex
- 跨域問題,解決方案 – CORS方案跨域CORS
- ROS意外崩掉解決方案ROS
- JEESZ-SSO解決方案
- nodejs微服務解決方案NodeJS微服務
- 前端圖片解決方案前端
- javascript非同步解決方案JavaScript非同步
- 智慧農業解決方案