From 8fd74aa1483c7ca7f5376e61e58f5fab1b7a0aca Mon Sep 17 00:00:00 2001 From: yujoo Date: Fri, 7 Aug 2015 11:58:48 +0900 Subject: [PATCH] #7 Add Content :: 2.Setting QEMU bridge.md --- GRUB Guide/2. Setting QEMU bridge.md | 164 ++++++++++++++++++++------- 1 file changed, 125 insertions(+), 39 deletions(-) diff --git a/GRUB Guide/2. Setting QEMU bridge.md b/GRUB Guide/2. Setting QEMU bridge.md index bbdf05e..292b70b 100644 --- a/GRUB Guide/2. Setting QEMU bridge.md +++ b/GRUB Guide/2. Setting QEMU bridge.md @@ -1,30 +1,25 @@ -[Âü°í»çÀÌÆ®](http://www.joinc.co.kr/modules/moniwiki/wiki.php/Site/cloud/Qemu/Network) -
-¿ìºÐÅõ¿¡¼­ Bridge ³×Æ®¿öÅ© ±¸Ãà -------------------------------------------------------------------- -¿ìºÐÅõ¿¡ ºê¸´Áö ³×Æ®¿öÅ©¸¦ ±¸ÃàÇϱâ·Î Çß´Ù. ¾Æ·¡ÀÇ °úÁ¤À» °ÅÄ£´Ù. +**Âü°í »çÀÌÆ®** ``` -1. È£½ºÆ® ºê¸´ÁöÀÎ br0¸¦ ¸¸µç´Ù. -2. br0¸¦ eth0 Æ÷Æ®¿¡ ¸µÅ©ÇÑ´Ù. -3. VMÀ» À§ÇÑ tap µð¹ÙÀ̽º 2°³¸¦ ¸¸µç´Ù. À̸§Àº tap1°ú tap2·Î Çß´Ù. -4. br0¿¡ tap1, tap2, eth0À» ¹­´Â´Ù. +http://www.joinc.co.kr/modules/moniwiki/wiki.php/Site/System_management/dhcp +http://www.joinc.co.kr/modules/moniwiki/wiki.php/Site/System_management/PXEBoot ```
-###*1. brctlÀ» ÀÌ¿ëÇؼ­ ºê¸´Áö¸¦ ¸¸µç´Ù.* +**Çʼö** +``` +- sudo apt-get update +- sudo apt-get upgrade ``` -# brctl addbr br0 -# ifconfig br0 up +
+# sudo brctl addbr br0 +# sudo ifconfig br0 up ```
-###*2. ºê¸´Áö ÀÎÅÍÆäÀ̽º¸¦ ¼³Á¤ÇÑ´Ù.* -1. eth0 °ú ºê¸´Áö ÇÑ´Ù. -2. dhcp¸¦ ÀÌ¿ëÇؼ­ ºê¸´ÁöÀÇ ³×Æ®¿öÅ©¸¦ ¼³Á¤ÇÑ´Ù. dhcp ÆÐŶÀº eth0À» Ÿ°í ³ª°¡¼­ ºê·Îµåij½ºÆà µÈ´Ù. +###*2. ºê¸´Áö ÀÎÅÍÆäÀ̽º¸¦ ¼³Á¤* ``` -# vim /etc/network/interfaces +# sudo vim /etc/network/interfaces ``` -¢º interfacesÀÇ ³»¿ë +**interfaces¿¡ Ãß°¡ÇÒ °Í** ``` -# cat /etc/network/interfaces auto lo iface lo inet loopback @@ -35,62 +30,153 @@ iface br0 inet dhcp bridge_fd 0 bridge_maxwait 0 ``` -
+1. eth0 °ú ºê¸´Áö ÇÑ´Ù. +2. dhcp¸¦ ÀÌ¿ëÇؼ­ ºê¸´ÁöÀÇ ³×Æ®¿öÅ©¸¦ ¼³Á¤ÇÑ´Ù. dhcp ÆÐŶÀº eth0À» Ÿ°í ³ª°¡¼­ ºê·Îµåij½ºÆà µÈ´Ù. + ###*3. ºê¸´Áö ÀÎÅÍÆäÀ̽º¸¦ ¿Ã¸°´Ù.* ``` -# ifup br0 +# sudo ifup br0 ```
-###*4. eth0ÀÌ Çß´ø ³×Æ®¿öÅ© ÀÎÅÍÆäÀ̽ºÀÇ ¿ªÇÒÀº ¾ÕÀ¸·Î br0ÀÌ ÇÏ°í eth0Àº ¹°¸®ÀûÀÎ µð¹ÙÀ̽º¸¦ ¸µÅ©Çϱâ À§ÇÑ ¿ªÇÒ¸¸À» ÇÑ´Ù. µû¶ó¼­ eth0ÀÇ ³×Æ®¿öÅ© ¼³Á¤À» ¾ø¾Ø´Ù.* +###*4. eth0ÀÇ ³×Æ®¿öÅ© ¼³Á¤À» ¾ø¾Ø´Ù.* +ÀÌÀ¯ : eth0ÀÌ Çß´ø ³×Æ®¿öÅ© ÀÎÅÍÆäÀ̽ºÀÇ ¿ªÇÒÀº ¾ÕÀ¸·Î br0ÀÌ ÇÏ°í eth0Àº ¹°¸®ÀûÀÎ µð¹ÙÀ̽º¸¦ ¸µÅ©Çϱâ À§ÇÑ ¿ªÇÒ¸¸À» ÇÑ´Ù. ``` -# ifconfig eth0 0.0.0.0 +# sudo ifconfig eth0 0.0.0.0 ```
###*5. Tap interface »ý¼º* ``` -# openvpn --mktun --dev tap1 -# openvpn --mktun --dev tap2 -# ifconfig tap1 up -# ifconfig tap2 up +# sudo openvpn --mktun --dev tap0 +# sudo ifconfig tap0 192.168.56.1 up ```
-###*6. ºê¸´Áö¿¡ ÀÎÅÍÆäÀ̽ºµéÀ» Ãß°¡ÇÑ´Ù.* +###*6.ºê¸´Áö¿¡ ÀÎÅÍÆäÀ̽ºµéÀ» Ãß°¡* ``` -# brctl addif br0 tap1 -# brctl addif br0 tap2 -# brctl addif br0 eth0 +# sudo brctl addif br0 tap0 +# sudo brctl addif br0 eth0 ```
-###*7. ³×Æ®¿öÅ© ºê¸´Áö Á¤º¸¸¦ È®ÀÎÇØ º¸ÀÚ.* +###*7. ³×Æ®¿öÅ© ºê¸´Áö Á¤º¸¸¦ È®ÀÎ* ``` # brctl show +``` +**Ãâ·Â °ª** +``` bridge name bridge id STP enabled interfaces br0 8000.d2a4aba39cf4 no eth0 tap1 tap0 ```
-###*8. È£½ºÆ®ÀÇ ¶ó¿ìÆà ¼³Á¤À» È®ÀÎÇØ º¸ÀÚ.* +###*8. È£½ºÆ®ÀÇ ¶ó¿ìÆà ¼³Á¤À» È®ÀÎ* ``` # route -n +``` +**Ãâ·Â °ª** +``` Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.11.1 0.0.0.0 UG 0 0 0 br0 169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 br0 192.168.11.0 0.0.0.0 255.255.255.0 U 0 0 0 br0 ``` -¢º 0.0.0.0/0À¸·Î ÇâÇÏ´Â ÆÐŶÀº br0 À¸·Î È帥´Ù. br0Àº ÀÌ ÆÐŶÀ» eth0 ÀÎÅÍÆäÀ̽º·Î º¸³¾ °ÍÀÌ´Ù. -¢º 192.168.11.0/24·Î ÇâÇÏ´Â ÆÐŶÀº LAN ¿µ¿ª¿¡¼­ ¼ÒºñµÈ´Ù. +0.0.0.0/0À¸·Î ÇâÇÏ´Â ÆÐŶÀº br0 À¸·Î È帥´Ù. br0Àº ÀÌ ÆÐŶÀ» eth0 ÀÎÅÍÆäÀ̽º·Î º¸³¾ °ÍÀÌ´Ù. +192.168.11.0/24·Î ÇâÇÏ´Â ÆÐŶÀº LAN ¿µ¿ª¿¡¼­ ¼ÒºñµÈ´Ù. +Å×½ºÆ®¸¦ À§ÇÑ VMÀ» ½ÇÇàÇÑ´Ù. VMµéÀÇ ³×Æ®¿öÅ© ¼³Á¤Àº DHCP·Î ÇÑ´Ù. +
+###*9. TFTP ¼­¹ö ¼³Á¤* +``` +# sudo apt-get install tftp +# sudo apt-get install tftpd +# cat /etc/xinetd.d/tftp +``` +**tftp¿¡ Ãß°¡ÇÒ °Í** +``` +service tftp +{ + disable = no + socket_type = dgram + protocol = udp + wait = yes + user = root + server = /usr/sbin/in.tftpd + server_args = -s /srv/tftpboot + per_source = 11 + cps = 100 2 + flags = IPv4 +} +``` +
+###*10. DHCP ¼³Á¤* +``` +sudo apt-get install isc-dhcp-server +sudo vim /etc/dhcp/dhcpd.conf +``` +**decpd.conf¿¡ Ãß°¡ÇÒ °Í** +``` +#ddns-update-style none; + +option domain-name "yujoonote.tistory.com"; +option domain-name-servers 8.8.8.8, 8.8.6.6; +option routers 192.168.56.1; +option subnet-mask 255.255.255.0; + +default-lease-time 60; +max-lease-time 72; + +allow bootp; +allow booting; + +subnet 192.168.56.0 netmask 255.255.255.0 { + range 192.168.56.10 192.168.56.20; + option routers 192.168.56.1; + host pxe-bootos { + hardware ethernet 52:00:00:00:00:01; + filename "boot/grub/i386-pc/core.0"; + } +} +```
-###*9. Å×½ºÆ®¸¦ À§ÇÑ VMÀ» ½ÇÇàÇÑ´Ù. VMµéÀÇ ³×Æ®¿öÅ© ¼³Á¤Àº DHCP·Î ÇÑ´Ù.* +###*11. DHCP ¼­¹ö Àç½ÃÀÛ* ``` -# qemu-system-i386 -m 512 -hda brdist-img.raw -net nic,macaddr=52:00:00:00:00:01 -net tap,ifname=tap1,script=no -boot n +sudo /etc/init.d/isc-dhcp-server restart +qemu-system-i386 -m 512 -net nic,macaddr=52:00:00:00:00:01 -net tap,ifname=tap0,script=no -boot n ```
-###*10. ½ÇÇàµÈ °¡»ó¸Ó½ÅÀº ´ÝÁö ¾ÊÀº »óÅ¿¡¼­ »õ·Î¿î Å͹̳ÎÀ» »ý¼ºÇØ, ºê¸´ÁöÀÇ MAC Å×ÀÌºí¿¡ VMÀÇ ¸ÆÀÌ Æ÷ÇԵƴÂÁö È®ÀÎÇØ º¸ÀÚ.* +###*12. tftp ÆÄÀÏ »ý¼º* ``` -# brctl showmacs br0 +# cd SecurityBootloader/ +# vim tftp +``` +**tftp¿¡ Ãß°¡ÇÒ °Í** +``` +#!/bin/bash +sudo ~/g2/usr/bin/grub-mknetdir --net-directory=/srv/tftpboot --subdir=boot/grub --modules=tftp ```
+###*13. tftp ±ÇÇÑ ºÎ¿©* +``` +# chmod a+x tftp +# ll tftp +# ./tftp <= grub¸¦ pxe·Î ºÎÆÃÇÒ ¼ö ÀÖµµ·Ï coreÆÄÀÏÀ» ¸¸µç´Ù. ³»ºÎÀûÀ¸·Î mkimage¸¦ ¸¸µç´Ù. +```
-**ÀÌ Å×½ºÆ®´Â ÇϳªÀÇ VLAN¿¡¼­ ÀÌ·ç¾îÁ³´Ù. VLANÀ» ÂÉ°³´Â ¹æ½ÄÀ¸·Î Multi-tenant ÀÀ¿ëÀÌ °¡´É ÇÒ°Å´Ù.** +###*14. tftp µ¿ÀÛ È®ÀÎ* +``` +sudo nmap localhost + +sudo apt-get install tftpd-hpa +sudo service tftpd-hpa restart + +qemu-system-i386 -m 512 -net nic,macaddr=52:00:00:00:00:01 -net tap,ifname=tap0,script=no -boot n +``` + +###*ÀçºÎÆýÃ* +``` +sudo openvpn --mktun --dev tap0 +sudo ifconfig tap0 192.168.56.1 up +sudo /etc/init.d/isc-dhcp-server restart +qemu-system-i386 -m 512 -net nic,macaddr=52:00:00:00:00:01 -net tap,ifname=tap0,script=no -boot n +``` + +