caiwang / board2ihost

0 stars 0 forks source link

how to check if the kernel support for ip alias? #65

Open unissoft-bj opened 9 years ago

unissoft-bj commented 9 years ago

http://unix.stackexchange.com/questions/108396/how-to-check-if-the-kernel-support-for-ip-alias

http://www.tldp.org/LDP/nag2/x-087-2-hardware.kernel.config.html 3.1. Kernel Configuration

Virtual hosting

These options together allow to you configure more than one IP address onto an interface. This is sometimes useful if you want to do “virtual hosting,” through which a single machine can be configured to look and act as though it were actually many separate machines, each with its own network personality. We'll talk more about IP aliasing in a moment:

Networking options ---> [*] TCP/IP networking

[*] Network aliasing
<*> IP: aliasing support
unissoft-bj commented 9 years ago

rocklite板子,系统使用radxa_rock_pro_lite_ubuntu_14.04_server_141030_sdcard.zip

/etc/network/interfaces内容:

interfaces(5) file used by ifup(8) and ifdown(8)

Include files from /etc/network/interfaces.d:

source-directory /etc/network/interfaces.d

iface eth0:9 inet static name Ethernet alias MAN card address 192.168.254.254 netmask 255.255.255.0 network 192.168.254.0 broadcast 192.168.254.255

/etc/network/interfaces.d/eth0 内容: auto eth0 iface eth0 inet dhcp

root@ihost:~# ifconfig eth0 eth0 Link encap:Ethernet HWaddr de:ad:de:ad:be:ef
inet addr:192.168.1.7 Bcast:192.168.1.255 Mask:255.255.255.0 inet6 addr: fe80::dcad:deff:fead:beef/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:2121 errors:0 dropped:0 overruns:0 frame:0 TX packets:664 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:204151 (204.1 KB) TX bytes:65045 (65.0 KB) Interrupt:51

root@ihost:~# ifconfig eth0:9 eth0:9 Link encap:Ethernet HWaddr de:ad:de:ad:be:ef
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 Interrupt:51

root@ihost:~# ifconfig eth0:10 eth0:10 Link encap:Ethernet HWaddr de:ad:de:ad:be:ef
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 Interrupt:51

root@ihost:~# ip addr add 172.16.0.10/16 dev eth0:10

root@ihost:~# ip addr list eth0 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether de:ad:de:ad:be:ef brd ff:ff:ff:ff:ff:ff inet 192.168.1.7/24 brd 192.168.1.255 scope global eth0 inet 172.16.0.10/16 scope global eth0 inet6 fe80::dcad:deff:fead:beef/64 scope link valid_lft forever preferred_lft forever root@ihost:~#

unissoft-bj commented 9 years ago

手机连到wlan0上 录音程序设置服务器为172.16.0.10

抓wlan0的包

root@ihost:~# tshark -i wlan0 -f 'udp' 1426 89.655257 172.16.0.109 -> 172.16.0.10 UDP 834 Source port: 58075 Destination port: ddi-udp-1 1427 89.956005 172.16.0.109 -> 172.16.0.10 IPv4 1514 Fragmented IP protocol (proto=UDP 17, off=0, ID=c242) 1428 89.956015 172.16.0.109 -> 172.16.0.10 IPv4 1514 Fragmented IP protocol (proto=UDP 17, off=1480, ID=c242) 1429 89.956049 172.16.0.109 -> 172.16.0.10 IPv4 1514 Fragmented IP protocol (proto=UDP 17, off=2960, ID=c242) 1430 89.956062 172.16.0.109 -> 172.16.0.10 IPv4 1514 Fragmented IP protocol (proto=UDP 17, off=4440, ID=c242) 1431 89.956071 172.16.0.109 -> 172.16.0.10 IPv4 1514 Fragmented IP protocol (proto=UDP 17, off=5920, ID=c242) 1432 89.956079 172.16.0.109 -> 172.16.0.10 UDP 834 Source port: 58075 Destination port: ddi-udp-1

---- 启动chilli-------

1432 1433 93.471285 172.16.0.109 -> 172.16.0.1 DNS 79 Standard query 0x80af A mcometgw.alipay.com 1433 1434 98.474577 172.16.0.109 -> 172.16.0.1 DNS 79 Standard query 0x80af A mcometgw.alipay.com 1434 1435 103.480139 172.16.0.109 -> 172.16.0.1 DNS 79 Standard query 0x80af A mcometgw.alipay.com 1435 1436 108.484895 172.16.0.109 -> 172.16.0.1 DNS 79 Standard query 0x80af A mcometgw.alipay.com 1436 1437 113.488452 172.16.0.109 -> 172.16.0.1 DNS 79 Standard query 0xc7c1 A mcometgw.alipay.com

抓eth0:10的包

root@ihost:~# tshark -i eth0:10 -f 'udp' 87 88 376.669648 192.168.1.1 -> 239.255.255.250 SSDP 304 NOTIFY * HTTP/1.1 89 376.670041 192.168.1.1 -> 239.255.255.250 SSDP 376 NOTIFY * HTTP/1.1 90 376.670412 192.168.1.1 -> 239.255.255.250 SSDP 372 NOTIFY * HTTP/1.1 91 376.670767 192.168.1.1 -> 239.255.255.250 SSDP 352 NOTIFY * HTTP/1.1 92 376.671168 192.168.1.1 -> 239.255.255.250 SSDP 384 NOTIFY * HTTP/1.1 93 376.671488 192.168.1.1 -> 239.255.255.250 SSDP 366 NOTIFY * HTTP/1.1 94 376.671829 192.168.1.1 -> 239.255.255.250 SSDP 368 NOTIFY * HTTP/1.1 95 376.672218 192.168.1.1 -> 239.255.255.250 SSDP 368 NOTIFY * HTTP/1.1 95 96 436.676414 192.168.1.1 -> 239.255.255.250 SSDP 304 NOTIFY * HTTP/1.1

结论

chilli启动之前,在wlan0上能抓到手机发给eth0:10的udp包 但eth0:10抓不到这些udp包

chilli启动后,wlan0上抓不到手机发给eth0:10的包

unissoft-bj commented 9 years ago

root@ihost:~# echo 'iface eth0:9 inet static' >> /etc/network/interfaces.d/eth0:9 root@ihost:~# echo 'iface eth0:10 inet static' >> /etc/network/interfaces.d/eth0:10 root@ihost:~# echo 'iface eth0:11 inet static' >> /etc/network/interfaces.d/eth0:11

root@ihost:~# ip addr add 172.16.0.10/16 dev eth0:10 root@ihost:~# ip addr list eth0 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether de:ad:de:ad:be:ef brd ff:ff:ff:ff:ff:ff inet 192.168.1.7/24 brd 192.168.1.255 scope global eth0 inet 172.16.0.10/16 scope global eth0 inet6 fe80::dcad:deff:fead:beef/64 scope link valid_lft forever preferred_lft forever root@ihost:~#