-
-
Save gedex/4356077 to your computer and use it in GitHub Desktop.
script to start UML (User Mode Linux).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ifconfig | |
eth0 Link encap:Ethernet HWaddr 00:50:fc:99:96:e3 | |
inet addr:10.0.0.1 Bcast:10.255.255.255 Mask:255.0.0.0 | |
inet6 addr: fe80::250:fcff:fe99:96e3/64 Scope:Link | |
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 | |
RX packets:36311 errors:0 dropped:0 overruns:0 frame:0 | |
TX packets:36902 errors:0 dropped:0 overruns:0 carrier:0 | |
collisions:0 txqueuelen:1000 | |
RX bytes:24450223 (24.4 MB) TX bytes:6426466 (6.4 MB) | |
Interrupt:16 Base address:0xe800 | |
tap0 Link encap:Ethernet HWaddr da:d3:37:23:d3:35 | |
inet addr:10.0.0.1 Bcast:10.255.255.255 Mask:255.0.0.0 | |
inet6 addr: fe80::d8d3:37ff:fe23:d335/64 Scope:Link | |
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 | |
RX packets:17 errors:0 dropped:0 overruns:0 frame:0 | |
TX packets:39 errors:0 dropped:0 overruns:0 carrier:0 | |
collisions:0 txqueuelen:500 | |
RX bytes:4230 (4.2 KB) TX bytes:6323 (6.3 KB) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ifconfig eth0 10.0.0.2 up | |
$ route add default gw 10.0.0.1 | |
# Now UML should be able to connect to outside world |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# TODO: | |
# Set var for tuntap dev name instead of hardcoded 'tap0'. | |
# Set var for IP ADDR for tuntap dev | |
# Set var for tuntap dev owner | |
# Set var for host's dev name in which connected to gw internet | |
# Global vars | |
KERNEL_BIN=/home/akeda/Learn/user-linux-mode/kernel-3.2.35/kernel32-3.2.35 | |
DEBIAN_FS_FILE=/home/akeda/Learn/user-linux-mode/kernel-3.2.35/Debian-Squeeze-x86-root_fs | |
ALLOCATED_MEM_SIZE=512M | |
echo 'Setting up tap0' | |
sudo tunctl -d tap0 | |
sudo tunctl -u akeda -t tap0 | |
sudo ifconfig tap0 10.0.0.1 up | |
echo 'Seting up iptables' | |
sudo iptables --flush | |
sudo iptables --table nat --flush | |
sudo iptables --delete-chain | |
sudo iptables --table nat --delete-chain | |
sudo iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE | |
sudo iptables --append FORWARD --in-interface tap0 -j ACCEPT | |
echo 'Enabling IP forwarding' | |
sudo sysctl net.ipv4.ip_forward=1 | |
sudo sysctl net.ipv4.conf.tap0.proxy_arp=1 | |
sudo arp -Ds 10.0.0.2 eth0 pub | |
sudo route add -host 10.0.0.2 dev tap0 | |
echo 'Running Debian UML' | |
CMD="$KERNEL_BIN ubda=$DEBIAN_FS_FILE mem=$ALLOCATED_MEM_SIZE eth0=tuntap,tap0,,10.0.0.1 umid=debian" | |
$CMD |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment