VirtualBox 리눅스 인터넷 연결 확인
OS/Linux2017. 10. 1. 13:49
1 문제상황
VirtualBox에 리눅스를 설치했는데[1] 인터넷 연결이 안된다.
[root@localhost ~]# ping 8.8.8.8
connect: Network is unreachable
- → 인터넷상 IP인 8.8.8.8로 접근이 되지 않는다. 인터넷과 연결되지 않았기 때문이다.
2 확인
[root@localhost ~]# ifconfig
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:16436 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:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
- → lo 밖에 보이지 않는다.
[root@localhost ~]# ifconfig -a
eth0 Link encap:Ethernet HWaddr 08:00:27:F8:4A:51
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)
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:16436 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:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
- → -a 옵션을 주어 실행하니, eth0가 있기는 한데 UP 상태가 아니다.
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
BOOTPROTO="dhcp"
HWADDR="08:00:27:F8:4A:51"
NM_CONTROLLED="yes"
ONBOOT="no"
TYPE="Ethernet"
UUID="123d4fbd-e5c6-4732-a723-6210af2738ea"
- → eth0 설정을 보니, dhcp를 통해 자동으로 IP를 부여받도록 되어 있다.
- → ONBOOT가 no로 되어 있어 부팅시에 eth0 가 시작되지 않는다.
3 eth0 시작
[root@localhost ~]# ifup eth0
Determining IP information for eth0... done.
- → eth0를 시작하였다.
[root@localhost ~]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 08:00:27:F8:4A:51
inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fefd:beb3/64 Scope:Link
UP BROADCAST RUNING MULTICAST MTU:1500 Metric:1
RX packets:2 errors:0 dropped:0 overruns:0 frame:0
TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1180 (1.1 KiB) TX bytes:1236 (1.2 KiB)
- → eth0가 UP 상태인 것을 확인할 수 있다.
- → dhcp로 받아온 IP는 10.0.2.15이다.
4 테스트
[root@localhost ~]# ping 8.8.8.8 -c2
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_req=13 ttl=29 time=323 ms
64 bytes from 8.8.8.8: icmp_req=14 ttl=29 time=339 ms
--- 8.8.8.8 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1447ms
rtt min/avg/max/mdev = 323.499/331.351/339.204/7.873 ms
- → 인터넷과 연결이 되었다.
[root@localhost ~]# ping google.com -c2
PING google.com (74.125.142.102) 56(84) bytes of data.
64 bytes from ie-in-f102.1e100.net (74.125.142.10): icmp_req=1 ttl=43 time=234 ms
64 bytes from ie-in-f102.1e100.net (74.125.142.10): icmp_req=2 ttl=43 time=215 ms
--- google.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1374ms
rtt min/avg/max/mdev = 215.349/224.783/234.218/9.446 ms
- → 도메인으로도 잘 된다. 즉 DNS도 잘 연결되고 있다.
5 영구 적용
재부팅시에도 eth0가 자동으로 시작되게 하려면 ifcfg-eth0 파일을 수정해야 한다.
[root@localhost ~]# cp /etc/sysconfig/network-scripts/ifcfg-eth0 /root/ifcfg-eth0.old
- → 기존 설정을 /root/에 보존
[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
# ONBOOT="no"
ONBOOT="yes"
- → ifcfg-eth0 에서 ONBOOT="no"를 찾아 ONBOOT="yes"로 수정하고 저장[2]
- 확인
[root@localhost ~]# diff /root/ifcfg-eth0.old /etc/sysconfig/network-scripts/ifcfg-eth0
5c5
< ONBOOT="no"
---
> ONBOOT="yes"
참고 URL -
https://zetawiki.com/wiki/VirtualBox_CentOS_6_%EC%84%A4%EC%B9%98
'OS > Linux' 카테고리의 다른 글
centos 6.9 최소 설치 후 환경설정 (0) | 2017.10.03 |
---|---|
centos GPG-KEY 에러 (0) | 2017.10.03 |
CentOs 6.8 tomcat+java+jsp 연동 (0) | 2016.12.31 |
가비아 리눅스 서버 세팅 예제 (0) | 2016.09.28 |
특정 파일(PHP)의 특정 폴더 실행 막기 (Linux Ver) (0) | 2016.08.07 |