當前位置:首頁 » 雲伺服器 » ubuntu伺服器採集多IP段

ubuntu伺服器採集多IP段

發布時間: 2024-05-29 03:40:35

⑴ 如何給Ubuntu網站綁定多個IP,怎麼給Ubuntu伺服器設置多IP

多個不同IP段的 /etc/network/interfaces 配置文件的範例如下:
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
address 8.8.8.2
netmask 255.255.255.248
gateway 8.8.8.1 要注意這里,多個不同IP段,只要1個gateway配置即可,其他IP不需要配置gateway

auto eth0:0
iface eth0:0 inet static
address 8.8.8.3
netmask 255.255.255.248

auto eth0:1
iface eth0:1 inet static
address 8.8.8.4
netmask 255.255.255.248

auto eth0:2
iface eth0:2 inet static
address 8.8.8.5
netmask 255.255.255.248

auto eth0:3
iface eth0:3 inet static
address 8.8.8.6
netmask 255.255.255.248

auto eth0:4
iface eth0:4 inet static
address 6.6.6.130 注意這里,雖然這是不同的IP段,但是不需要配置gateway,只需要配置netmask即可
netmask 255.255.255.224

auto eth0:5
iface eth0:5 inet static
address 6.6.6.131
netmask 255.255.255.224

更多ip也類似配置即可。
配置文件完成後,用命令 /etc/init.d/networking restart 重啟網路,不需要reboot重啟伺服器。 /etc/init.d/networking restart 重啟網路的時候,如果你的配置文件有錯誤,那麼他會提示你。比如IP重復了,書寫錯誤了,等等。在執行此命令前,一定要小心檢查interfaces配置文件,不然可能就把網路弄癱瘓,那時候就需要機房的工作人員去處理,十分麻煩。

/etc/init.d/networking restart錯誤分析案例:
[email protected]:/etc/network# /etc/init.d/networking restart
* Reconfiguring network interfaces...
/etc/network/interfaces:165: interface eth0:28 declared allow-auto twice
ifdown: couldn't read interfaces file "/etc/network/interfaces"
/etc/network/interfaces:165: interface eth0:28 declared allow-auto twice
ifup: couldn't read interfaces file "/etc/network/interfaces"
...fail!

說明eth0:28有重復,解決辦法:vi interfaces找到eth0:28,刪除掉重復的

[email protected]:/etc/network# /etc/init.d/networking restart
* Reconfiguring network interfaces...
/etc/network/interfaces:166: plicate interface
ifdown: couldn't read interfaces file "/etc/network/interfaces"
/etc/network/interfaces:166: plicate interface
ifup: couldn't read interfaces file "/etc/network/interfaces"
...fail!

說明166行有重復,解決辦法:vi interfaces找到166行(set number),刪除掉重復的

[email protected]:/etc/network# /etc/init.d/networking restart
* Reconfiguring network interfaces...
/etc/network/interfaces:162: plicate interface
ifdown: couldn't read interfaces file "/etc/network/interfaces"
/etc/network/interfaces:162: plicate interface
ifup: couldn't read interfaces file "/etc/network/interfaces"

說明162行有重復,解決辦法:vi interfaces找到166行(set number),刪除掉重復的

熱點內容
java返回this 發布:2025-10-20 08:28:16 瀏覽:645
製作腳本網站 發布:2025-10-20 08:17:34 瀏覽:936
python中的init方法 發布:2025-10-20 08:17:33 瀏覽:632
圖案密碼什麼意思 發布:2025-10-20 08:16:56 瀏覽:821
怎麼清理微信視頻緩存 發布:2025-10-20 08:12:37 瀏覽:731
c語言編譯器怎麼看執行過程 發布:2025-10-20 08:00:32 瀏覽:1066
郵箱如何填寫發信伺服器 發布:2025-10-20 07:45:27 瀏覽:299
shell腳本入門案例 發布:2025-10-20 07:44:45 瀏覽:160
怎麼上傳照片瀏覽上傳 發布:2025-10-20 07:44:03 瀏覽:852
python股票數據獲取 發布:2025-10-20 07:39:44 瀏覽:763