设为首页 收藏本站
查看: 1106|回复: 0

[经验分享] Xen in WiFi networks

[复制链接]

尚未签到

发表于 2015-10-12 08:36:04 | 显示全部楼层 |阅读模式
  From:
Xen in WiFi networks


  
  Successfully running Xen on a machine with a single WiFi card can be tricky. In my situation the network in
dom0 worked fine but in domU I could only see incoming packets. Outgoing ones were sent out to
xen-br0 but never transmitted over the wireless network.

Sample network configuration
  There are two physical hosts on the network - Router and a Xen host running
dom0 and domU:

Host
IP address
Router
192.168.157.20
Xen dom0
192.168.157.21
Xen domU
192.168.157.41  Xen dom0 network interface has the real MAC address of the
WiFi card, Xen domU MAC address is set in /etc/xen/domU config:

~# cat /etc/xen/domU
[...]
nics = 1
vif = ['eth0=00:60:00:00:00:01']

  



Problem and solution
  After some research it turned out that the culprit blocking outgoing traffic wasn't
Xen but the wireless card which refused to send out packets with a MAC address different from its own. Since Xen deploys
ethernet bridge to provide network for domU kernels the outgoing packets have a virtual source MAC address different from the real one of the
WiFi card. You don't need Xen to observe this problem - simple ethernet bridge constructed with brctl(8) between wired and wireless segments will not work with many wifi cards either. See section
It doesn't work with my Wireless card at
Linux Bridging FAQ.
  The solution obviously is to change the source MAC address to the real one on all outgoing packets. At first I tried to set it in vif=['mac=...'] config option for
domU host, but it didn't work. Better solution turned out to be deployment of
ebtables - netfilter infrastructure similar to iptables but working with MAC addresses instead of IP addresses. The simplest ebfilter rule to make it work is:
  



ebtables -t nat -A POSTROUTING -s 00:60:00:00:00:01 \
-j snat --to-source 00:60:aa:bb:cc:dd

  

This rule rewrites the source MAC address of all packets from 00:60:00:00:00:01 to 00:60:aa:bb:cc:dd.You may want to add some more checks, e.g. for source interface name or alike. This is the bare minimum. I have executed this command in
dom0 but in theory it could work in domU as well.

Details
  Surprisingly enough there doesn't have to be a corresponding reversed dnat rule. Ping from outside to
domU triggers this packet sequence:
  



01:56:03.972501 00:02:11:22:33:44 > ff:ff:ff:ff:ff:ff,
ethertype ARP (0x0806), length 42:
arp who-has 192.168.157.41 tell 192.168.157.20
01:56:03.975205 00:60:aa:bb:cc:dd > 00:02:11:22:33:44,
ethertype ARP (0x0806), length 60:
arp reply 192.168.157.41 is-at 00:60:00:00:00:01

  

Interesting point is the ARP reply. Although it comes from WiFi real MAC address, it carries the domU
virtual MAC inside in the packet. Subsequently my workstation created an entry in its ARP table with the
virtual(!) address of domU and started sending all further communication to that MAC:
  



01:56:03.975231 00:02:11:22:33:44 > 00:60:00:00:00:01,
ethertype IPv4 (0x0800), length 98:
IP 192.168.157.20 > 192.168.157.41:
icmp 64: echo request seq 1
01:56:03.982348 00:60:aa:bb:cc:dd > 00:02:11:22:33:44,
ethertype IPv4 (0x0800), length 98:
IP 192.168.157.41 > 192.168.157.20:
icmp 64: echo reply seq 1

  

Fortunately the Linux kernel on Router only updates its ARP table from the body of ARP replies and not from packet headers, which I believe is a correct behaviour. However I'm not sure that
all operating systems do like this.

Notes


  • To get the MAC address of your WiFi card use command
    ip link show:

ip link show
# ip link show
[...]
2: eth0: <BROADCAST,MULTICAST,NOTRAILERS,UP> mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 00:60:aa:bb:cc:dd brd ff:ff:ff:ff:ff:ff


  • The chipset on my WiFi card that caused these troubles is
    Intersil Corporation Prism 2.5 Wavelan chipset with firmware 1.3.6. Other chipsets may work just fine without these kludges.
  • Xen version in use here is 2.0.6 and both dom0 and domU are running SuSE Linux Professional 9.2 with kernel 2.6.11.4, but it is fairly irrelevant as the problem is in hardware not in software.


  

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-125615-1-1.html 上篇帖子: 编译Xen 3.4 Dom0 using Linux Kernel 2.6.31 on Ubuntu 9.10 (Karmic) 下篇帖子: xen xenserver xcp区别
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表