The NX-OS switch ports
are represented in the Guest Shell as Linux network interfaces. Typical Linux
methods like view stats in /proc/net/dev, through ifconfig or ethtool are all
supported:
The Guest Shell has a
number of typical network utilities included by default and they can be used on
different VRFs using the
chvrf
vrf
command command.
[guestshell@guestshell bootflash]$ ifconfig Eth1-47
Eth1-47: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 13.0.0.47 netmask 255.255.255.0 broadcast 13.0.0.255
ether 54:7f:ee:8e:27:bc txqueuelen 100 (Ethernet)
RX packets 311442 bytes 21703008 (20.6 MiB)
RX errors 0 dropped 185 overruns 0 frame 0
TX packets 12967 bytes 3023575 (2.8 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Within the Guest
Shell, the networking state can be monitored, but may not be changed. To change
networking state, use the NX-OS CLI or the appropriate Linux utilities in the
host bash shell.
The
tcpdump command is packaged with the Guest
Shell to allow packet tracing of punted traffic on the management or switch
ports.
The
sudo ip netns exec management
ping utility is a common method for running a command in the
context of a specified network namespace. This can be done within the Guest
Shell:
[guestshell@guestshell bootflash]$ sudo ip netns exec management ping 10.28.38.48
PING 10.28.38.48 (10.28.38.48) 56(84) bytes of data.
64 bytes from 10.28.38.48: icmp_seq=1 ttl=48 time=76.5 ms
The chvrf utility is
provided as a convenience:
guestshell@guestshell bootflash]$ chvrf management ping 10.28.38.48
PING 10.28.38.48 (10.28.38.48) 56(84) bytes of data.
64 bytes from 10.28.38.48: icmp_seq=1 ttl=48 time=76.5 ms
Note
|
Commands that are run without the
chvrf command are run in the current VRF/network namespace.
|
For example, to ping
IP address 10.0.0.1 over the management VRF, the command is “chvrf
management
ping
10.0.0.1 ”. Other utilities such as
scp or
ssh would be
similar.
Example:
switch# guestshell
[guestshell@guestshell ~]$ cd /bootflash
[guestshell@guestshell bootflash]$ chvrf management scp foo@10.28.38.48:/foo/index.html index.html
foo@10.28.38.48's password:
index.html 100% 1804 1.8KB/s 00:00
[guestshell@guestshell bootflash]$ ls -al index.html
-rw-r--r-- 1 guestshe users 1804 Sep 13 20:28 index.html
[guestshell@guestshell bootflash]$
[guestshell@guestshell bootflash]$ chvrf management curl cisco.com
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="http://www.cisco.com/">here</a>.</p>
</body></html>
[guestshell@guestshell bootflash]$
To obtain a list of
VRFs on the system, use the
show vrf
command natively from NX-OS or through the
dohost command:
Example:
[guestshell@guestshell bootflash]$ dohost 'sh vrf'
VRF-Name VRF-ID State Reason
default 1 Up --
management 2 Up --
red 6 Up --
Within the Guest
Shell, the network namespaces associated with the VRFs are what is actually
used. It can be more convenient to just see which network namespaces are
present:
[guestshell@guestshell bootflash]$ ls /var/run/netns
default management red
[guestshell@guestshell bootflash]$
To resolve domain
names from within the Guest Shell, the resolver needs to be configured. Edit
the /etc/resolv.conf file in the Guest Shell to include a DNS nameserver and
domain as appropriate for the network.
Example:
nameserver 10.1.1.1
domain cisco.com
The nameserver and
domain information should match what is configured through the NX-OS
configuration.
Example:
switch(config)# ip domain-name cisco.com
switch(config)# ip name-server 10.1.1.1
switch(config)# vrf context management
switch(config-vrf)# ip domain-name cisco.com
switch(config-vrf)# ip name-server 10.1.1.1
If the switch is in a network that uses an HTTP proxy server, the http_proxy and https_proxy environment variables must be set up within the Guest Shell also.
Example:
export http_proxy=http://proxy.esl.cisco.com:8080
export https_proxy=http://proxy.esl.cisco.com:8080
These environment
variables should be set in the .bashrc file or in an appropriate script to
ensure that they are persistent.