Windows服务器里面如何设置vmware/vps的IP? 一下文章仅供参考,并不适用所有的服务器。 After you have obtained your IP blocks, you will now be able to configure networking on the Virtual Machine. If you have not yet installed the Virtual Machine, configuration of your public network block can be performed through the Operating System installation process. This is the quickest method of configuring your public network and is recommended. If you have already install the guest Operating System, this guide does also provide instructions for configuring your public network. All network configuration steps provided will assume that the first network interface(eth0 or Local Area Connection) will always be the private network and the second network interface (eth1 or Local Area Connection 2) will be the public network. Configuring your network is setup differently based on the OS you have installed. This guide provides detailed information on configuring your network for the following Operating Systems. Operating Systems grouped together share the same network configuration. ·Windows 2008 Server Core Network configuration will require the following information for both your Public and Private IP blocks. -IP Address Windows 2008 Server Core Windows 2008 Server Core edition does not provide a graphical interface from which to configure the system network. Configuration will need to be done manually via the command line. Below are the commands you will need to run. The IP addresses used in this example will need to be replaced with the correct IP addresses from your IP Blocks. These same commands should work with older versions of Windows Server that include the netsh2 command. Example public IP block – 192.0.2.0/29 ·IP Address – 192.0.2.2 Example private IP block – 10.0.0.0/29 ·IP Address – 10.0.0.2 Public Network This command will create the public network connecting your server to the internet. These commands will create the DNS entries. If you are not using the private network, you will need to replace these IP addresses with working DNS servers Private Network The following 2 commands will configure the private network as well as create the persistent route for the private network. The persistent route will provide your private network access to the entire private network which includes the DNS servers in the public network configuration steps above. Please note, there is no gateway assigned to the private network. This is handled via the route statement that is provided below. Windows 2003 Standard and Enterprise Windows 2003 allows you configure networking using either the command line or the graphical user interface. If you intend to use the command line, please refer to the configuration instructions for Windows 2008 Server Core, as these instructions will work for 2003. The instructions for using the graphical interface will be provided here. The IP addresses used in this example will need to be replaced with the correct IP addresses from your IP Blocks. Example private IP block – 10.0.0.0/29 ·IP Address – 10.0.0.2 Open your network configurations Public Network The following instructions will provide detailed steps on configuring the public network through the windows graphical interface. Private Network To provide access to the entire private network which includes the DNS servers you will need to add a custom route to the server. This is done in the next few steps. ·Start -> Run Windows 2008 Web, Standard, Enterprise and Datacenter Windows 2008 allows you configure networking using either the command line or the graphical user interface. If you intend to use the command line, please refer to the configuration instructions for Windows 2008 Server Core, as these instructions will work for all 2008 servers. The instructions for using the graphical interface will be provided here. The IP addresses used in this example will need to be replaced with the correct IP addresses from your IP Blocks. Example private IP block – 10.0.0.0/29 ·IP Address – 10.0.0.2 Open your network configurations ·Start Menu -> Settings -> Control Panel Public Network The following instructions will provide detailed steps on configuring the public network through the windows graphical interface. Private Network To provide access to the entire private network which includes the DNS servers you will need to add a custom route to the server. This is done in the next few steps. Redhat, Fedora and CentOS Network configuration on RedHat, Fedora and CentOS is done through manually editing configuration files. In order to manually edit the files, you will need to be logged into the Virtual Machine as the root used and will require a text editor. Example public IP block – 192.0.2.0/29 ·IP Address – 192.0.2.2 Example private IP block – 10.0.0.0/29 ·IP Address – 10.0.0.2 Public Network The public network settings are contained in the following file, you will need to edit this file with the information provided. Replace the example IP addresses with the correct IP addresses form your public IP block. Note, the file may not exist. If the file does not exist, create the file. If it does exist, replace all data in the file with the information provided below. ·/etc/sysconfig/network-scripts/ ifcfg-eth1 GATEWAY=192.0.2.1 Private Network The private network settings are contained in the following file, you will need to edit this file with the information provided. Replace the example IP addresses with the correct IP addresses from your Private IP block. Note, the file may not exist. If the file does not exist create it, if the file does exist, replace all data in the file with the information provided below. The private network WILL NOT have a default route, so the GATEWAY will not be defined. ·/etc/sysconfig/network-scripts/ ifcfg-eth0 Finally, a new route will be required to provide private access to the entire private network including the DNS server. This is done by editing the following file. This fill will not exist and will need to be created. ·/etc/sysconfig/network-scripts/route-eth0 DNS Configuration The primary and secondary DNS configuration is contained in a separate file; this fill will need to be edited with the following information. If this Virtual Machine does not have access to the private network, you will need to replace the server IP’s with the IP addresses of the DNS servers you plan to use. ·/etc/resolv.conf In order for these changes to take effect, you will need to restart networking on the server. This can be done by running the following command Ubuntu and Debian Ubuntu and Debian network configuration is done through a single configuration file. This file will need to be manually edited. To edit this file you will need to have root access to the server. The base install of Ubuntu does not provide a root login, however the user created in the installation process has access to sudo. You will need to use the sudo command to edit the file if you are running on ubuntu. Example public IP block – 192.0.2.0/29 ·IP Address – 192.0.2.2 Example private IP block – 10.0.0.0/29 ·IP Address – 10.0.0.2 Public and Private Network Edit the following file with any text editor. Replace example IP addresses with the correct IP’s from your Public and Private IP blocks. ·/etc/network/interfaces DNS Configuration The primary and secondary DNS configuration is contained in a separate file; this fill will need to be edited with the following information. If this Virtual Machine does not have access to the private network, you will need to replace the server IP’s with the IP addresses of the DNS servers you plan to use. ·/etc/resolv.conf In order for these changes to take effect, you will want to restart networking on the server. This can be done by running the following command:
·Windows 2003 Standard and Enterprise
·Windows 2008 Web, Standard, Enterprise and Datacenter
·Redhat, Fedora and CentOS
·Ubuntu and Debian
-Gateway
-Subnet Mask
--Subnet conversion
---/29 - 255.255.255.248
---/28 - 255.255.255.240
---/27 - 255.255.255.224
---/26 - 255.255.255.192
---/25 - 255.255.255.128
---/24 - 255.255.255.0
·Gateway – 192.0.2.1
·Subnet Mask – 255.255.255.248
·Gateway – 10.0.0.1
·Subnet Mask – 255.255.255.248
·Gateway – 10.0.0.1
·Subnet Mask – 255.255.255.248
·Enter the command “cmd” and press “OK”
·Run the following command; replace the gateway address (10.0.0.1) with your private IP block gateway.
“route add 10.0.0.0 mask 255.0.0.0 10.0.0.1 –p”
·Gateway – 10.0.0.1
·Subnet Mask – 255.255.255.248
·Open “Network and Sharing Center”
·Click “Manage network connections”
·If you installed 2 network adaptors you will see “Local Area Connection” and “Local Area Connection 2”
·Gateway – 192.0.2.1
·Subnet Mask – 255.255.255.248
·Gateway – 10.0.0.1
·Subnet Mask – 255.255.255.248
DEVICE=eth1
BOOTPROTO=static
BROADCAST=192.0.2.7
IPADDR=192.0.2.2
NETMASK=255.255.255.248
NETWORK=192.0.2.0
ONBOOT=yes
DEVICE=eth0
BOOTPROTO=static
IPADDR=10.0.0.2
NETMASK=255.255.255.248
ONBOOT=yes
10.0.0.0/8 via 10.0.0.1
nameserver 10.0.80.11
nameserver 10.0.80.12
·Gateway – 192.0.2.1
·Subnet Mask – 255.255.255.248
·Gateway – 10.0.0.1
·Subnet Mask – 255.255.255.248
auto lo
iface lo inet loopback
##Public Network
auto eth1
iface eth1 inet static
address 192.0.2.2
netmask 255.255.255.248
gateway 192.0.2.1
##Private Network
auto eth0
iface eth0 inet static
address 10.0.0.2
netmask 255.255.255.248
#Static route for backend service network
up route add -net 10.0.0.0/8 gw 10.0.0.1
nameserver 10.0.80.11
nameserver 10.0.80.12
Note: 192.0.2.0/24 is used as Public IP Documentation as per RFC1166 and RFC5737. You will not use these IP addresses on your servers at any point in time.