问题
我在vagrant节点上设置了两个网络接口。 eth1
绑定到.11
地址,eth2
绑定到.12
。
当我这样做时:
ping 192.168.1.12
和
ping 192.168.1.11
...并在不同接口上的节点上监听ICMP消息
root@node1:/home/vagrant# tcpdump -i eth1 -v icmp -nn
对于eth1
我正在获取ICMP,但是在做
root@node1:/home/vagrant# tcpdump -i eth2 -v icmp -nn
我没有在tcpdump上看到我的ping请求。但是,如果我将ping请求发送到.12
并收听eth1
,我会看到请求,这对我来说很奇怪。因此,当我在eth1
接口上监听时,所有ICMP消息都在tcpdump中可见 - 即使我在ping .12
地址时也是如此。
我希望看到eth1
在.11
被ping“时向eth2
发出请求,并在.12
被发现时转到root@node1:/home/vagrant# tcpdump -i eth2 -v icmp -nn and src host 192.168.1.10
tcpdump: listening on eth2, link-type EN10MB (Ethernet), capture size 65535 bytes
05:30:21.800964 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto ICMP (1), length 84)
192.168.1.10 > 192.168.1.255: ICMP echo request, id 28770, seq 1, length 64
05:30:22.800953 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto ICMP (1), length 84)
- 为什么这不是案件?
更新1:
使用tcpdump:
监听192.168.1.12时,可以看到广播pingmindaugas@Mindaugas-Lenovo-Y50-70:~$ arp -an
? (192.168.1.1) at xxxxxxxx [ether] on wlan0
? (192.168.1.12) at 08:00:27:82:f6:0c [ether] on wlan0
? (192.168.1.11) at 08:00:27:82:f6:0c [ether] on wlan0
更新2:
广播表明L2和MAC地址有问题 - 实际上托管流浪者的主机有这个ARP表
eth1 Link encap:Ethernet HWaddr 08:00:27:82:f6:0c
inet addr:192.168.1.11 Bcast:192.168.1.255 Mask:255.255.255.0
eth2 Link encap:Ethernet HWaddr 08:00:27:7b:8d:fd
inet addr:192.168.1.12 Bcast:192.168.1.255 Mask:255.255.255.0
即使接口有这些:
? (192.168.1.12) at 08:00:27:7b:8d:fd [ether] PERM on wlan0
? (192.168.1.11) at 08:00:27:82:f6:0c [ether] PERM on wlan0
在ARP表中添加了MAC地址:
eth0
但是现在,我可以看到root@node1:/home/vagrant# ifconfig
eth0 Link encap:Ethernet HWaddr 08:00:27:ca:3e:f9
inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:feca:3ef9/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:872 errors:0 dropped:0 overruns:0 frame:0
TX packets:689 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:77679 (77.6 KB) TX bytes:78655 (78.6 KB)
eth1 Link encap:Ethernet HWaddr 08:00:27:82:f6:0c
inet addr:192.168.1.11 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe82:f60c/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:52 errors:0 dropped:0 overruns:0 frame:0
TX packets:67 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:7362 (7.3 KB) TX bytes:6796 (6.7 KB)
eth2 Link encap:Ethernet HWaddr 08:00:27:7b:8d:fd
inet addr:192.168.1.12 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe7b:8dfd/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:18 errors:0 dropped:0 overruns:0 frame:0
TX packets:22 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2444 (2.4 KB) TX bytes:2520 (2.5 KB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:16 errors:0 dropped:0 overruns:0 frame:0
TX packets:16 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1184 (1.1 KB) TX bytes:1184 (1.1 KB)
上传入的数据报,但我没有得到ping回复消息! ......我想知道为什么会这样?
更新3:
在安装了虚拟盒的另一台笔记本电脑上试用了一台Linux机箱作为虚拟机。添加了两个接口 - 两个桥接适配器。相同的行为。所以这与虚拟盒子或更通用的东西有关(比如我不了解虚拟网络是如何工作的),不一定是流浪汉。
使用数据:
我在流浪者节点上的ifconfig:
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.define "node1" do |node1|
node1.vm.box = "ubuntu/trusty64"
node1.vm.hostname = "node1"
config.vm.network :public_network, type: "dhcp", bridge: "wlan0"
config.vm.network :public_network, type: "dhcp", bridge: "wlan0"
# config.vm.network :public_network, bridge: "wlan0", ip: "192.168.1.251"
# config.vm.network :public_network, bridge: "wlan0", ip: "192.168.1.252"
config.vm.provider "virtualbox" do |v|
v.memory = 256
v.cpus = 2
end
end
我的vagrantfile:
Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim chk As New DataGridViewCheckBoxColumn()
grdExpedientes.Columns.Add(chk)
chk.HeaderText = ""
chk.Name = "chk"
'fills a datatable from an xml, it works ok, it fills it with the correct amount of rows
Dim dt As DataTable = Sistema.getInstance.getDataExpedienteForGrid()
Dim bs As New BindingSource
bs.DataSource = dt
grdExpedientes.DataSource = bs
navExpedientes.BindingSource = bs
For i As Integer = 0 To grdExpedientes.Rows.Count - 2
grdExpedientes.Rows(i).Cells(0).Value = True
Next
End Sub
Private Sub LoadGridExpedientes()
grdExpedientes.DataSource = Nothing
navExpedientes.BindingSource = Nothing
grdExpedientes.Columns.Clear()
grdExpedientes.Rows.Clear()
'This is to know if there is already the checkbox column
If Not (grdExpedientes.Columns.Count > 0 AndAlso grdExpedientes.Columns(0).Name = "chk") Then
Dim chk As New DataGridViewCheckBoxColumn()
grdExpedientes.Columns.Add(chk)
chk.HeaderText = ""
chk.Name = "chk"
End If
Dim dt As DataTable = Sistema.getInstance.getDataExpedienteForGrid()
Dim bs As New BindingSource
bs.DataSource = dt
grdExpedientes.DataSource = bs
navExpedientes.BindingSource = bs
End Sub
Private Sub navExpedientesDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles navExpedientesDelete.Click
For i As Integer = 0 To grdExpedientes.Rows.Count - 2
Dim dgvr As DataGridViewRow = grdExpedientes.Rows(i)
If CType(dgvr.Cells(0).Value, Boolean) = True Or _
CType(dgvr.Cells(0).GetEditedFormattedValue(dgvr.Index, DataGridViewDataErrorContexts.Commit), Boolean) = True Then
Dim draux As DataGridViewRow = dgvr
Dim expABorrar As Expediente = CType((From elem As Expediente In Sistema.listExpedientes
Where elem.Expediente = CType(draux.Cells("Expediente (Ficha)").Value, String)
Select elem).FirstOrDefault, Expediente)
Sistema.listExpedientes.Remove(expABorrar)
End If
Next
If System.IO.File.Exists(Sistema.pathListExpedientes) Then
System.IO.File.Delete(Sistema.pathListExpedientes)
End If
Dim sw As System.IO.TextWriter = New System.IO.StreamWriter(Sistema.rutaListaExpedientes, 0)
Serializer(Of Expediente).Serialize(Sistema.listExpedientes, sw, New List(Of Type) From {GetType(Movimiento)})
sw.Close()
LoadGridExpedientes()
End Sub
答案 0 :(得分:0)
问题是我将两个网卡分配到同一个网络,因此IP路由无法正常工作。
以下是vagrant主机中路由表的外观:
root@node1:/home/vagrant# route -ne
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
10.0.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth2
将使用eth1 MAC解析Arp,因为eth1将用于向192.168.1.0/24主机发送数据包。
一旦我删除了一条路线 - 另一条路线开始工作。
Alsi,我是否会使用
并不重要net.ipv4.conf.eth0.arp_ignore = 1
net.ipv4.conf.eth0.arp_announce = 2
因为路由仍然无效(即使我强制正确的ARP解析(请参阅OP),PING回复永远不会回复给我(不知道为什么会这样))。
这说明了IP路由中的一个重要概念 - IP是per host
,而不是per NIC
。
一些参考文献:
Why arp ignore/annouce are not enable by default https://serverfault.com/questions/556943/multiple-nic-arp-issue