我配置虛擬ip位址的目的是為了實現高可用性,那是後話,先看看ubuntu12.04下如何設定虛擬ip位址。
首先看一下我的ubuntu的ip:
[plain]
chenshu@sloop2:~$ ifconfig
eth0 link encap:ethernet hwaddr d0:67:e5:ef:5a:6e
inet addr:10.112.18.158 bcast:10.112.18.255 mask:255.255.255.0
inet6 addr: fe80::d267:e5ff:feef:5a6e/64 scope:link
up broadcast running multicast mtu:1500 metric:1
rx packets:341661 errors:0 dropped:0 overruns:0 frame:0
tx packets:242801 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
rx bytes:328287656 (328.2 mb) tx bytes:31858367 (31.8 mb)
interrupt:17
lo link encap:local loopback
inet addr:127.0.0.1 mask:255.0.0.0
inet6 addr: ::1/128 scope:host
up loopback running mtu:16436 metric:1
rx packets:17904 errors:0 dropped:0 overruns:0 frame:0
tx packets:17904 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
rx bytes:2160236 (2.1 mb) tx bytes:2160236 (2.1 mb)
ping一下191,發現網路中沒有,就用它做虛擬ip吧。
sudo -s之後,執行下面的命令,
[plain]
ifconfig eth0:0 10.112.18.191 netmask 255.255.255.0 up
確保虛擬ip位址和本機ip位址在乙個網段。
再來看一下是否成功:
[plain]
ifconfig
eth0 link encap:ethernet hwaddr d0:67:e5:ef:5a:6e
inet addr:10.112.18.158 bcast:10.112.18.255 mask:255.255.255.0
inet6 addr: fe80::d267:e5ff:feef:5a6e/64 scope:link
up broadcast running multicast mtu:1500 metric:1
rx packets:347634 errors:0 dropped:0 overruns:0 frame:0
tx packets:246488 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
rx bytes:335797145 (335.7 mb) tx bytes:32178089 (32.1 mb)
interrupt:17
eth0:0 link encap:ethernet hwaddr d0:67:e5:ef:5a:6e
inet addr:10.112.18.191 bcast:10.112.18.255 mask:255.255.255.0
up broadcast running multicast mtu:1500 metric:1
interrupt:17
lo link encap:local loopback
inet addr:127.0.0.1 mask:255.0.0.0
inet6 addr: ::1/128 scope:host
up loopback running mtu:16436 metric:1
rx packets:17953 errors:0 dropped:0 overruns:0 frame:0
tx packets:17953 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
rx bytes:2164072 (2.1 mb) tx bytes:2164072 (2.1 mb)
本機測試:
[plain]
ping 10.112.18.191
ping 10.112.18.191 (10.112.18.191) 56(84) bytes of data.
64 bytes from 10.112.18.191: icmp_req=1 ttl=64 time=0.028 ms
換台機器測試:
[plain]
edward@edward-catamaran:~$ ping 10.112.18.191
ping 10.112.18.191 (10.112.18.191) 56(84) bytes of data.
64 bytes from 10.112.18.191: icmp_req=1 ttl=64 time=0.916 ms
64 bytes from 10.112.18.191: icmp_req=2 ttl=64 time=0.258 ms
刪除虛擬ip的方法。
ifconfig eth0:0 down
後面還要做什麼?當然是儲存配置,保證重啟後虛擬ip也還在。
直接在/etc/network/inte***ces檔案中新增:
[plain]
懾甀琀漀 lo
iface lo inet loopback
auto eth0:0
iface eth0:0 inet static
name ethernet alias lan card
address 10.112.18.191
netmask 255.255.255.0
broadcast 10.112.18.255
network 10.112.18.0
重新啟動網路服務。
/etc/init.d/networking restart
-
Vmware下Ubuntu16 04網路配置
1.編輯配置檔案 sudo vi etc network inte ces 2.修改配置檔案中引數值,以自身情況填寫 auto eth0 iface eth0 inet static address 192.168.123.34 靜態的ip位址 netmask 255.255.255.0 子網掩碼 ...
ubuntu 安裝mysql server配置
ubuntu 安裝mysql server 的安裝和配置步驟如下 1.安裝 mysql server命令 sudo apt get install mysql server2.等待安裝完後,接下來開始配置 2 其他機器訪問 mysql 配置 a.sudo vim etc mysql.my.cnf 找...
virtualbox下安裝ubuntu配置總結
安裝virtualbox和和ubuntu的過程就不說了,安裝了ubuntu後,有幾個問題要解決 1 沒有root賬戶 2 語言環境,預設為中文 3 alt ctrl f1切換不到命令列介面 4 virtualbox下ubuntu的解析度設定 對於第乙個問題,通過以下解決 sudo passwd ro...