
직접 케이블을 통해 컴퓨터에 간단한 UDP 장치(ENC28J60)가 연결되어 있습니다. UDP 패킷을 192.168.133.1 IP, 6661 포트로 보내도록 구성된 장치입니다.
컴퓨터, Fedora 22 OS, 인터페이스 이름은 enp7s0입니다. 인터페이스에 IP 주소가 할당되면 tcpdump가 중단되고 netcat은 자동으로 작동합니다. 인터페이스에 할당된 IP 주소가 없으면 netcat 자동(출력 없음), tcpdump가 패킷을 수신합니다.
패킷은 실제로 장치에서 나옵니다. 인터페이스가 UP이지만 IP 주소가 할당되지 않은 경우에만 tcpdump를 통해 볼 수 있습니다.
먼저 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
할 것입니다.