스터디 용 블로그
VirtualBox 리눅스 인터넷 연결 본문
반응형
VirtualBox 리눅스 인터넷 연결
문제상황
VirtualBox에 리눅스를 설치했는데[1] 인터넷 연결이 안된다.
[root@localhost ~]# ping 8.8.8.8
connect: Network is unreachable
- → 인터넷상 IP인 8.8.8.8로 접근이 되지 않는다. 인터넷과 연결되지 않았기 때문이다.
확인
[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 가 시작되지 않는다.
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이다.
테스트
[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도 잘 연결되고 있다.
영구 적용
재부팅시에도 eth0가 자동으로 시작되게 하려면 ifcfg-eth0 파일을 수정해야 한다.
[root@localhost ~]# cp /etc/sysconfig/network-scripts/ifcfg-eth0 /root/ifcfg-eth0.old [root@localhost ~]# sed -i 's/ONBOOT="no"/ONBOOT="yes"/g' /etc/sysconfig/network-scripts/ifcfg-eth0
- → 기존 설정을 /root/에 보존
- → ifcfg-eth0 에서 ONBOOT="no"를 찾아 ONBOOT="yes"로 수정.
- 확인
[root@localhost ~]# diff /root/ifcfg-eth0.old /etc/sysconfig/network-scripts/ifcfg-eth0 5c5 < ONBOOT="no" --- > ONBOOT="yes"
후속 작업
ifdown eth0 (이더넷인터페이스이름)
ifup eth0
후 ping 때려보기
리눅스 ifup
/sbin/ifup
/etc/sysconfig/network-scripts/ifup
리눅스 ifdown
/sbin/ifdown
/etc/sysconfig/network-scripts/ifdown
반응형
'리눅스' 카테고리의 다른 글
리눅스 phpMyAdmin 설치 (yum) (0) | 2015.05.12 |
---|---|
[CentOS] 네트워크 설정 (0) | 2015.05.12 |
CentOS 6 최소 설치 VirtualBox 게스트 확장 설치 (0) | 2015.05.12 |
VirtualBox 리눅스 SSH 연결 (브리지) (0) | 2015.05.12 |
nano 단축키 (0) | 2015.01.15 |
Comments