Since I'm studying for VCAP-DCA and will use this lab more, I figured might as well set it to static and not rely on chance and have to check the display to find the IP again. Part of VCAP-DCA is getting very comfortable using the command line, so I determined I would do it with esxcli.
Pic from DCUI before doing the change:
Notice in this command that both the address and DNS are being acquired from DHCP for the vmk0 interface.
[root@arielitox:~] esxcli network ip interface ipv4 get
Name IPv4 Address IPv4 Netmask IPv4 Broadcast Address Type DHCP DNS
---- ------------ ------------- -------------- ------------ --------
vmk0 192.168.1.12 255.255.255.0 192.168.1.255 DHCP true
vmk1 192.168.1.13 255.255.255.0 192.168.1.255 STATIC false
A way to find out how to change it is to execute the command without parameters and get the help
Error: Missing required parameter -t|--type
Missing required parameter -i|--interface-name
Usage: esxcli network ip interface ipv4 set [cmd options]
Description:
set Configure IPv4 setting for a given VMkernel network interface.
Cmd options:
-i|--interface-name=<str>
The name of the VMkernel network interface to set IPv4 settings for. This name must be an interface
listed in the interface list command. (required)
-I|--ipv4=<str> The static IPv4 address for this interface.
-N|--netmask=<str> The static IPv4 netmask for this interface.
-P|--peer-dns A boolean value to indicate if the system should use the DNS settings published via DHCP for this
interface.
-t|--type=<str> IPv4 Address type :
dhcp: Use DHCP to aquire IPv4 setting for this interface.
none: Remove IPv4 settings form this interface.
static: Set Static IPv4 information for this interface. Requires --ipv4 and --netmask options.
(required)
I'm setting the same IP but static:
[root@arielitox:~] esxcli network ip interface ipv4 set -i vmk0 -I 192.168.1.12 -N 255.255.255.0 -P false -t static
and we can now confirm the results
[root@arielitox:~] esxcli network ip interface ipv4 get
Name IPv4 Address IPv4 Netmask IPv4 Broadcast Address Type DHCP DNS
---- ------------ ------------- -------------- ------------ --------
vmk0 192.168.1.12 255.255.255.0 192.168.1.255 STATIC false
vmk1 192.168.1.13 255.255.255.0 192.168.1.255 STATIC false
[root@arielitox:~] esxcli network ip dns server list
DNSServers: 192.168.1.1
That is in fact what I had through DHCP. I tested it survives a reboot; nonetheless I point this command out so that you also remember to check the DNS settings when you do this. I did these tests by changing the IP through the client, and in there the DNS option is in a separate location and must be changed manually.
So there you go. Once I checked back the DCUI, it indeed reports it as a static address
and it can be checked in the client as well.
Was there a gotcha here? Not sure. Things worked as expected; maybe the -P option is a bit of a gotcha, so that you don't leave DNS relying on DHCP, if you are doing this with the client.
No comments:
Post a Comment