반응형

1. 네트워킹 정보 보기

1) 모든 네트워크 장치의 상태 표시

# nmcli dev status

DEVICE       TYPE      STATE         CONNECTION  

eno16777736  ethernet  connected     eno16777736 

eno33554960  ethernet  disconnected  --          

eno50332184  ethernet  disconnected  --          

lo           loopback  unmanaged     -- 


2) 장치의 상태를 상세히 확인 하려면..

nmcli device show eno16777736

GENERAL.DEVICE:                         eno16777736

GENERAL.TYPE:                           ethernet

GENERAL.HWADDR:                         00:0C:29:DA:27:A4

GENERAL.MTU:                            1500

GENERAL.STATE:                          100 (connected)

GENERAL.CONNECTION:                     eno16777736

GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveConnection/0

WIRED-PROPERTIES.CARRIER:               on

IP4.ADDRESS[1]:                         ip = 192.168.174.127/24, gw = 192.168.37.2

IP4.ADDRESS[2]:                         ip = 192.168.37.127/24, gw = 192.168.37.2

IP4.DNS[1]:                             192.168.37.2

IP6.ADDRESS[1]:                         ip = fe80::20c:29ff:feda:27a4/64, gw = ::


3) 모든 목록 표시

# nmcli connection show 

NAME         UUID                                  TYPE            DEVICE      

eno50332184  780109f3-9808-4aac-9eea-059fca9fc3c5  802-3-ethernet  --          

eno33554960  55a0ed56-44f5-4c76-bbf2-81543e0ac71f  802-3-ethernet  --          

eno16777736  c2e577cd-b1fb-42a1-83fd-d64ae1f092ff  802-3-ethernet  eno16777736


4) 활성된 연결만 표시

# nmcli connection show --active

NAME         UUID                                  TYPE            DEVICE      

eno16777736  c2e577cd-b1fb-42a1-83fd-d64ae1f092ff  802-3-ethernet  eno16777736


2. 네트워크 연결 추가

1) DHCP를 사용하여 IPv4 네트워킹 정보를 가져온 후 시작 시 자동으로 연결설정

# nmcli connection add con-name eno33554960 type ethernet ifname eno33554960

Connection 'eno33554960' (b6f77153-c147-491b-94b1-c9fbdf5b04ce) successfully added.


# nmcli connection show --active

# nmcli connection show --active

NAME         UUID                                  TYPE            DEVICE      

eno16777736  c2e577cd-b1fb-42a1-83fd-d64ae1f092ff  802-3-ethernet  eno16777736 

eno33554960  b6f77153-c147-491b-94b1-c9fbdf5b04ce  802-3-ethernet  eno33554960 


# ip addr show eno33554960

3: eno33554960: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000

    link/ether 00:0c:29:da:27:ae brd ff:ff:ff:ff:ff:ff

    inet 192.168.37.128/24 brd 192.168.37.255 scope global dynamic eno33554960

       valid_lft 1667sec preferred_lft 1667sec

    inet6 fe80::20c:29ff:feda:27ae/64 scope link 

       valid_lft forever preferred_lft forever


2) Static IP를 네트워크 추가

  IP : 192.168.37.100/24, GW : 192.168.37.2

  # nmcli connection add con-name eno50332184 type ethernet ifname eno50332184 ip4 192.168.37.100/24 gw4 192.168.37.2

Connection 'eno50332184' (bec69db6-5e59-4331-aecc-b4602dd0522c) successfully added.  


# nmcli connection  show --active

NAME         UUID                                  TYPE            DEVICE      

eno16777736  c2e577cd-b1fb-42a1-83fd-d64ae1f092ff  802-3-ethernet  eno16777736 

eno50332184  bec69db6-5e59-4331-aecc-b4602dd0522c  802-3-ethernet  eno50332184 

eno33554960  b6f77153-c147-491b-94b1-c9fbdf5b04ce  802-3-ethernet  eno33554960


