| Version 4 (modified by stappers, 2 years ago) (diff) |
|---|
Networking is about understanding both ends of the line.
Most likely you came here from SmallSteps. So you have debwrt started with
qemu-system-mipsel -M malta -nographic \ -kernel /usr/src/debwrt/build/openwrt-malta-le_Default-trunk-default/build_dir/linux-malta_le/vmlinux.elf \ -hda /usr/src/debwrt/tile -parallel none -m 256 \ -net user -net nic,model=pcnet \ -append "root=/dev/sda1 probe_mask=0x3f init=/sbin/init root_delay=10"
That implies this network configuration (qemu defaults):
- Address: 10.0.2.15
- Netmask: 255.0.0.0
- Router: 10.0.2.2
- Name server: 10.0.2.3
Transforming that to your debwrt system is manual done with these commands
ifconfig eth0 10.0.2.15 netmask 255.0.0.0 route add default gw 10.0.2.2 echo nameserver 10.0.2.3 > /etc/resolv.conf
Making that configuration visible is done with
ifconfig eth0 netstat -r cat /etc/resolv.conf
which looks like
root@debwrt:~# ifconfig eth0 10.0.2.15 netmask 255.0.0.0
root@debwrt:~# route add default gw 10.0.2.2
root@debwrt:~# echo nameserver 10.0.2.3 > /etc/resolv.conf
root@debwrt:~#
root@debwrt:~# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 52:54:00:12:34:56
inet addr:10.0.2.15 Bcast:10.255.255.255 Mask:255.0.0.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:30 errors:0 dropped:0 overruns:0 frame:0
TX packets:30 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:4212 (4.1 KiB) TX bytes:2568 (2.5 KiB)
Interrupt:10 Base address:0x1020
root@debwrt:~# netstat -r
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
10.0.0.0 * 255.0.0.0 U 0 0 0 eth0
default 10.0.2.2 0.0.0.0 UG 0 0 0 eth0
root@debwrt:~# cat /etc/resolv.conf
nameserver 10.0.2.3
root@debwrt:~#
Actual network traffic
wget -O NetworkingSteps.txt http://www.debwrt.net/trac/wiki/NetworkingSteps?format=txt
Will show
Resolving www.debwrt.net... 81.171.37.245 Connecting to www.debwrt.net|81.171.37.245|:80... connected. HTTP request sent, awaiting response... 200 Ok Length: 1965 [text/plain] Saving to: `NetworkingSteps.txt'
Now you known that eth0 works.
host network reconfigure
Real debwrt devices have default the address 192.168.1.1. When your computer has addres example given 192.168.1.2 then you don't have to reconfigure your network.
If your computer has e.g. 172.24.0.21 you can avoid reconfigure by using an IP-alias. It is done by this command
sudo ifconfig eth0:1 192.168.1.2
Checking the host computer network configuration starts now with these commands
/sbin/ifconfig eth0 /sbin/ifconfig eth0:1
will show
eth0 Link encap:Ethernet HWaddr 00:22:15:fd:e4:13
inet addr:172.24.0.21 Bcast:172.24.0.63 Mask:255.255.255.192
inet6 addr: fe80::222:15ff:fefd:e413/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:4282 errors:0 dropped:0 overruns:0 frame:0
TX packets:2207 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:331645 (323.8 KiB) TX bytes:410611 (400.9 KiB)
eth0:1 Link encap:Ethernet HWaddr 00:22:15:fd:e4:13
inet addr:192.168.1.2 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Your desktop computer is now in two IPv4 networks.
Now almost the same thing for qemu, it uses tun/tap devices and network bridges. You need the packages uml-utilities and bridge-utils
sudo aptitude install uml-utilities bridge-utils
Execute the next commands as root
modprobe tun tunctl -u stappers -t tap0 ifconfig tap0 0.0.0.0 brctl addbr br0 brctl addif br0 tap0 ifconfig eth0 0.0.0.0 brctl addif br0 eth0 ifconfig br0 172.24.0.24 netmask 255.255.255.192 ifconfig br0:1 192.168.1.2 netmask 255.255.255.0
Some remarks:
- It is wise to put those commands in a shell script.
- The tunctl with -u stappers means that user stappers becomes owner of the tap device, it is the user that will start qemu.
A succesfull setup will look like
# ifconfig br0
br0 Link encap:Ethernet HWaddr 00:22:15:fd:e4:13
inet addr:172.24.0.24 Bcast:172.24.0.63 Mask:255.255.255.192
inet6 addr: fe80::222:15ff:fefd:e413/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:181786 errors:0 dropped:0 overruns:0 frame:0
TX packets:35089 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:243452147 (232.1 MiB) TX bytes:3080820 (2.9 MiB)
# ifconfig br0:1
br0:1 Link encap:Ethernet HWaddr 00:22:15:fd:e4:13
inet addr:192.168.1.2 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
# brctl show
bridge name bridge id STP enabled interfaces
br0 8000.002215fde413 no eth0
tap0
# brctl showmacs br0
port no mac addr is local? ageing timer
2 00:1f:3f:f3:a6:25 no 107.20
2 00:22:15:fd:e4:13 yes 0.00
1 52:54:00:12:34:56 no 119.66
2 52:55:0a:00:02:02 no 111.52
1 f6:ec:e6:54:6d:5a yes 0.00
#
That is all from the host computer, the machine that will run qemu.
You start qemu with
qemu-system-mipsel -M malta -nographic \ -kernel /usr/src/debwrt/build/openwrt-malta-le_Default-trunk-default/build_dir/linux-malta_le/vmlinux.elf \ -hda /usr/src/debwrt/tile -parallel none -m 256 \ -net user -net nic,model=pcnet \ -net tap,ifname=tap0 \ -append "root=/dev/sda1 probe_mask=0x3f init=/sbin/init rootdelay=2 console=ttyS0,115200 netconsole=6665@192.168.1.1/eth0,6666@192.168.1.2/"
From your configured host, either real or qemu, you can now secure shell to your debwrt instance
ssh root@192.168.1.1
the default password is debwrt