Ramanu

qemu boot 명령어와 qemu 내부 network 세팅(Static, Dynamic) 본문

가상화

qemu boot 명령어와 qemu 내부 network 세팅(Static, Dynamic)

Ramanu 2021. 1. 14. 16:18

# env = mips big endian, qemu, tap

 

1. Static IP Setting

- ubuntu network setting & qemu argument

#!/bin/sh

openvpn --mktun --dev tap0 
ifconfig tap0 192.168.100.1 up 

iptables -t nat -A PREROUTING -i ens33 -p tcp -j DNAT --to-destination 192.168.100.2 
iptables -t nat -A POSTROUTING -j MASQUERADE 

qemu-system-mips -M malta -kernel vmlinux -hda debian_squeeze_mips_standard.qcow2 -append "root=/dev/hda1 console=ttyS0" -net nic -net tap,ifname=tap0 -net socket,listen=localhost:1234 -nographic

 

- qemu /etc/network/interfaces

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
	address 192.168.100.2
	netmask 255.255.255.0
	gateway 192.168.100.1

ubuntu 패킷을 qemu로 전부 전송한다는 느낌의 세팅

 

# 가끔씩 qemu에서 ping 8.8.8.8이 안되는 경우가 있는데 ubuntu에서 ipv4세팅이 안되서 그럴수도 있다.

# echo 1 > /proc/sys/net/ipv4/ip_forward

 

 

 

2. Dynamic IP Setting(DHCP)

 

- ubuntu network setting ( /etc/nerwork/interfaces)

auto br0
iface br0 inet dhcp
        bridge_ports ens33
        bridge_stp off
        bridge_fd 0
        bridge_maxwait 0

- qemu argument

#!/bin/sh

openvpn --mktun --dev tap0
ifconfig tap0 up
brctl addif eth0 tap0

qemu-system-mips -M malta -kernel vmlinux-2.6.32-5-4kc-malta -hda debian_squeeze_mips_standard.qcow2 -append "root=/dev/sda1 console=ttyS0" -net nic -net tap,ifname=tap0 -net socket,listen=localhost:1234 -nographic

 

- qemu /etc/network/interface

auto lo
iface lo inet loopback

allow-hotplug eth0
iface eth0 inet dhcp

 

'가상화' 카테고리의 다른 글

ssh root 접속 방법  (0) 2021.01.26
QEMU 가상화 이미지 실행 명령어  (0) 2021.01.26
QEMU MAC Address 충돌문제  (0) 2021.01.25
ubuntu 18.04 rc.local 사용방법  (0) 2021.01.22
qemu 이미지  (0) 2021.01.05
Comments