導航:首頁 > 操作系統 > linux雙網卡雙ip

linux雙網卡雙ip

發布時間:2023-09-19 21:01:50

『壹』 關於linux系統下設置雙網卡雙IP的問題!

ubuntu雙網卡雙IP.不同網關.不同子網.如何同時ping通兩塊網卡的解決方法,
伺服器環境如下:、
系統:Ubuntu 9.04 X64 server
電信IP(TEL):114.80.0.4 netmask 255.255.255.128 gateway 114.80.0.3
聯通IP(CNC):112.65.0.2 netmask 255.255.255.0 gateway 112.65.0.1
1.配置網卡信息
# vi /etc/network/interfaces
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
address 114.80.0.4
netmask 255.255.255.128
gateway 114.80.0.3
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 202.96.209.133
auto eth1
iface eth1 inet static
address 112.65.0.2
netmask 255.255.255.0
保存配置信息並重新啟動網卡
# /etc/init.d/networking restart
2.增加2個路由表分別是電信:tel 聯通:cnc
# vi /etc/iproute2/rt_tables
252 tel
251 cnc
保存並推出
3.增加路由規則
# ip route flush table tel
# ip route add default via 114.80.0.3 dev eth0 src 114.80.0.4 table tel
# ip ruleadd from 114.80.0.4 table tel
此處是設置電信的網關,並可實現讓電信的資源訪問只從eth0網卡出去
# ip route flush table cnc
# ip route add default via 112.65.0.1 dev eth1 src 112.65.0.2 table cnc
# ip rule add from 112.65.0.2 table cnc
此處是設置聯通的網關,並可實現讓聯通的資源訪問只從eth1網卡出去
4.配置networking啟動腳本文件 在結尾exit 0之前增加如下內容
# vi /etc/init.d/networking
ip route flush table tel
ip route add default via 114.80.0.3 dev eth0 src 114.80.0.4 table tel
ip rule add from 114.80.0.4 table tel
ip route flush table cnc
ip route add default via 112.65.0.1 dev eth1 src 112.65.0.2 table cnc
ip rule add from 112.65.0.2 table cnc
exit 0
5,退出並重啟網路
# /etc/init.d/networking restart
此時再測試機器網路情況,就會發現電信和聯通的地址都可以正常訪問了。此方法還可以實現讓從電信IP過來的請求按照電信路由返回,從網通IP過來的請求從網通路由返回。
補充:網上有些大神說如果伺服器重啟,或者網路服務重啟,上述的路由規則就失效了,所以你需要把上面這段命令寫入系統啟動腳本和網路啟動腳本
如果是ubuntu/debian,系統啟動腳本是/etc/rc.local
如果是RedHat/CentOS,系統啟動腳本是/etc/rc.d/rc.local
如果是ubuntu/debian,網路啟動腳本是/etc/init.d/networking
如果是RedHat/centos,網路啟動腳本是/etc/rc.d/init.d/network

『貳』 雙網卡雙ip linux系統,開放8080埠給其中一個網卡的ip通訊怎麼做

最快回答的那個說對了,我就不重復了。其實,在linux中如果是多網卡,就算你綁定了IP上的埠,比如綁定了192.168.1.11:8080,但是系統還配置了192.168.2.11,也可以從192.168.2.11:8080訪問,這個是通的。http協議的基礎東西。

『叄』 linux伺服器雙網卡雙IP,兩網卡要都能ping遠方某個IP地址

你試下你只給你的外網網卡配置網關,內網網卡不設置。

雙網關好像不行吧?!

閱讀全文

與linux雙網卡雙ip相關的資料

熱點內容
微光app主頁的愛心代表什麼意思 瀏覽:563
程序員和餃子做飯 瀏覽:307
美團app的點擊騎車在哪裡 瀏覽:723
程序員標配條件 瀏覽:211
免費電腦解壓app排行榜前十名 瀏覽:189
順序表查找演算法 瀏覽:463
整合包解壓後是亂碼 瀏覽:300
xp系統如何查找伺服器名 瀏覽:983
土的壓縮系數的確定方法 瀏覽:647
程序員家裡健身 瀏覽:620
電視看籃球app哪個好 瀏覽:47
高中畢業當程序員 瀏覽:245
php標簽屬性大全 瀏覽:897
遠程訪問伺服器ip地址 瀏覽:313
程序員吃雞蛋炒菜 瀏覽:174
在哪裡看俄羅斯電視劇app 瀏覽:308
怎麼找資料庫伺服器地址 瀏覽:487
伺服器調試怎麼翻譯 瀏覽:921
php如何處理ajax請求 瀏覽:211
php數組下標存在 瀏覽:707