이름 기반 가상 호스팅을 위해 CentOS Linux 시스템에 가상 인터페이스를 만들려고 합니다. 아래에서 장치 정보를 확인하세요.
DEVICE=eth0
BOOTPROTO=dhcp
HWADDR=00:0c:29:4e:1c:14
MTU=1500
NM_CONTROLLED=yes
ONBOOT=yes
TYPE=Ethernet
USERCTL=no
PEERDNS=yes
IPV6INIT=no
DEVICE=eth0:1
BOOTPROTO=none
IPADDR=192.168.1.5
NETMASK=255.255.255.0
NM_CONTROLLED=yes
ONBOOT=no
HWADDR=00:0C:29:4E:1C:14
TYPE=Ethernet
PREFIX=24
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth0:1"
UUID=7758ac79-c4a2-dd87-1760-71284a316d00
ifconfig를 실행하면 가상 장치 eth0:1이 표시되지 않습니다.
[root@centos network-scripts]# ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:0C:29:4E:1C:14
inet addr:192.168.1.3 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe4e:1c14/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:24368 errors:0 dropped:0 overruns:0 frame:0
TX packets:21884 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:9793531 (9.3 MiB) TX bytes:4460526 (4.2 MiB)
Interrupt:19 Base address:0x2000
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:799 errors:0 dropped:0 overruns:0 frame:0
TX packets:799 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:82196 (80.2 KiB) TX bytes:82196 (80.2 KiB)
pan0 Link encap:Ethernet HWaddr EE:75:AD:75:9C:84
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:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
sit0 Link encap:IPv6-in-IPv4
NOARP MTU:1480 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)
내가 놓칠 수 있는 것이 무엇인지에 대한 아이디어.
----------편집 1:-
Linux 상자를 다시 시작하면 아래와 같이 구성된 모든 가상 인터페이스를 볼 수 있습니다.- 시스템을 다시 시작한 후:-
[root@centos ~]# date
Tue Apr 30 21:25:16 PDT 2013
[root@centos ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:4E:1C:14
inet addr:192.168.1.3 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe4e:1c14/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:97 errors:0 dropped:0 overruns:0 frame:0
TX packets:117 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:9756 (9.5 KiB) TX bytes:17204 (16.8 KiB)
Interrupt:19 Base address:0x2000
eth0:1 Link encap:Ethernet HWaddr 00:0C:29:4E:1C:14
inet addr:192.168.1.10 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:19 Base address:0x2000
eth0:2 Link encap:Ethernet HWaddr 00:0C:29:4E:1C:14
inet addr:192.168.1.40 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:19 Base address:0x2000
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:4 errors:0 dropped:0 overruns:0 frame:0
TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:240 (240.0 b) TX bytes:240 (240.0 b)
그러나 완료 후 system-network-restart
모든 설정이 사라졌습니다. 명령을 실행한 후 다음 결과를 찾으십시오.
[root@centos ~]# service network restart
Shutting down interface eth0: Device state: 3 (disconnected)
[ OK ]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0: Active connection state: activating
Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/1
state: activated
Connection activated
[root@centos ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:4E:1C:14
inet addr:192.168.1.3 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe4e:1c14/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:290 errors:0 dropped:0 overruns:0 frame:0
TX packets:292 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:25640 (25.0 KiB) TX bytes:41720 (40.7 KiB)
Interrupt:19 Base address:0x2000
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:4 errors:0 dropped:0 overruns:0 frame:0
TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:240 (240.0 b) TX bytes:240 (240.0 b)
답변1
당신은 설정해야
ONBOOT=yes
그런 다음 네트워크 서비스를 시작/다시 시작하면 인터페이스가 시작되거나 다음을 사용하여 인터페이스를 수동으로 시작할 수 있습니다.
ifup eth0:1
다운 재킷의 경우
ifdown eth0:1
답변2
BOOTPROTO=none
으로 변경해야 합니다 BOOTPROTO=static
.
답변3
가상 인터페이스(별칭 장치라고도 함)는 자체 별도 파일에 있어야 합니다.ifcfg-eth0:1이와 같이:
# /etc/sysconfig/network-scripts/ifcfg-eth0:1
DEVICE=eth0:1
BOOTPROTO=static
IPADDR=192.168.1.5
NETMASK=255.255.255.0
NM_CONTROLLED=yes
ONBOOT=yes
HWADDR=00:0C:29:4E:1C:14
TYPE=Ethernet
PREFIX=24
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth0:1"
UUID=7758ac79-c4a2-dd87-1760-71284a316d00