kayws426 / embox

Automatically exported from code.google.com/p/embox
0 stars 1 forks source link

Using many ethernet interfaces problem (not ping) #551

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I modify file ../qemu/auto_qemu to use many eth interfaces:

#!/bin/bash

# Change working direcory to scripts/qemu
cd "$(dirname "$0")"

QEMU=qemu-system-i386
IMAGE=../../build/base/bin/embox
EMBOX_MODS_CONF=../../conf/mods.config

# Checking for network driver

for DRIVER in "ne2k_pci" "e1000" "rtl8139"
do
grep embox.driver.net.$DRIVER $EMBOX_MODS_CONF > /dev/null
if [ $? -eq 0 ]; then
QEMU_NET_DRIVER=$DRIVER
break
fi
done

if ! [ "$QEMU_NET_DRIVER"  ]; then
echo "auto_qemu: No supported network drivers in $EMBOX_MODS_CONF"
exit 1
fi

# Checking for KVM and VT support

egrep '(vmx|svm)' /proc/cpuinfo > /dev/null

if [ $? -ne 0 ]; then
echo "auto_qemu: VT is not supported by CPU"
else
QEMU_KVM_ENABLE="-enable-kvm"
fi

dmesg | tail | grep "kvm: disabled by bios" > /dev/null

if [ $? -eq 0 ]; then
echo "auto_qemu: kvm: disabled by bios. You can enable VT in bios"
QEMU_KVM_ENABLE=""
fi

lsmod | egrep '(kvm_intel|kvm_amd)' > /dev/null

if [ $? -ne 0 ]; then
echo "auto_qemu: No kvm_intel [kvm_amd] kernel module"
QEMU_KVM_ENABLE=""
fi

# Run qemu

sudo $QEMU $QEMU_KVM_ENABLE -kernel $IMAGE \
 -net nic,vlan=0,model=$QEMU_NET_DRIVER,macaddr=AA:BB:CC:DD:EE:02 \
 -net tap,vlan=0,name=tap0,script=start_script,downscript=stop_script \
 -net nic,vlan=1,model=$QEMU_NET_DRIVER,macaddr=AA:BB:CC:DD:EE:04 \
 -net tap,vlan=1,name=tap1,script=start_sc,downscript=stop_sc \
 -net nic,vlan=2,model=$QEMU_NET_DRIVER,macaddr=AA:BB:CC:DD:EE:06 \
 -net tap,vlan=2,name=tap1,script=start2,downscript=stop2 \
 -nographic $@
--------------------------------------------------------------------------
../qemu/start_sc

#!/bin/sh
/sbin/ip tuntap add mode tap tap1
/sbin/ifconfig tap1 11.0.2.10 dstaddr 11.0.2.0 netmask 255.255.255.0 down
/sbin/ifconfig tap1 hw ether aa:bb:cc:dd:ee:f1 up

echo "Enable IP Forwarding"
iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward
--------------------------------------------------------------------------
../qemu/start2

#!/bin/sh
/sbin/ip tuntap add mode tap tap2
/sbin/ifconfig tap2 12.0.2.10 dstaddr 12.0.2.0 netmask 255.255.255.0 down
/sbin/ifconfig tap2 hw ether aa:bb:cc:dd:ee:f2 up
echo "Enable IP Forwarding"
iptables -t nat -A POSTROUTING -o eth2 -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward
---------------------------------------------------------------------
Network card in ../templates/x86/nonvga_debug/mods.config :
@Runlevel(2) include embox.driver.net.ne2k_pci
-----------------------------------------------------------------------
../templates/x86/nonvga_debug/start_script.inc :

