我已经尝试过 Net::RawIP 和 Net::Write::Layer3。如果我在网络中提供特定的 IP 地址,它工作正常。当我得到任何一个时
sendto() at /usr/lib/perl5/Net/RawIP.pm line 630. shell returned 13
或者
Net::Write::Layer::send: Permission denied
如果我将目标地址更改为 66.66.66.255
有任何想法吗?
我正在使用的代码在这里
use Net::Write::Layer qw(:constants);
use Net::Write::Layer3;
use NetAddr::IP;
use Net::RawIP;
$message = "Foo";
# using Net::RawIP
$n = Net::RawIP->new({
ip => {
tos => 0xC0,
daddr => '66.66.66.2',
protocol => 2,
},
generic => {
data => $message
}
});
$n->send;
# using Net::Write::Layer3
my $desc = Net::Write::Layer3->new(
dst => '66.66.66.2',
protocol => '2',
family => NW_AF_INET,
);
$desc->open;
$desc->send($message);
$desc->close;