Difference between revisions of "CLI - Networking"

Line 1: Line 1:
 
__FORCETOC__
 
__FORCETOC__
 
=== Network interfaces ===
 
=== Network interfaces ===
To display network interfaces and their assigned addresses, type the <code>show interface</code>
+
To display network interfaces and their assigned IP addresses and nameserver addresses, type the <code>show interface</code>
 
<pre>
 
<pre>
 
LYSH@MyHostName# show interface
 
LYSH@MyHostName# show interface
Line 19: Line 19:
 
     IPv4 address  : 192.168.0.40/24  
 
     IPv4 address  : 192.168.0.40/24  
 
     MAC  address  : 00:01:a2:92:1e:f3
 
     MAC  address  : 00:01:a2:92:1e:f3
 
+
    ......
 +
        DNS Servers: 8.8.8.8
 +
                    8.8.4.4
 
LYSH@MyHostName# show interface eth0 // Display only eth0
 
LYSH@MyHostName# show interface eth0 // Display only eth0
 
eth0:
 
eth0:
Line 28: Line 30:
 
     IPv4 address  : 192.168.0.40/24  
 
     IPv4 address  : 192.168.0.40/24  
 
     MAC  address  : 00:01:a2:92:1e:f3
 
     MAC  address  : 00:01:a2:92:1e:f3
 +
    ......
 +
        DNS Servers: 8.8.8.8
 +
                    8.8.4.4
 
</pre>
 
</pre>
 
  
 
=== Assigning the IP address ===
 
=== Assigning the IP address ===

Revision as of 17:48, 28 April 2021

Network interfaces

To display network interfaces and their assigned IP addresses and nameserver addresses, type the show interface

LYSH@MyHostName# show interface
lo:
    stats          : operate=up, up=yes, speed=0MB, duplex=?, mtu=65536
    incoming       : bytes=79.3G, pkts=310057073, errs=0, drops=0
    outgoing       : bytes=79.3G, pkts=310057073, errs=0, drops=0
    IPv4 address   : 127.0.0.1/8
    IPv6 address   : ::1/128
    MAC  address   : 00:00:00:00:00:00

eth0:
    stats          : operate=up, up=yes, speed=100MB, duplex=full, mtu=1500
    incoming       : bytes=15.1G, pkts=93920605, errs=0, drops=6869214
    outgoing       : bytes=65.9G, pkts=76383487, errs=0, drops=0
    gateway4       : 192.168.0.1
    IPv4 address   : 192.168.0.40/24 
    MAC  address   : 00:01:a2:92:1e:f3
    ......
        DNS Servers: 8.8.8.8
                     8.8.4.4
LYSH@MyHostName# show interface eth0			// Display only eth0
eth0:
    stats          : operate=up, up=yes, speed=100MB, duplex=full, mtu=1500
    incoming       : bytes=15.1G, pkts=93920605, errs=0, drops=6869214
    outgoing       : bytes=65.9G, pkts=76383487, errs=0, drops=0
    gateway4       : 192.168.0.1
    IPv4 address   : 192.168.0.40/24 
    MAC  address   : 00:01:a2:92:1e:f3
    ......
        DNS Servers: 8.8.8.8
                     8.8.4.4

Assigning the IP address

Both IPv4 and IPv6 addresses can be configured in the configuration mode.

LYSH@MyHostName# configure				// Enters configuration mode.
configure# ip add eth0 192.168.0.3/24 192.168.0.1	// Configures an IPv4 address, subnet, and gateway.(i.e. 192.168.0.1)
configure# ip add eth0 2000:4::40/64 2000:4::1		// Configures an IPv6 address, prefix, and gateway.(i.e, 2000:4::1)
interface setting was added. Do you want to apply these settings?(y/n): y	// immediately apply the configurations.
configure# exit
configure# show interface
LYSH@MyHostName# ping 192.168.0.1		
LYSH@MyHostName# ping6 2000:4::1				

Note that, If a network interface already has an assigned IP address and you configure another IP address and gateway of the same version, the gateway is ignored. In the words, the secondary gateway of the same version is not allowed.

Deleting the IP address

LYSH@MyHostName# configure				// Enters configuration mode.
configure# ip delete eth0 192.168.0.3/24		// Deletes an IPv4 address(i.e. 192.168.0.3/24)
configure# ip delete eth0 2000:4::40/64			// Deletes an IPv6 address(i.e. 2000:4::40/64)
interface setting was deleted. Do you want to apply these settings?(y/n): y	// immediately apply the configurations.
configure# exit
configure# show interface				

Note that, If a network interface has multiple assigned IP addresses of the same version(i.e. IPv4 or IPv6), the gateway address is not removing before deleting all IP addresses of the same version from a network interface.