/* Setup loopback interface */
"ifconfig lo 127.0.0.1 netmask 255.0.0.0 up",
"route add 127.0.0.0 netmask 255.0.0.0 lo",
/* Setup eth0 interface */
"ifconfig eth0 10.0.2.16 netmask 255.255.255.0 hw ether AA:BB:CC:DD:EE:02 up",
"route add 10.0.2.0 netmask 255.255.255.0 eth0",
"route add default gw 10.0.2.10 eth0",
/* Setup eth1 interface */
"ifconfig eth1 11.0.2.16 netmask 255.255.255.0 hw ether AA:BB:CC:DD:EE:04 up",
"route add 11.0.2.0 netmask 255.255.255.0 eth1",
/*"route add default gw 11.0.2.10 eth1",*/
/* Setup eth2 interface */
"ifconfig eth2 12.0.2.16 netmask 255.255.255.0 hw ether AA:BB:CC:DD:EE:06 up",
"route add 12.0.2.0 netmask 255.255.255.0 eth2",
/*"route add default gw 12.0.2.10 eth2",*/
----------------------------------------------------------------------------
Using ifconfig in EMBOX command line:
loading start script:
> ifconfig lo 127.0.0.1 netmask 255.0.0.0 up
> route add 127.0.0.0 netmask 255.0.0.0 lo
> ifconfig eth0 10.0.2.16 netmask 255.255.255.0 hw ether AA:BB:CC:DD:EE:02 up
> route add 10.0.2.0 netmask 255.255.255.0 eth0
> route add default gw 10.0.2.10 eth0
> ifconfig eth1 11.0.2.16 netmask 255.255.255.0 hw ether AA:BB:CC:DD:EE:04 up
> route add 11.0.2.0 netmask 255.255.255.0 eth1
> ifconfig eth2 12.0.2.16 netmask 255.255.255.0 hw ether AA:BB:CC:DD:EE:06 up
> route add 12.0.2.0 netmask 255.255.255.0 eth2
Welcome to Embox and have a lot of fun!
embox>ifconfig
lo      Link encap:Local Loopback
        inet addr:127.0.0.1  Mask:255.0.0.0
        UP LOOPBACK RUNNING  MTU:16436  Metric:0
        RX packets:0 errors:0 dropped:0 overruns:0 frame:0
        TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
        collisions:0 txqueuelen:0
        RX bytes:0 (0 MiB)  TX bytes:0 (0 MiB)
eth0    Link encap:Ethernet  HWaddr AA:BB:CC:DD:EE:02
        inet addr:10.0.2.16  Bcast:10.0.2.255  Mask:255.255.255.0
        UP BROADCAST RUNNING MULTICAST  MTU:1514  Metric:0
        RX packets:0 errors:0 dropped:0 overruns:0 frame:0
        TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
        collisions:0 txqueuelen:1000
        RX bytes:0 (0 MiB)  TX bytes:0 (0 MiB)
        Interrupt:10 Base address:0x0000c200
eth1    Link encap:Ethernet  HWaddr AA:BB:CC:DD:EE:04
        inet addr:11.0.2.16  Bcast:11.0.2.255  Mask:255.255.255.0
        UP BROADCAST RUNNING MULTICAST  MTU:1514  Metric:0
        RX packets:0 errors:0 dropped:0 overruns:0 frame:0
        TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
        collisions:0 txqueuelen:1000
        RX bytes:0 (0 MiB)  TX bytes:0 (0 MiB)
        Interrupt:11 Base address:0x0000c100
eth2    Link encap:Ethernet  HWaddr AA:BB:CC:DD:EE:06
        inet addr:12.0.2.16  Bcast:12.0.2.255  Mask:255.255.255.0
        UP BROADCAST RUNNING MULTICAST  MTU:1514  Metric:0
        RX packets:0 errors:0 dropped:0 overruns:0 frame:0
        TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
        collisions:0 txqueuelen:1000
        RX bytes:0 (0 MiB)  TX bytes:0 (0 MiB)
        Interrupt:11 Base address:0x0000c000
embox>telnetd
-- it normally started.

Using ping in host console :
> ping 10.0.2.16
PING 10.0.2.16 (10.0.2.16) 56(84) bytes of data.
From 10.0.2.10 icmp_seq=1 Destination Host Unreachable
From 10.0.2.10 icmp_seq=2 Destination Host Unreachable
From 10.0.2.10 icmp_seq=3 Destination Host Unreachable

ping 11.0.2.16 and 12.0.2.16 also unreachable

> telnet 10.0.2.16
Trying 10.0.2.16...
telnet: Unable to connect to remote host: No route to host

telnet 11.0.2.16 and 12.0.2.16 also unable.

Original issue reported on code.google.com by ershpush on 14 Mar 2013 at 2:12

GoogleCodeExporter commented 9 years ago
It was error in string
" -net tap,vlan=2,name=tap1,script=start2,downscript=stop2 \".
Use "tap2" instead "tap1".
Scripts are attached.

Original comment by ershpush on 18 Mar 2013 at 2:19

Attachments:

GoogleCodeExporter commented 9 years ago
fixed by r9318

Original comment by ki.stfu on 28 Mar 2013 at 8:53