
我有一個簡單的 UDP 設備 (ENC28J60 ) 透過直接電纜連接到我的電腦。設備配置為將 UDP 封包傳送至 192.168.133.1 IP、6661 連接埠。
計算機,Fedora 22作業系統,介面名稱為enp7s0。當將 IP 位址指派給介面時,tcpdump 掛起,netcat 靜默。當沒有IP位址分配給介面時,netcat靜默(無輸出),tcpdump接收封包。
封包確實來自設備,我可以使用 tcpdump 查看,僅當介面處於 UP,但沒有分配 IP 位址時。
首先嘗試開啟帶有 IP 位址的介面:
[root@d7520 ~]# nmcli connection up toArd
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/20)
[root@d7520 ~]# ip a s dev enp7s0
2: enp7s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 74:86:7a:1e:e0:85 brd ff:ff:ff:ff:ff:ff
inet 192.168.133.1/24 brd 192.168.133.255 scope global enp7s0
valid_lft forever preferred_lft forever
inet6 fe80::7686:7aff:fe1e:e085/64 scope link
valid_lft forever preferred_lft forever
嘗試使用 netcat 和 tcpdump。沒有答案。 tcpdump 掛起。
[root@d7520 ~]# ncat -u -l 6661
^C
[root@d7520 ~]# tcpdump -vvv -i enp7s0 -X
tcpdump: listening on enp7s0, link-type EN10MB (Ethernet), capture size 262144 bytes
[root@d7520 ~]# nc -v -l -u 6661
Ncat: Version 6.47 ( http://nmap.org/ncat )
Ncat: Listening on :::6661
Ncat: Listening on 0.0.0.0:6661
^C
現在,嘗試刪除 IP 位址。 tcpdump 收到了 UDP 封包,但 netcat 仍然保持沉默:
[root@d7520 ~]# nmcli connection down toArd
Connection 'toArd' successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/21)
[root@d7520 ~]# ip a s dev enp7s0
2: enp7s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 74:86:7a:1e:e0:85 brd ff:ff:ff:ff:ff:ff
[root@d7520 ~]# tcpdump -vvv -i enp7s0 -X
tcpdump: listening on enp7s0, link-type EN10MB (Ethernet), capture size 262144 bytes
13:41:39.423449 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto UDP (17), length 37)
192.168.133.2.6660 > 192.168.133.1.6661: [udp sum ok] UDP, length 9
0x0000: 4500 0025 0000 4000 4011 af73 c0a8 8502 E..%..@[email protected]....
0x0010: c0a8 8501 1a04 1a05 0011 0630 7465 7374 ...........0test
0x0020: 2031 3233 0000 0000 0000 0000 0000 .123..........
^C
1 packet captured
1 packet received by filter
0 packets dropped by kernel
答案1
我不確定這是你的問題,但你nmcli
首先為什麼要使用?nmcli
是網路管理器命令列介面,即多得多比你在嘗試調出介面時所期望的要好。
如果我是你,我會如下進行。作為sudo
:
service network-manager stop # halt NM
ip link set dev enp7s0 down # bring the interface down, in order to...
ip addr flush dev enp7s0 # ... get rid of its ip address
要么手動配置...
ip addr add 192.168.133.133/24 dev enp7s0 # we give it a brand new address...
ip link set dev enp7s0 up # now we try again...
ip route add default via 192.168.133.1 # and a gateway
或自動的:
ip link set dev enp7s0 up
dhclient -v enp7s0
(根據您的發行版,您可能必須省略該-v
標誌)。
現在我會再試一次,兩者都tcpdump
應該nc
可以工作。