서버를 이용하기 위해서는 네트워크 설정이 필요하며, 서비스 제공을 위해 기본적으로 고정IP가 필요하다.
이번 포스팅에서는 서버간 이름을 지정하는 Hostname 설정과 고정 IP 설정 방법, 사용하지 않는 IPv6를 비활성화하는 방법에 대해 알아보자.
# Hostname 설정
[root@localhost ~]# hostnamectl set-hostname magicpipe
# 설정된 Hostname 확인
[root@localhost ~]# hostname
magicpipe
# 서버의 네트워크 인터페이스 확인
[root@localhost ~]# nmcli device
DEVICE TYPE STATE CONNECTION
enp0s3 ethernet connected enp0s3
enp0s8 ethernet connected enp0s8
lo loopback unmanaged --
virbr0-nic tun unmanaged --
# 고정 IP와 Subnet 설정
[root@localhost ~]# nmcli connection modify enp0s3 ipv4.addresses 10.0.2.101/24
# Gateway IP 설정
[root@localhost ~]# nmcli connection modify enp0s3 ipv4.gateway 10.0.2.1
# DNS IP 설정
[root@localhost ~]# nmcli connection modify enp0s3 ipv4.dns 10.0.2.1
# 고정 IP 사용하기 수동 설정 적용
[root@localhost ~]# nmcli connection modify enp0s3 ipv4.method manual
# 고정 IP 설정한 네트워크 인터페이스 재시작
[root@localhost ~]# nmcli connection down enp0s3; nmcli connection up enp0s3
Connection 'enp0s3' successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/1)
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/5)
# 고정 IP 설정 확인
[root@localhost ~]# nmcli device show enp0s3
GENERAL.DEVICE: enp0s3
GENERAL.TYPE: ethernet
GENERAL.HWADDR: 08:00:27:D8:9A:B1
GENERAL.MTU: 1500
GENERAL.STATE: 100 (connected)
GENERAL.CONNECTION: enp0s3
GENERAL.CON-PATH: /org/freedesktop/NetworkManager/ActiveConnection/6
WIRED-PROPERTIES.CARRIER: on
IP4.ADDRESS[1]: 10.0.2.101/24
IP4.GATEWAY: 10.0.2.1
IP4.ROUTE[1]: dst = 10.0.2.0/24, nh = 0.0.0.0, mt = 102
IP4.ROUTE[2]: dst = 0.0.0.0/0, nh = 10.0.2.1, mt = 102
IP4.DNS[1]: 10.0.2.1
IP6.ADDRESS[1]: fe80::ba7d:47e7:e20a:bdb0/64
IP6.GATEWAY: --
IP6.ROUTE[1]: dst = fe80::/64, nh = ::, mt = 102
IP6.ROUTE[2]: dst = ff00::/8, nh = ::, mt = 256, table=255
# 상태 확인하기
[root@localhost ~]# ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 08:00:27:d8:9a:b1 brd ff:ff:ff:ff:ff:ff
inet 10.0.2.101/24 brd 10.0.2.255 scope global noprefixroute enp0s3
valid_lft forever preferred_lft forever
inet6 fe80::ba7d:47e7:e20a:bdb0/64 scope link noprefixroute
valid_lft forever preferred_lft forever
3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 08:00:27:eb:57:81 brd ff:ff:ff:ff:ff:ff
inet 192.168.56.107/24 brd 192.168.56.255 scope global dynamic noprefixroute enp0s8
valid_lft 1094sec preferred_lft 1094sec
inet6 fe80::2bf0:8265:9997:cb41/64 scope link noprefixroute
valid_lft forever preferred_lft forever
# IPv6 비활성화 설정
[root@localhost ~]# vi /etc/default/grub
# 설정 변경 전 Config
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto resume=/dev/mapper/cl-swap rd.lvm.lv=cl/root rd.lvm.lv=cl/swap rhgb quiet"
GRUB_DISABLE_RECOVERY="true"
GRUB_ENABLE_BLSCFG=true
# 설정 변경 후 Config
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto ipv6.disable=1 resume=/dev/mapper/cl-swap rd.lvm.lv=cl/root rd.lvm.lv=cl/swap rhgb quiet"
GRUB_DISABLE_RECOVERY="true"
GRUB_ENABLE_BLSCFG=true
# 설정 적용 후 서버 재시작
[root@localhost ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
done
[root@localhost ~]# reboot
[CentOS 8] 초기 세팅 | Update System (0) | 2020.07.04 |
---|---|
[CentOS 8] 초기 세팅 | Services 확인 (0) | 2020.07.03 |
[CentOS 8] 초기 세팅 | 방화벽과 SELinux 설정 (0) | 2020.07.01 |
[CentOS 8] 일반 사용자 추가/삭제와 SU 권한 설정 (0) | 2020.06.30 |
[CentOS 8] 리눅스 설치하기 (0) | 2020.06.27 |
댓글 영역