eth0 에 고정 IP 주소할당하기(static IP address)
문제
요약: eth0 에 고정 IP주소(static IP address)를 할당하고자 한다.
지난번 포스팅(http://techlog.gurucat.net/277)을 하면서 판다보드에서 살린 두개의 network interface중에서 eth0 에 '192.168.1.1' 과 같이 고정 IP를 할당하고 싶다.
이유는 PC와 판다보드를 LAN cable을 통해 direct연결 한 후, putty와 같은 툴을 사용해서 ssh shell로 연결 하여 개발을 진행하려고 하는 것이다.
판다보드를 부팅한 후, eth0 에 어떻게 고정 IP를 할당할 수 있는가?
해결
할당하려는 IP는 192.168.1.1 이다.
원래는 bootloader에서 argument 읽은 후 kernel로 argument 전달하는 방식을 택하려 했으나, 일단은 더 간단한 방법을 선택했다.
우선 /etc/network/interfaces 를 편집기로 연다.
root@arm:~# cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
auto lo
iface lo inet loopback
allow-hotplug eth0
iface eth0 inet static
address 192.168.1.1
netmask 255.255.255.0
gateway 192.168.1.255
allow-hotplug wlan0
iface wlan0 inet dhcp
파란 색으로 표시한 것과 같이 기술해 준다.
이상.
재부팅을 하고 확인해보면 아래와 같이 ip address가 할당된 것을 볼 수 있다.
root@arm:~# ifconfig
eth0 Link encap:Ethernet HWaddr c6:f3:ca:97:cf:67
inet addr:192.168.1.1 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::c4f3:caff:fe97:cf67/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:226 errors:0 dropped:0 overruns:0 frame:0
TX packets:32 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:18954 (18.9 KB) TX bytes:4397 (4.3 KB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
wlan0 Link encap:Ethernet HWaddr de:ad:be:ef:00:00
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
그런데.. 문제가 있다.
sshd 가 부팅되면서 시작되었다가 곧바로 종료된다.
그래서 ssh shell을 사용하지 못하고, 아직 serial로 연결해서 작업을 진행중이다.
Next Action Item
sshd의 시작 직후 종료되는 원인을 찾고, sshd가 부팅되면서 정상적으로 실행되도록 수정하는 것이다.