
CentOS 7에서 실행되는 QEMU 중 하나에 대한 브리지 인터페이스를 설정하려고 합니다. TAP 인터페이스 실행을 위한 스크립트가 아래에 있습니다.
$ cat /etc/qemu-ifup
ifconfig ens192 down
ifconfig ens192 0.0.0.0 promisc up
openvpn --mktun --dev tap0
ifconfig tap0 0.0.0.0 up
brctl addbr br0
brctl addif br0 ens192
brctl addif br0 tap0
brctl stp br0 off
ifconfig br0 192.168.42.201 netmask 255.255.255.0
이제 QEMU 시스템을 실행하기 전에 브리지 인터페이스를 시작하고 실행할 수 있도록 이 스크립트를 실행합니다. 다른 호스트에서 이 인터페이스를 ping할 수 있습니다. 아래는 출력입니다
$ ifconfig
br0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.42.201 netmask 255.255.255.0 broadcast 192.168.42.255
inet6 fe80::646a:f6ff:fe1e:42ce prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:1f:e0:db txqueuelen 0 (Ethernet)
RX packets 314 bytes 15522 (15.1 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 38 bytes 4803 (4.6 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ens192: flags=4419<UP,BROADCAST,RUNNING,PROMISC,MULTICAST> mtu 1500
ether 00:0c:29:1f:e0:db txqueuelen 1000 (Ethernet)
RX packets 258 bytes 16020 (15.6 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 92 bytes 8269 (8.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 0 (Local Loopback)
RX packets 7404 bytes 108578604 (103.5 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 7404 bytes 108578604 (103.5 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
tap0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::e8d9:3ff:fedf:85d3 prefixlen 64 scopeid 0x20<link>
ether ea:d9:03:df:85:d3 txqueuelen 100 (Ethernet)
RX packets 69 bytes 4722 (4.6 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 193 bytes 12111 (11.8 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether 02:a1:9f:a4:81:bc txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1 bytes 90 (90.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
다음은 다른 호스트(예: 192.168.42.12)의 ping 출력입니다.
# ping 192.168.42.201
PING 192.168.42.201 (192.168.42.201) 56(84) bytes of data.
64 bytes from 192.168.42.201: icmp_seq=1 ttl=64 time=1.19 ms
64 bytes from 192.168.42.201: icmp_seq=2 ttl=64 time=0.369 ms
이제 아래는 QEMU를 실행하기 위해 실행한 명령입니다.
/home/test/yocto/poky/build/tmp/sysroots/x86_64-linux/usr/bin/qemu-system-arm -kernel /home/test/yocto/poky/build/tmp/deploy/images/qemuarm/zImage-qemuarm.bin -net nic,vlan=0 -net tap,vlan=0,ifname=tap0,script=no,downscript=no -M versatilepb -hda /home/test/yocto/poky/build/tmp/deploy/images/qemuarm/core-image-minimal-dev-qemuarm-20141124054625.rootfs.ext3 -no-reboot -show-cursor -usb -usbdevice wacom-tablet -no-reboot -m 128 --append "root=/dev/sda rw console=ttyAMA0,115200 console=tty mem=128M highres=off "
또한 iptables를 중지하고 QEMU 시스템(192.168.42.202) 또는 다른 호스트에서 호스트에 ping을 시도했지만 연결할 수 없습니다.
# ping 192.168.42.202
PING 192.168.42.202 (192.168.42.202) 56(84) bytes of data.
^C
--- 192.168.42.202 ping statistics ---
670 packets transmitted, 0 received, 100% packet loss, time 669735ms
따라서 이 문제를 해결하려는 생각이 있으신가요?
답변1
마침내 OpenVPN 터널 메커니즘을 통해 이 문제를 해결할 수 있었습니다. 그래서 참고로 솔루션을 올려드립니다. 더 있을 수 있으므로 이것은 그 중 하나일 수 있습니다.
- Epel RPM을 설치한 다음 openvpn 패키지를
yum install openvpn
. - 이제 샘플 브리지 시작 스크립트(에서 찾을 수 있음
/usr/share/doc/openvpn<version>/sample-scripts
)를 아래와 같이 수정합니다.
#!/bin/bash
# Define Bridge Interface
br="br0"
# Define list of TAP interfaces to be bridged,
# for example tap="tap0 tap1 tap2".
tap="tap0"
# Define physical ethernet interface to be bridged
# with TAP interface(s) above.
eth="eth0" #<== Change it with your physical ethernet device.
eth_ip="192.168.8.4/24" #<== Update this with the address which you want to use it.
# create the bridge interface, assign the ip address for it, and enable
ip link add name $br type bridge
ip address add $eth_ip dev $br
ip link set dev $br up
# add eth interface into the bridge
ip link set dev $eth master $br
ip link set dev $eth up
# create the tap interfaces and add they into the bridge
for t in $tap; do
openvpn --mktun --dev $t
ip link set dev $t master $br
ip link set dev $t up
done
exit 0
유사한 브리지 중지 스크립트가 있습니다. 탭 장치와 브리지를 제거하는 데 사용할 수 있습니다.
이제 실행 가능하게 만들고 ./bridge-start로 실행합니다. 시작 Qemu를 실행하기 전에.
이제 TAP 장치 즉, Qemu를 시작하십시오
tap0
. 다른 호스트 및 장치와 통신할 수 있습니다.
자세한 내용은 다음을 참조하세요.OpenVPN 이더넷 브리지 네트워킹