Azure的每個VM都有多種IP地址,包括DIP、VIP和PIP。具體如下:
DIP地址是在VM裡能夠看到的IP地址,即私網地址;PIP地址是這個VM關聯的公網IP地址,即公網地址;VIP地址是負載均衡的地址。
目前Azure的VM已經支援每個網路卡關聯多個ipconfig,即可以支援VM的每個網路卡關聯多個私網和公網地址:DIP和PIP。
如下圖:
具體配置如下:
1. VM種NIC的ipconfig
2. 新增ipconfig
點選新增後:
按相同的方法再新增第三個ipconfig,配置完後的配置結果:
3. VM內的配置(CentOS7)
登入到VM中,做如下修改:
[root@hwvntp01 init.d]# cd /etc/sysconfig/network-scripts/ [root@hwvntp01 network-scripts]# vim ifcfg-eth0:0 DEVICE=eth0:0 ONBOOT=yes BOOTPROTO=static IPADDR=10.3.1.6 NETMASK=255.255.255.0 [root@hwvntp01 network-scripts]# vim ifcfg-eth0:1 DEVICE=eth0:1 ONBOOT=yes BOOTPROTO=static IPADDR=10.3.1.7 NETMASK=255.255.255.0
然後重啟Network的服務:
[root@hwvntp01 network-scripts]# cd /etc/init.d
[root@hwvntp01 init.d]# ./network restart
4. 檢驗
[root@hwvntp01 html]# ifconfig eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 10.3.1.5 netmask 255.255.255.0 broadcast 10.3.1.255 inet6 fe80::217:faff:fe00:40f2 prefixlen 64 scopeid 0x20<link> ether 00:17:fa:00:40:f2 txqueuelen 1000 (Ethernet) RX packets 250659 bytes 131605494 (125.5 MiB) RX errors 0 dropped 1 overruns 0 frame 0 TX packets 302252 bytes 48623564 (46.3 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 eth0:0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 10.3.1.6 netmask 255.255.255.0 broadcast 10.3.1.255 ether 00:17:fa:00:40:f2 txqueuelen 1000 (Ethernet) eth0:1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 10.3.1.7 netmask 255.255.255.0 broadcast 10.3.1.255 ether 00:17:fa:00:40:f2 txqueuelen 1000 (Ethernet) lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 1 (Local Loopback) RX packets 10 bytes 1078 (1.0 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 10 bytes 1078 (1.0 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 [root@hwvntp01 html]# ping www.sina.com.cn PING ara.sina.com.cn (121.14.1.190) 56(84) bytes of data. 64 bytes from 121.14.1.190 (121.14.1.190): icmp_seq=1 ttl=51 time=45.7 ms 64 bytes from 121.14.1.190 (121.14.1.190): icmp_seq=2 ttl=51 time=45.7 ms ^C --- ara.sina.com.cn ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 1001ms rtt min/avg/max/mdev = 45.710/45.716/45.723/0.213 ms [root@hwvntp01 html]# ping -I 10.3.1.6 www.sina.com.cn PING ara.sina.com.cn (121.14.1.190) from 10.3.1.6 : 56(84) bytes of data. 64 bytes from 121.14.1.190 (121.14.1.190): icmp_seq=1 ttl=53 time=48.4 ms 64 bytes from 121.14.1.190 (121.14.1.190): icmp_seq=2 ttl=53 time=48.5 ms ^C --- ara.sina.com.cn ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 999ms rtt min/avg/max/mdev = 48.406/48.470/48.535/0.229 ms [root@hwvntp01 html]# ping -I 10.3.1.7 www.sina.com.cn PING ara.sina.com.cn (121.14.1.190) from 10.3.1.7 : 56(84) bytes of data. 64 bytes from 121.14.1.190 (121.14.1.190): icmp_seq=1 ttl=51 time=46.3 ms 64 bytes from 121.14.1.190 (121.14.1.190): icmp_seq=2 ttl=51 time=46.4 ms 64 bytes from 121.14.1.190 (121.14.1.190): icmp_seq=3 ttl=51 time=46.1 ms 64 bytes from 121.14.1.190 (121.14.1.190): icmp_seq=4 ttl=51 time=46.2 ms ^C --- ara.sina.com.cn ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 5958ms rtt min/avg/max/mdev = 46.190/46.298/46.423/0.277 ms
5. 通過服務檢驗
在VM中安裝httpd:
yum install -y httpd systemctl start httpd systemctl status httpd ● httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled) Active: active (running) since Fri 2017-04-14 08:49:38 UTC; 6s ago Docs: man:httpd(8) man:apachectl(8) Main PID: 14147 (httpd)
從外部檢測:
三個地址都可以訪問。