Difference between revisions of "CLI - Networking"

 
(17 intermediate revisions by the same user not shown)
Line 1: Line 1:
IP 주소 설정은 configure 명령어에서 설정할 수 있습니다.
+
__FORCETOC__
 +
=== Verifying Network interfaces and Assigned IP Addresses ===
 +
To display network interfaces and their assigned IP addresses and nameserver addresses, type the <code>show interface</code>
 +
<pre>
 +
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
 +
</pre>
 +
 
 +
=== Assigning the IP address ===
 +
Both IPv4 and IPv6 addresses can be configured in the configuration mode.
 +
<pre>
 +
LYSH@MyHostName# configure // Enters configuration mode.
 +
LYSH@MyHostName(config)# 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)
 +
LYSH@MyHostName(config)# 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.
 +
LYSH@MyHostName(config)# exit
 +
LYSH@MyHostName# show interface
 +
LYSH@MyHostName# ping 192.168.0.1
 +
LYSH@MyHostName# ping6 2000:4::1
 +
</pre>
 +
{{note|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 ===
 +
<pre>
 +
LYSH@MyHostName# configure // Enters configuration mode.
 +
LYSH@MyHostName(config)# ip delete eth0 192.168.0.3/24 // Deletes an IPv4 address(i.e. 192.168.0.3/24)
 +
LYSH@MyHostName(config)# 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.
 +
LYSH@MyHostName(config)# exit
 +
LYSH@MyHostName# show interface
 +
</pre>
 +
{{note|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.}}
  
 +
=== netpaln ===
 +
This command allows you to apply the network configuration immediately. If you did not immediately apply the network configuration after adding or removing addresses, you can apply the new configuration with this command.
 
<pre>
 
<pre>
 
LYSH@MyHostName# configure
 
LYSH@MyHostName# configure
configure# ip add -h
+
LYSH@MyHostName(config)# netplan apply
usage: ip add [-h] interface ip [gateway]
+
</pre>
  
positional arguments:
 
  interface  Ethernet interface name
 
  ip          IPv4/Subnet Mask or IPv6 address/prefix
 
  [gateway]  IPv4 or IPv6 address
 
  
optional arguments:
+
=== nameserver ===
   -h, --help show this help message and exit
+
You can add or delete a nameserver of a network interface. To verify the configured nameservers, enter the <code>show interface</code> command in the user mode.
 +
<pre>
 +
LYSH@MyHostName# configure
 +
LYSH@MyHostName(config)# nameserver add eth0 8.8.8.8 // add a nameserver, 8.8.8.8, into the eth0 interface.
 +
LYSH@MyHostName(config)# nameserver delete eth0 8.8.4.4 // delete a nameserver, 8.8.8.8, from the eth0 interface.
 +
LYSH@MyHostName(config)# exit
 +
LYSH@MyHostName# show interface 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
 
</pre>
 
</pre>
  
=== Basic Commands ===
 
* <code>configure# ip add eth0 192.168.0.3/24</code> [gateway]는 제외하고 ip를 설정할 수 있습니다.
 
* <code>configure# ip add eth1 2000:4::40/64 2000:4::1</code> ipv6 및 gateway를 포함하여 설정합니다.
 
  
=== After Commands ===
+
=== Verifying Multicast Group ===
ip add 명령어로 interface 설정이 완료되면 <code>netplan apply</code>로 변경 사항을 적용할 수 있습니다.
+
To display multicast group membership information for IPv4 and IPv6, enter the <code>show multicast</code> command.
해당 명령어를 실행하지 않은 경우 재부팅 전까지 변경된 interface는 적용되지 않습니다.
+
<pre>
* <code>configure# netplan apply</code> 설정한 interface 정보를 적용합니다. 실행결과는 성공/실패로 표시됩니다.
+
LYSH@MyHostName# show multicast
사용하지 않는 interface의 ip주소는 <code>ip delete</code>명령어로 삭제합니다.
+
1:      lo
* <code>configure# ip delete eth0 192.168.0.3/24</code> eth0 인터페이스의 192.168.0.3/24 가 삭제됩니다.
+
        inet  224.0.0.1
ip 주소 삭제 명령어 이후 <code>netplan apply</code>로 변경 사항을 적용할 수 있습니다.
+
        inet6 ff02::1
 +
        inet6 ff01::1
 +
2:      eth0
 +
        link  01:80:c2:00:00:00   
 +
        inet  224.0.0.1
 +
        inet6 ff05::1:3
 +
        inet6 ff02::1:2
 +
        inet6 ff02::1:ff00:40
 +
</pre>

Latest revision as of 10:48, 28 January 2022

Verifying Network interfaces and Assigned IP Addresses

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.
LYSH@MyHostName(config)# 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)
LYSH@MyHostName(config)# 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.
LYSH@MyHostName(config)# exit
LYSH@MyHostName# 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.
LYSH@MyHostName(config)# ip delete eth0 192.168.0.3/24		// Deletes an IPv4 address(i.e. 192.168.0.3/24)
LYSH@MyHostName(config)# 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.
LYSH@MyHostName(config)# exit
LYSH@MyHostName# 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.

netpaln

This command allows you to apply the network configuration immediately. If you did not immediately apply the network configuration after adding or removing addresses, you can apply the new configuration with this command.

LYSH@MyHostName# configure
LYSH@MyHostName(config)# netplan apply


nameserver

You can add or delete a nameserver of a network interface. To verify the configured nameservers, enter the show interface command in the user mode.

LYSH@MyHostName# configure
LYSH@MyHostName(config)# nameserver add eth0 8.8.8.8		// add a nameserver, 8.8.8.8, into the eth0 interface.
LYSH@MyHostName(config)# nameserver delete eth0 8.8.4.4	// delete a nameserver, 8.8.8.8, from the eth0 interface.
LYSH@MyHostName(config)# exit
LYSH@MyHostName# show interface 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


Verifying Multicast Group

To display multicast group membership information for IPv4 and IPv6, enter the show multicast command.

LYSH@MyHostName# show multicast
1:      lo
        inet  224.0.0.1
        inet6 ff02::1
        inet6 ff01::1
2:      eth0
        link  01:80:c2:00:00:00    
        inet  224.0.0.1
        inet6 ff05::1:3
        inet6 ff02::1:2
        inet6 ff02::1:ff00:40