# ip addr show eno50332184

4: eno50332184: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000

    link/ether 00:0c:29:da:27:b8 brd ff:ff:ff:ff:ff:ff

    inet 192.168.37.100/24 brd 192.168.37.255 scope global eno50332184

       valid_lft forever preferred_lft forever

    inet6 fe80::20c:29ff:feda:27b8/64 scope link 

       valid_lft forever preferred_lft forever


3. 네트워크 연결 제어

1) 네트워크 인터페이스 비활성화

# nmcli device disconnect eno50332184

# nmcli dev status

DEVICE       TYPE      STATE         CONNECTION  

eno16777736  ethernet  connected     eno16777736 

eno33554960  ethernet  connected     eno33554960 

eno50332184  ethernet  disconnected  --          

lo           loopback  unmanaged     --   


2) 네트워크 인터페이스 활성화

# nmcli device connect eno50332184

Device 'eno50332184' successfully activated with 'bec69db6-5e59-4331-aecc-b4602dd0522c'.

# nmcli dev status

DEVICE       TYPE      STATE      CONNECTION  

eno16777736  ethernet  connected  eno16777736 

eno33554960  ethernet  connected  eno33554960 

eno50332184  ethernet  connected  eno50332184 

lo           loopback  unmanaged  --     


3) 네트워크 인터페이스 중단 및 시작

# nmcli connection down eno33554960  // 중단

# nmcli connection up eno33554960   // 시작

Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/4)


4. 네트워크 연결 변경

1) eno50332184의 현재 상태를 확인

# nmcli device show eno50332184 

GENERAL.DEVICE:                         eno50332184

GENERAL.TYPE:                           ethernet

GENERAL.HWADDR:                         00:0C:29:DA:27:B8

GENERAL.MTU:                            1500

GENERAL.STATE:                          100 (connected)

GENERAL.CONNECTION:                     eno50332184

GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveConnection/3

WIRED-PROPERTIES.CARRIER:               on

IP4.ADDRESS[1]:                         ip = 192.168.37.100/24, gw = 192.168.37.2

IP6.ADDRESS[1]:                         ip = fe80::20c:29ff:feda:27b8/64, gw = ::


2) IPv4 주소 192.168.37.101/24, 게이트웨어 192.168.37.2로 변경하려면

# nmcli connection modify eno50332184 ipv4.addresses "192.168.37.101/24 192.168.37.2" ipv4.dns 8.8.8.8 connection.autoconnect yes ipv4.method static


3) DNS 서버 168.126.63.1 추가

# nmcli connection modify eno50332184 +ipv4.dns 168.126.63.1


※ 기본적으로 nmcli con mod name을 통해 변경된 내용은 자동으로 ~/ifcfg-name에 저장된다, ifcfg-name을 vi로 편집 후 NetworkManager가 구성 변경 내용을 읽을 수 있도록하기 위해서는 nmcli con reload를 실행해 주어야 한다.


※ NetworkManager는 /etc/resolv.conf을 직접 수정하려 하므로 내용이 덮어 쓰여 질 수가 있으므로 ifcfg-*파일에서 DNS? 및 DOMAIN 지시문을 설정하는 것이 더 바람직하다.


5. 네트워크 연결 삭제

nmcli connection delete eno50332184 

# nmcli device status

DEVICE       TYPE      STATE         CONNECTION  

eno16777736  ethernet  connected     eno16777736 

eno33554960  ethernet  connected     eno33554960 

eno50332184  ethernet  disconnected  --          

lo           loopback  unmanaged     -- 


6. hostname

1) 현재 호스트 네임 확인

# hostname

localhost.localdomain


2) 현재 호스트 네임을 임시로 변경

# hostname demo.example.com

# hostname

demo.example.com


3) hostnamectl명령으로 영구적으로 호스트네임 적용(/etc/hostname 파일이 수정된다.)

# hostnamectl set-hostname demo1.example.com

