Linux设置VIP

问题描述

在使用VMVare时,因为mac的ip经常会改变,每次重启虚拟机的时候IP也会改变,所有就要去改host去访问虚拟机中的项目,很麻烦,其实可以固定虚拟机的ip,及时宿主机ip变了也不会改变

1
2
3
sudo -s

vim /Library/Preferences/VMware\Fusion/vmnet8/dhcpd.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
# Configuration file for ISC 2.0 vmnet-dhcpd operating on vmnet8.
#
# This file was automatically generated by the VMware configuration program.
# See Instructions below if you want to modify it.
#
# We set domain-name-servers to make some DHCP clients happy
# (dhclient as configured in SuSE, TurboLinux, etc.).
# We also supply a domain name to make pump (Red Hat 6.x) happy.
#


###### VMNET DHCP Configuration. Start of "DO NOT MODIFY SECTION" #####
# Modification Instructions: This section of the configuration file contains
# information generated by the configuration program. Do not modify this
# section.
# You are free to modify everything else. Also, this section must start
# on a new line
# This file will get backed up with a different name in the same directory
# if this section is edited and you try to configure DHCP again.

# Written at: 11/08/2017 23:14:55
allow unknown-clients;
default-lease-time 1800; # default is 30 minutes
max-lease-time 7200; # default is 2 hours

subnet 192.168.37.0 netmask 255.255.255.0 {
range 192.168.37.128 192.168.37.254;
option broadcast-address 192.168.37.255;
option domain-name-servers 192.168.37.2;
option domain-name localdomain;
default-lease-time 1800; # default is 30 minutes
max-lease-time 7200; # default is 2 hours
option netbios-name-servers 192.168.37.2;
option routers 192.168.37.2;
}
host vmnet8 {
hardware ethernet 00:50:56:C0:00:08;
fixed-address 192.168.37.1;
option domain-name-servers 0.0.0.0;
option domain-name "";
option routers 0.0.0.0;
}



#在这里添加你的虚拟机的固定ip
host 你的虚拟机的名字 {
hardware ethernet 00:50:56:C0:00:08;
fixed-address 192.168.37.88;
}
# hardware ethernet查看上面配置
# fixed-address 你要配置的固定ip