본문으로 바로가기

환경

운영체제 , 네트워크 정보입니다.

pi@raspberrypi:~ $ uname -a
Linux raspberrypi 4.19.118-v7+ #1311 SMP Mon Apr 27 14:21:24 BST 2020 armv7l GNU/Linux

pi@raspberrypi:~ $ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"
pi@raspberrypi:~ $ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.254.15  netmask 255.255.255.0  broadcast 192.168.254.255
        inet6 fe80::42f8:452c:3cac:f11  prefixlen 64  scopeid 0x20<link>
        ether b8:27:eb:f5:a1:9e  txqueuelen 1000  (Ethernet)
        RX packets 285  bytes 24119 (23.5 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 238  bytes 37458 (36.5 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

 

환경설정

sudo vi /etc/dhcpcd.conf

더보기
pi@raspberrypi:~ $ sudo vi /etc/dhcpcd.conf

# A sample configuration for dhcpcd.
# See dhcpcd.conf(5) for details.

# Allow users of this group to interact with dhcpcd via the control socket.
#controlgroup wheel

# Inform the DHCP server of our hostname for DDNS.
hostname

# Use the hardware address of the interface for the Client ID.
clientid
# or
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 ClientID as per RFC4361.
# Some non-RFC compliant DHCP servers do not reply with this set.
# In this case, comment out duid and enable clientid above.
#duid

# Persist interface configuration when dhcpcd exits.
persistent

# Rapid commit support.
# Safe to enable by default because it requires the equivalent option set
# on the server to actually work.
option rapid_commit

# A list of options to request from the DHCP server.
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
# Respect the network MTU. This is applied to DHCP routes.
option interface_mtu

# Most distributions have NTP support.
#option ntp_servers

# A ServerID is required by RFC2131.
require dhcp_server_identifier

# Generate SLAAC address using the Hardware Address of the interface
#slaac hwaddr
# OR generate Stable Private IPv6 Addresses based from the DUID
slaac private

# Example static IP configuration:
#interface eth0
#static ip_address=192.168.0.10/24
#static ip6_address=fd51:42f8:caae:d92e::ff/64
#static routers=192.168.0.1
#static domain_name_servers=192.168.0.1 8.8.8.8 fd51:42f8:caae:d92e::1

# It is possible to fall back to a static IP if DHCP fails:
# define static profile
#profile static_eth0
#static ip_address=192.168.1.23/24
#static routers=192.168.1.1
#static domain_name_servers=192.168.1.1

# fallback to static profile on eth0
#interface eth0
#fallback static_eth0

 

수정할 부분입니다.

/etc/dhcpcd.conf

 

다음과 같이 수정하여 저장합니다.

static ip_address=x.x.x.x/24 (사용할 IP)

static routers=x.x.x.x (게이트웨이 IP)

/etc/dhcpcd.conf

 

게이트웨이 및 라우팅 정보는 다음 명령어로 확인할 수 있습니다.

ip route or route

 

재시작

네트워크를 재시작합니다.

sudo systemctl restart networking

재시작했는데 IP 가 변경되지 않았습니다.

 

다음 명령어로 라즈베리파이를 재부팅합니다.

sudo init 6

정상적으로 변경되었습니다.