# hostnamectl status

   Static hostname: demo1.example.com

         Icon name: computer

           Chassis: n/a

        Machine ID: f9496f144568483086317305f6b4295a

           Boot ID: 76b1618a5eb246bdae6541ff24138ed4

    Virtualization: vmware

  Operating System: CentOS Linux 7 (Core)

       CPE OS Name: cpe:/o:centos:centos:7

            Kernel: Linux 3.10.0-123.el7.x86_64

      Architecture: x86_64

# cat /etc/hostname

demo1.example.com


==========================================================================================again

7. IPv6 네트워크 연결 추가

# nmcli connection add con-name eno1 type ethernet ifname eno1
Connection 'eno1' (479af0e7-2e16-46a0-8868-78aea5dbc3b1) successfully added.

# nmcli connection show
NAME         UUID                                  TYPE            DEVICE
eno1         479af0e7-2e16-46a0-8868-78aea5dbc3b1  802-3-ethernet  eno1   
System eth0  5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03  802-3-ethernet  eth0   

# nmcli connection modify eno1 ipv4.addresses 192.168.0.100/24
# nmcli connection modify eno1 ipv4.method manual

# nmcli connection modify eno1 ipv6.addresses fddb:fe2a:ab1e::c0a8:64/64
# nmcli connection modify eno1 ipv6.method manual

# systemctl restart NetworkManager
# ip addr show dev eno1
4: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether ce:c3:64:84:c3:49 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.100/24 brd 192.168.0.255 scope global eno1
       valid_lft forever preferred_lft forever
    inet6 fddb:fe2a:ab1e::c0a8:64/64 scope global
       valid_lft forever preferred_lft forever
    inet6 fe80::ccc3:64ff:fe84:c349/64 scope link
       valid_lft forever preferred_lft forever

# ping -I eno1 192.168.0.254
PING 192.168.0.254 (192.168.0.254) from 192.168.0.100 eno1: 56(84) bytes of data.
64 bytes from 192.168.0.254: icmp_seq=1 ttl=64 time=0.061 ms
64 bytes from 192.168.0.254: icmp_seq=2 ttl=64 time=0.064 ms
# ping6 -I eno1 fddb:fe2a:ab1e::c0a8:fe
PING fddb:fe2a:ab1e::c0a8:fe(fddb:fe2a:ab1e::c0a8:fe) from fddb:fe2a:ab1e::c0a8:64 eno1: 56 data bytes
64 bytes from fddb:fe2a:ab1e::c0a8:fe: icmp_seq=1 ttl=64 time=0.087 ms
64 bytes from fddb:fe2a:ab1e::c0a8:fe: icmp_seq=2 ttl=64 time=0.072 ms

# nmcli connection show eno1  | egrep 'ipv4.addresses|ipv6.addresses|ipv4.method|ipv6.method'

ipv4.addresses:                         { ip = 192.168.0.100/24, gw = 0.0.0.0 }

ipv6.addresses:                         { ip = fddb:fe2a:ab1e::c0a8:64/64, gw = :: } 

ipv4.method:                            auto

ipv6.method:                            auto

# nmcli connection down eno1

# nmcli connection up eno1

Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/3)


2) IPv6 네트워킹 정보 보기

# ip addr show 

==============================================================================================

※ NetworkManager GUI, TUI

1) nm-connection-editor


2) nmtui


반응형

'Linux > CentOS' 카테고리의 다른 글

[CentOS7] NFS  (0) 2015.03.17
[CentOS7] iSCSI  (0) 2015.03.17
[CentOS7] 서비스 및 데몬 제어  (0) 2015.03.16
[CentOS5] GeoIP 커널 모듈 빌드 하는 방법  (0) 2015.02.24
[CentOS] CentOS 7 처음 설치 후 설정  (2) 2014.11.24
  • 네이버 블러그 공유하기
  • 네이버 밴드에 공유하기
  • 페이스북 공유하기
  • 카카오스토리 공유하기