Sometimes we need to change IP addresses in our systems, and some are easy than others. In his blog post, we will discuss how to change the IP address in a vCloud Director.
I will show how to change the IP address in a vCloud Director in a Linux vCD and a vCD Appliance.
Environment:
- Linux CentOS7 vCloud Director 10.2.x
- 2 vNIC with 2 IPs
- IP1: 192.168.1.110/24 – Used for HTTP and Console Access (primary and console IP)
- IP2: 192.168.1.111/24 – Used for DB (database host IP)
- 2 vNIC with 2 IPs
- vCloud Director Appliance 10.2.
- 2 vNIC with 2 IPs
- IP1: 192.168.1.110/24 – Used for HTTP and Console Access (primary and console IP)
- IP2: 192.168.2.110/24 – Used for DB (database host IP)
- 2 vNIC with 2 IPs
- New IPs
- IP1: 192.168.1.112/24
- IP2: 192.168.1.113/24
Pre-checks or changes.
- Check the NFS shared folder permissions in your NAS. If you are setting those permissions per IP, do not forget to add the new IPs.
- Check your DNS names. If you plan to use the same DNS name, do not forget to set new IPS with the same DNS name.
- If you will use different IPs and DNS names and using Custom CA Signed Certificates, you need to add the new certificates to vCD. For self-signed certificates, no changes are needed.
- If you connect to your vCD using ssh, do not forget that you will lose connection after you change the eth0 interface IP. Use VM remote console instead.
In a Linux vCloud Director.
For the Linux version, you change your IP like in any normal Linux system. For this case, since I am using a CentOS7, I will use the nmtui network tool from CentOS.
These are the original IP addresses.
Running the nmtui Network management tool, we can easily change the IP addresses. Or you can do it manually, like in a normal Linux system.
After changing the IP addresses, restart the network service, and you should now have the new IPs.
Note: Do not forget to change your NFS shared folder settings. In my case, I needed to change my Sinology NFS Shared folder permissions to see the new IPs since I have set per IP.
After adding the IPs and run mount, I mounted -a Shared folder, and I can start and run the vCD configuration tool.
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 54 55 56 57 58 59 60 61 62 63 |
[root@vCD-97-SQL /]# ./opt/vmware/vcloud-director/bin/configure Welcome to the VMware Cloud Director configuration utility. You will be prompted to enter a number of parameters that are necessary to configure and start the VMware Cloud Director service. Error: saved primary IP address (/192.168.1.110) is no longer registered on this machine. Error: saved primary IP address (/192.168.1.111) is no longer registered on this machine. Please indicate which IP address available on this machine should be used for the HTTP service and which IP address should be used for the remote console proxy. The HTTP service IP address is used for accessing the user interface and the REST API. The remote console proxy IP address is used for all remote console connections and traffic. Please enter your choice for the HTTP service IP address: 1. 192.168.1.112 2. 192.168.1.113 3. 127.0.0.1 Choice [default=1]: 1 Please enter your choice for the remote console proxy IP address: 1. 192.168.1.113 2. 127.0.0.1 Choice [default=1]: 1 Connecting to the database: jdbc:postgresql://192.168.1.110:5432/vcloud?socketTimeout=90 May 19, 2021 11:47:36 PM org.postgresql.Driver connect SEVERE: Connection error: org.postgresql.util.PSQLException: The connection attempt failed. at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:275) at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49) at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:194) at org.postgresql.Driver.makeConnection(Driver.java:450) at org.postgresql.Driver.connect(Driver.java:252) ... Caused by: java.net.SocketTimeoutException: connect timed out at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:607) at org.postgresql.core.PGStream.<init>(PGStream.java:68) at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:144) ... 22 more May 19, 2021 11:47:36 PM org.apache.tomcat.jdbc.pool.ConnectionPool init SEVERE: Unable to create initial connections of pool. org.postgresql.util.PSQLException: The connection attempt failed. at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:275) ... at com.vmware.vcloud.configure.legacy.ConfigAgent.start(ConfigAgent.java:361) at com.vmware.vcloud.configure.legacy.ConfigAgentExecutor.start(ConfigAgentExecutor.java:87) at com.vmware.vcloud.configure.legacy.ConfigAgentExecutor.main(ConfigAgentExecutor.java:81) Caused by: java.net.SocketTimeoutException: connect timed out at java.net.PlainSocketImpl.socketConnect(Native Method) ... at java.net.Socket.connect(Socket.java:607) at org.postgresql.core.PGStream.<init>(PGStream.java:68) at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:144) ... 22 more |
When you run the vCD configuration tool, you should get an error(cannot connect to DB), which is normal since the IP is different and cannot connect to the DB. Just follow the steps and enter the new IPs and your DB name and user. In the end, your vCloud Director should be ready to be used.
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 |
Could not connect to database: The connection attempt failed. Could not connect to database. Please reenter. Enter the host (or IP address) for the PostgreSQL database: 192.168.1.112 Enter the database port [default=5432]: Using default value "5432" for port. Enter the database name [default=vcloud]: Using default value "vcloud" for database name. Enter the database username: vcloud Enter the database password: Connecting to the database: jdbc:postgresql://192.168.1.112:5432/vcloud?socketTimeout=90 ...\ Database configuration complete. VMware Cloud Director configuration is now complete. Once the VMware Cloud Director server has been started you will be able to access it at this URL: https://vCD-97-SQL.vmwarehome.lab Would you like to start the Cloud Director service now? If you choose not to start it now, you can manually start it at any time using this command: service vmware-vcd start Start it now? [y/n] y |
Now we have new IPs in our Linux CD, let us test.
As we can see above, the new IPs are working, and all vApps/VMs are power on.
In a vCloud Director Appliance.
These are the original IPs from vCD Appliance.
The vCD Appliance changing IPs is a bit different since some vami scripts do this automatically.
Inside the folder /opt/vmware/share/vami there are scripts to change our vCD Appliance.
In this case, we will use the script vami_config_net. With this script, we can change IPs, default gateway, DNS, and hostname.
1. First stop vCD Appliance Servcd /vice.
1 2 3 4 5 |
root@vCD-97-SQL [ / ]# /opt/vmware/vcloud-director/bin/cell-management-tool -u administrator cell -s Please enter the administrator password: Cell successfully deactivated and all tasks cleared in preparation for shutdown |
2. Run the script vami_config_net and change the first IP address that is in eth0.
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 |
root@vCD-97-SQL [ ~ ]# cd /opt/vmware/share/vami/ root@vCD-97-SQL [ /opt/vmware/share/vami ]# ./vami_config_net 0) Show Current Configuration (scroll with Shift-PgUp/PgDown) 1) Exit this program 2) Default Gateway 3) Hostname 4) DNS 5) Proxy Server 6) IP Address Allocation for eth0 7) IP Address Allocation for eth1 Enter a menu number [0]: 6 Type Ctrl-C to go back to the Main Menu Configure an IPv4 address for eth0? y/n [n]: y Use a DHCPv4 Server instead of a static IPv4 address? y/n [n]: n IPv4 Address [192.168.1.110]: 192.168.1.112 Netmask [255.255.255.0]: IPv4 Address: 192.168.1.112 Netmask: 255.255.255.0 Is this correct? y/n [y]: y Reconfiguring eth0... net.ipv6.conf.eth0.disable_ipv6 = 1 Network parameters successfully changed to requested values |
3. Select option 7 to change the second IP address that is in eth1.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
7) IP Address Allocation for eth1 Enter a menu number [0]: 7 Type Ctrl-C to go back to the Main Menu Configure an IPv4 address for eth1? y/n [n]: y Use a DHCPv4 Server instead of a static IPv4 address? y/n [n]: IPv4 Address [192.168.2.110]: 192.168.1.113 Netmask [255.255.255.0]: IPv4 Address: 192.168.1.113 Netmask: 255.255.255.0 Is this correct? y/n [y]: y Reconfiguring eth1... net.ipv6.conf.eth1.disable_ipv6 = 1 Network parameters successfully changed to requested values |
4. Select option 0 to check the new settings.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
0) Show Current Configuration (scroll with Shift-PgUp/PgDown) Enter a menu number [0]: 0 Network Configuration for eth0 IPv4 Address: 192.168.1.112 Netmask: 255.255.255.0 Network Configuration for eth1 IPv4 Address: 192.168.1.113 Netmask: 255.255.255.0 Global Configuration IPv4 Gateway: 192.168.1.254 Hostname: vCD-97-SQL.vmwarehome.lab DNS Servers: 192.168.1.3, 192.168.1.40 Domain Name: Search Path: vCD-97-SQL.vmwarehome.lab vmwarehome.lab Proxy Server: |
Select 1 to exit the menu script.
As we can check in the above settings, the hostname is the same. If you need a new hostname, use the same script to make those changes. So again, check if you want to use the same DNS name or change it. Do the changes in your DNS accordantly.
The new IP addresses are set.
Note: If you have your NFS shared folder, set the permission per IP, do not forget to change your NFS shared folder settings.
5. Now, we need to reconfigure vCD to see the new IP addresses. Again we need to use the vCD configuration tool /opt/vmware/vcloud-director/bin/configure.
After adding the IPs and run mount -a Shared folder was again mounted, and I can start and run the vCD configuration tool.
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 54 55 56 57 58 59 60 61 62 63 64 |
root@vCD-97-SQL [ / ]# ./opt/vmware/vcloud-director/bin/configure Welcome to the VMware Cloud Director configuration utility. You will be prompted to enter a number of parameters that are necessary to configure and start the VMware Cloud Director service. Error: saved primary IP address (/192.168.1.110) is no longer registered on this machine. Error: saved primary IP address (/192.168.1.110) is no longer registered on this machine. Please indicate which IP address available on this machine should be used for the HTTP service and which IP address should be used for the remote console proxy. The HTTP service IP address is used for accessing the user interface and the REST API. The remote console proxy IP address is used for all remote console connections and traffic. Please enter your choice for the HTTP service IP address: 1. 192.168.1.112 2. 192.168.1.113 3. 127.0.0.1 4. [0:0:0:0:0:0:0:1%lo] Choice [default=1]: Using default value "192.168.1.112" for HTTP service. Please enter your choice for the remote console proxy IP address: 1. 192.168.1.113 2. 127.0.0.1 3. [0:0:0:0:0:0:0:1%lo] Choice [default=1]: Using default value "192.168.1.113" for remote console proxy. Connecting to the database: jdbc:postgresql://192.168.2.110:5432/vcloud?socketTimeout=90 Could not connect to database: The connection attempt failed. Could not connect to database. Please reenter. Enter the host (or IP address) for the PostgreSQL database: 192.168.1.113 Enter the database port [default=5432]: Using default value "5432" for port. Enter the database name [default=vcloud]: Using default value "vcloud" for database name. Enter the database username: vcloud Enter the database password: Connecting to the database: jdbc:postgresql://192.168.1.113:5432/vcloud?socketTimeout=90 ...\ Database configuration complete. VMware Cloud Director configuration is now complete. Once the VMware Cloud Director server has been started you will be able to access it at this URL: https://192.168.1.112 Would you like to start the Cloud Director service now? If you choose not to start it now, you can manually start it at any time using this command: service vmware-vcd start Start it now? [y/n] n Skipping start up for now The Cloud Director service will be started automatically on boot. To disable this, use the following command: chkconfig --del vmware-vcd |
As we can notice above, the process is similar to what we used in the Linux CD configuration.
Note: Again, if you use certificates that rely on IPs and DNS Names, you need to change your certificates in vCD.
6. Re-import vCenter, NSX-V, or NSX-T used in your vCD Appliance.
1 2 3 4 5 6 7 8 9 10 11 |
root@vCD-97-SQL [ / ]# /opt/vmware/vcloud-director/bin/cell-management-tool trust-infra-certs --vsphere --unattended Downloading certificates for 2 host(s): 192.168.1.109 [Download: SUCCESS] 192.168.1.51 [Download: SUCCESS] Downloaded certificates for 2/2 host(s). Trusting certificates for 2 host(s): 192.168.1.51 [Trusted: SUCCESS] 192.168.1.109 [Trusted: SUCCESS] Trusted 2/2 downloaded certificates. |
7. Start your vCD Appliance service.
1 2 3 |
root@vCD-97-SQL [ / ]# service vmware-vcd start |
Now vCD is all set to use the new IPs.
Again after the changes, all services, vApps, and VMs are running fine.
With this last step, we finish this process and blog post How to change the IP address in a vCloud Director. I hope it can help you make this kind of change in your vCD.
Share this article if you think it is worth sharing. If you have any questions or comments, comment here, or contact me on Twitter.
Leave A Comment
You must be logged in to post a comment.