date int64 1,220B 1,719B | question_description stringlengths 28 29.9k | accepted_answer stringlengths 12 26.4k | question_title stringlengths 14 159 |
|---|---|---|---|
1,651,155,404,000 |
I have Debian 4.19.194-1 as a router server with LAN, WAN, PPPOE (as gateway) and COMPUTER1 in LAN network which should have access to internet through Debian router.
As firewall I use nftables with rules:
#!/usr/sbin/nft -f
flush ruleset
define EXTIF = "ppp0"
define LANIF = "enp1s0"
define WANIF = "enp4s0"
define LO... |
The firewall rules did not cause the problem. Instead, it's due to the MTU difference in "plain" Ethernet and PPPoE. Since PPP header takes up (at least) 8 bytes, and the usual MTU of Ethernet itself is 1500 bytes, the MTU of PPPoE in that case will be at most 1492 bytes.
I don't know MTU stuff well enough to tell the... | Router with nftables doesn't work well |
1,651,155,404,000 |
Let's say I want to apply a rule to ip daddr { 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 }, but I want to exclude two more specific IPv4 addresses from that. How do I do that?
I was hoping for some more elegant way of doing this:
ip daddr { 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 } \
ip daddr != 10.0.1.2 \
ip da... |
It appears that negations of sets are working as expected (undocumented):
ip daddr { 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 } \
ip daddr != { 10.0.1.2, 10.0.2.3 }
| Can I match a set negatively in nftables? |
1,651,155,404,000 |
Since I'm using a transparent proxy service, I use a raspberry pi as my home router. Its OS is plain Raspbian. Now I'm setting up a Minecraft server on 192.168.2.28, and am exposing it to WAN using NAT. Here's my /etc/nftables.conf:
#!/sbin/nft -f
flush ruleset
table ip filter {
chain output {
type filte... |
As a reminder, nftables (just like iptables) sees only the first packet of a flow to be NAT-ed. When it comes to doing NAT, every other packet in the same flow will be handled directly by Netfilter/conntrack without seeing nftables anymore: so the return traffic is automatically un-NAT-ed without further assistance.
T... | How to configure port forwarding with nftables for a Minecraft server on Raspberry Pi? |
1,648,211,276,000 |
I am using Ubuntu 20.04 OS with dnsjava client library to query DNS servers.
I have nftables rule in this machine which block all traffic on ports except ephemeral port range 32768-61000 which will be used by dnsjava to get results from DNS server.
table inet tb {
chain input {
type filter hoo... |
Use stateful firewall rules. Connection state for stateful rules is handled by Netfilter's conntrack subsystem and can be used from nftables.
The goal is to allow (select) outgoing packets, let them be tracked (automatically) by conntrack and allow back as incoming packets, only those that are part of the flow initial... | How to avoid allowing ephemeral port range rule in nftables |
1,648,211,276,000 |
This is on Ubuntu 20.04.
I am attempting to write a rule for nftables which will match all IP packets received on interface eth1 that have a specific TOS value (0x02). My attempt so far:
sudo nft add table raw
sudo nft -- add chain raw prerouting {type filter hook prerouting priority -300\;}
sudo nft add rule ip raw p... |
Looking further into the make-up of a IPv4 header:
https://en.wikipedia.org/wiki/IPv4#Header
I see that TOS is the name given to the entire byte, but DSCP is the name for only the most-significant 6 bits.
Based on this I guessed TOS != DSCP.
I tried changing the sending code to using a TOS of 0x20 and then modified th... | Nftables not matching TOS value in IP packets |
1,648,211,276,000 |
This is my /etc/nftables.conf
#!/usr/sbin/nft -f
flush ruleset
define wan = { eth0 }
table inet filter {
chain input {
type filter hook input priority 0; policy drop;
# allow everything from loopback interface
iif lo accept comment "Accept any localhost traffic"
# dr... |
For anybody else encountering this problem. Make sure:
The "netfilter" (and corresponding) kernel options are compiled either directly or as modules (grep -i netfilter /proc/config* or grep -i netfilter /boot/config*)
If the option have been compiled as modules, make sure you do not have sysctl option kernel.modules_... | nftables: ct state rule produces "Error: Could not process rule: No such file or directory" |
1,648,211,276,000 |
nftables supports dynamically populated sets which are documented in nftables wiki. The first example on the wiki page is following:
table ip my_filter_table {
set my_ssh_meter {
type ipv4_addr
size 65535
flags dynamic
}
chain my_input_chain {
... |
What happens:
when a new ssh connection arrives, its source plus attached meter is added (if not already present: it's a set, so each element is present only once) to the set and evaluated to provide a boolean result true/false
if the evaluation is true, the rule can continue, else the rule stops.
note: without the ... | How to understand the nftables "add @my_ssh_meter { ip saddr limit rate 10/second } accept" rule? |
1,648,211,276,000 |
From the nftables Quick reference:
family refers to a one of the following table types: ip, arp, ip6,
bridge, inet, netdev.
and
type refers to the kind of chain to be created. Possible types are:
filter: Supported by arp, bridge, ip, ip6 and inet table families.
route: Mark packets (like mangle for the output hook,... |
I am new one, but also interested in nftables rules. I found in nftables wiki: "The principal (only?) use for this (netdev) family is for base chains using the ingress hook, new in Linux kernel 4.2." More info here, in the end of article: https://wiki.nftables.org/wiki-nftables/index.php/Nftables_families
Ingress hook... | What chain types are supported by the nftables NETDEV family? |
1,648,211,276,000 |
Here is a working example on how I currently use an unamed set containing ICMP types:
#!/usr/sbin/nft -f
add table filter_4
add chain filter_4 icmp_out_4 {
comment "Output ICMPv4 traffic"
}
define response_icmp_4 = {
0, # Echo Reply
3, # Destination Unreachable
10, # Router Solicitation
11, # Ti... |
The named set declaration must match the type to compare it to. An ICMP type is not an inet service:
# nft describe inet_service
datatype inet_service (internet network service) (basetype integer), 16 bits
which means a port. Compatible for example with:
# nft describe udp dport
payload expression, datatype inet_serv... | Declare and use a named set of ICMP types in nftables |
1,648,211,276,000 |
Here is a working example of how ct helper object is currently declared as per nftables docs
#!/usr/sbin/nft -f
add table filter_4 {
# TODO: Can helper object be declared outside the scope of table declaration scope?
# ct helper stateful object
# "ftp-standard" is the name of this ct helper stateful objec... |
The syntax is described in nft(8):
CT HELPER
add ct helper [family] table name { type type protocol protocol ; [l3proto family ;] }
delete ct helper [family] table name
list ct helpers
So for your case:
From shell (including proper shell escaping using ' where appropriate, nft itself doesn't care: it parses paramet... | Declare ct helper object outside table declaration scope in nftables |
1,648,211,276,000 |
I've set up a rule to match multicast packets as follows:
add rule filter_4 new_out_4 meta pkttype multicast goto multicast_out_4
filter_4 is IPv4 table, new_out4 is output chain and multicast_out_4 is a chain to handle multicast only traffic.
Here is a more complete picture of the IPv4 table excluding non-relevant p... |
Having reproduced (and completed missing parts for) the setup with a few additional entries such as:
nft insert rule filter_4 new_out_4 counter meta pkttype host counter
indeed the property meta pkttype for this skbuff is host rather than the expected multicast for an outgoing multicast packet. Note that when this ke... | nftables - multicast packets not matched |
1,648,211,276,000 |
This is a question specifically about nftables chain types in the Linux kernel.
I don't understand how they're processed. I've been staring at the kernel code for a while, and it looks to me like an nftables "chain" is attached to a netns as a hook entry (in e.g. struct netns_nf.hooks_ipv4 for IPv4).
I don't see anyt... |
TL;DR
When doing an experiment where a network namespace receives traffic and does NAT on it, one can see that whatever the priority given to the type nat hook prerouting chain, it doesn't matter with regard to the filter chains priorities: NAT always happen at exactly prerouting hook priority -100 aka NF_IP_PRI_NAT_D... | nftables: Are chains of multiple types all evaluated for a given hook? |
1,648,211,276,000 |
I'm working from the answer of this question and man nft in order to create some dnat rules in my nftables config.
The relevant config extract is:
define src_ip = 192.168.1.128/26
define dst_ip = 192.168.1.1
define docker_dns = 172.20.10.5
table inet nat {
map dns_nat {
type ipv4_addr . ipv4... |
There are 3 problems.
no error is displayed
This looks to be a bug in nftables 1.0.6, see following bullets.
Here with the same version and OP's ruleset in /tmp/ruleset.nft:
# nft -V
nftables v1.0.6 (Lester Gooch #5)
[...]
# nft -f /tmp/ruleset.nft
/tmp/ruleset.nft:7:38-45: Error: unknown datatype ip_proto
t... | nftables dnat map rule failing silently |
1,648,211,276,000 |
I would like to change source address of every packet generated by a process in given cgroup (version 2). Is that even possible?
I have:
nftables 1.0.2,
linux 5.15 (Ubuntu variant)
/system.slice/system-my-service.slice/[email protected] cgroup
I have tried to:
create a table nft add table ip myservice
create a post... |
Here's an answer to your two problems:
syntax
cgroupv2 expects a path, which is a string. A string is always displayed with double-quotes, and requires double-quotes if it includes special characters. These double-quotes are for the nft command's consumption, not for the shell. With direct commands (ie: not in a file... | Can nftables perform postrouting matching on crgroupv2? |
1,648,211,276,000 |
I'm using nftables on a router running NixOS 22.11 (with the latest XanMod kernel patches and acpid as well as irqbalance enabled). The machine has 3 interfaces: enp4s0 which is connected to the internet and two local WiFi access points serving distinct IP LANs, wlp1s0 and wlp5s0.
My nftables configuration is the foll... |
Warning: this is a generic Linux answer. What won't be covered in this answer is specific integration with NixOS and its own method for configuring network or how to call arbitrary commands from its configuration.
Presentation
In OP's first case (two different interfaces), the router is actually routing between the t... | nftables doesn't see KDE Connect packets between two machines on the same interface |
1,648,211,276,000 |
When creating a dnat rule, you can specify the following command:
nft 'add rule ip twilight prerouting ip daddr 1.2.3.0/24 dnat ip prefix to ip daddr map { 1.2.3.0/24 : 2.3.4.0/24 }'
And then get dnat that maps addresses like 1.2.3.4 -> 2.3.4.4. This command runs as expected with nftables v1.0.4 (Lester Gooch #3)... |
TL;DR: You need at least nftables version >= 1.0.5.
In version 1.0.5:
scanner: allow prefix in ip6 scope
Which matches this commit:
scanner: allow prefix in ip6 scope
'ip6 prefix' is valid syntax, so make sure scanner recognizes it also
in ip6 context.
Also add test case.
[...]
diff --git a/tests/shell/te... | nftables anonymous map for ipv6 dnat |
1,648,211,276,000 |
Given the following:
One host called middleman has the interfaces:
Interface
Address
Location
Master VRF
enp1s0
192.168.2.99
Outer network
vrf-outer
enp2s0
192.168.2.1
Inner network
vrf-inner
Presume that the outer network has default gateway 192.168.2.1, and that we have another network - 192.168.3.0/24... |
The config showed above works as intended, with one small caveat. Vrf interfaces include vrf contexts, to handle multi-tennant applications. This means that applications can be vrf-aware and only listen to a specific vrf context, where all programs run in a default vrf context unless told otherwise. My traffic was bei... | Routing between identical copies of network with assymetric IPs on bridge machine |
1,648,211,276,000 |
A have a weird scenario in which I need to create some firewall-rules to flash a LED. So far, I've always been able to do that using iptables:
iptables -A INPUT -p tcp --dport 443 -j LED --led-trigger-id mytrigger
So far, so good. There is a new issue, however: For various reasons, I now need to create such a rule no... |
I think you are having this problem because LED is an unsupported extension of iptables that is not now supported in nftables.
https://wiki.nftables.org/wiki-nftables/index.php/Supported_features_compared_to_xtables#LED
That is too bad because it sounds like you are doing something cool. Please revisit this question i... | nftables: Create LED rules |
1,648,211,276,000 |
The nftables status in my os:
sudo systemctl status nftables
● nftables.service - nftables
Loaded: loaded (/lib/systemd/system/nftables.service; disabled; vendor preset: enabled)
Active: active (exited) since Fri 2022-11-04 11:01:47 HKT; 1s ago
Docs: man:nft(8)
http://wiki.nftables.org
... |
The table is in the inet family (representing the combination of IPv4+IPv6 together) so the family parameter inet is needed, else it defaults to ip:
If an identifier is specified without an address family, the ip family
is used by default.
As there's no ip filter table nor ip filter input chain, this command:
nft a... | How can add rule to log all incoming traffic? |
1,648,211,276,000 |
Update 2022-09-15:
It has turned out that what I was trying to achieve does not make much sense. Hence, actually this question should be deleted. However, there are some very enlightening comments to it; therefore I'll leave it as-is for the moment and leave the decision about its fate to the community.
Original quest... |
The router has two IP addresses, 192.168.20.253 and 192.168.20.254
...both ... are assigned to the same interface
So we have something like:
# ip addr
3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 08:00:27:f8:ed:0e brd ff:ff:ff:ff:ff:ff
ine... | In nftables, how can we get the IP address via which a packet came in if the respective interface has multiple IP addresses assigned? |
1,648,211,276,000 |
I am trying to locate the file /etc/nftables/inet-filter which is referenced in the readme for a project I've inherited. When I installed nftables, the only files that existed in etc/nftables were:
. .. main.nft nat.nft osf router.nft
I found an inet-filter.nft file at git.netfilter.org which consists of:
#!/usr... |
It appears they are not packaged on Fedora since Fedora 36:
# drop vendor-provided configs, they are not really useful
rm -f $RPM_BUILD_ROOT/%{_datadir}/nftables/*.nft
Instead, a "more advanced default config" is shipped with files /etc/nftables/main.nft,router.nft and nat.nft.
# Sample configuration for nftables ... | Where is /etc/nftables/inet-filter? |
1,648,211,276,000 |
I want to match all data from ens19 with the mac address 88:7e:25:d3:90:0b use table 147.
My idea is to mark the data from 88:7e:25:d3:90:0b and give it a fwmark 14. Then use ip rule to the specified route table
So I make this command
nft add rule filter input iif ens19 ether saddr = 88:7e:25:d3:90:0b mark set 147
Err... |
According to the documentation, the syntax you want is:
nft add rule filter input iif ens19 ether saddr 88:7e:25:d3:90:0b mark set 147
| maching source MAC address in nftables |
1,648,211,276,000 |
Hi dear esteemed community,
I'm having a hard time porting my very functional iptables firewall to nftables.
No issues with input/output/forward stuffs, it's mainly the conntrack marking.
What I currently do is the following:
1/ I create three routing tables with the ip command, along with rules and conntrack marks. E... |
iptables-translate is provided along any modern iptables installation (or might be packaged separately, search for it). It will (attempt) to translate iptables rules into nftables rules. That's an easy way if one doesn't want to read all the documentation (including use for this tool) and man page.
It doesn't require ... | Porting Iptables to Nftables firewall with conntrack marks |
1,648,211,276,000 |
I am finally switching from the old iptables to the new netfilter (specifically using firewalld) to configure my computers and servers but so far I have failed to find any newer alternative to the good old iptables -vnL for quickly getting current statistics.
What's the appropriate command to use here instead?
|
You can print all netfilter rules to check current counter values
nft list ruleset
Edit:
Since firewalld probably does not add counters to nft rules, you will not get traffic statistics using firewalld with nftables.
| Get netfilter statistics on the command line |
1,648,211,276,000 |
I've got my server set up with long list of services, and everything is working great... on IPv4. But when I test them against IPv6 nothing is resolving. After disabling nftables everything started working, so I turned it back on and through trial and error, was able to identify the two lines (identified with --> be... |
Turns out that the rules I posted were not the culprit, as I've noted in the question update. The actual issue was related to ICMP traffic and in particular several types related directly to IPv6. My ICMP rules were...
add rule inet filter INPUT ct state new icmp type { echo-request, echo-reply } accept
add rule ine... | nftables preventing services from resolving on IPv6 |
1,648,211,276,000 |
I have a working nftables rule-set. However it is very long, and has a lot of repeated code:
Exact (just a few characters different) duplicate for ip4 and ip6.
Chains of rules, that branch into near identical branches. I feel that some boolean logic would help here.
How can I reduce the repeated code, to make this r... |
Joining IPv4 and IPv6 together
Join tables of families ip and ip6 into a single table of family inet:
remove the whole ip6 vnc_table table
change the ip vnc_table table into inet vnc_table table
Family inet can handle both IPv4 and IPv6 at the same time, and can still accept specific IPv4 or IPv6 rules when needed. S... | Simplify nftables (net filter tables) rules |
1,648,211,276,000 |
Set up/configuration:
I have a RHEL 8 server, running Asterisk 15.x, that has 2 NICs. NMCLI is used for networking
NIC0 (eno5np0) is on the trusted network and is configured as a static IPv4 and NIC1 (ens1f0) is on the untrusted side as a DHCP IPv4. Both are UP,BROADCAST,RUNNING,MULTICAST
NIC0 is where I access the se... |
A gateway with a genmask of 0.0.0.0 is a "default gateway". In other words, it means "unless otherwise specified, the rest of the world is this way." In a simple multi-homed host configuration, there should be just one default gateway in the entire system at a time. You cannot really use two NATted internet connection... | RHEL 8 IP/Kernel Routing Multi-Homed Server Issue - Cannot get a response to ping, when trying to ping from 2nd Interface |
1,648,211,276,000 |
I am running AlmaLinux 9, and on boot I see warning
Warning: Deprecated Driver is detected: nft_compat will not be maintained in a future major release and may be disabled
but what is loading that driver? I have firewalld service disabled. I want to eliminate this warning (properly).
Additional info:
[root@server ~... |
About the message itself: it's not an upstream kernel message, it's a specific message added in AlmaLinux 9 (and probably inherited from RHEL 9).
The nft_compat module is the compatibility layer allowing to run iptables over nftables and still use non-nftables modules.
CONFIG_NFT_COMPAT: Netfilter x_tables over nf_ta... | What loads nft_compat |
1,648,211,276,000 |
Our router machine has multiple public IPs (/27) on its WAN interface. Now, I want to add dnat rules which match specific dport/saddr/daddr combinations.
My dream would be something like this:
map one2one_dnat {
# dst_addr . src_addr . proto . dst_port : dnat_to . dnat_to_port
type ipv4_addr . ... |
The idea was here but with a wrong syntax used for the named map case, while the proper syntax was used for the anonymous map case.
A map replaces a key with this key's value if found (or the expression just evaluates to false, stopping further processing). Even when used along a dnat rule a map named keytovalue must ... | Nftables: Dnat with source address restriction and just one map |
1,648,211,276,000 |
My understanding from reading is that once a rule matches, no further rules are evaluated. However; my experience with the following example seems to indicate otherwise. Looking for some clarity on this.
table netdev retag {
chain tagin {
type filter hook ingress devices = $lan priority -149; policy ac... |
Some actions, such as accept, drop prevent further rule processing. In the documentation such actions are called "terminal statement".
Other actions, such as counter, log perform their task and continue to the next rule.
In this slightly modified example I added accept to the first rule, this will prevent further eval... | Questions about nftables and rule processing order |
1,662,510,379,000 |
On Linux, I want to drop all packets that contain any obsolete tcp options. By obsolete options, I mean all those with a tcp option kind number above 8. How can I do this using nftables?
For example, if there is a way to check whether a tcp packet has an option with a given numeric kind in nftables, that would work. I... |
Many keywords in nftables just represent a constant. That's the case for tcp options (UPDATE: but only since nftables 0.9.8).
Here's an excerpt for tcp options:
EXTENSION HEADER EXPRESSIONS
Extension header expressions refer to data from variable-sized
protocol headers, such as IPv6 extension headers and TCP options.... | blocking obsolete tcp options |
1,662,510,379,000 |
There is the requirement to set up a stateless NAT for two UDP connections from a physical network adapter in global network namespace via a linked pair of virtual network adapters to a service running in a special network namespace. This should be done on a CPU (Intel Atom) in an industrial device running Linux (Debi... |
I found the solution by myself finally after many, many hours of reading documentations, tutorials, suggestions on various web pages, making lots of trials, and doing deep and comprehensive network and netfilter monitorings and analyzes.
nft add table ip prot1
nft add chain ip prot1 prerouting '{ type filter hook prer... | How to set up stateless NAT for two UDP connections from a global network to special network namespace? |
1,662,510,379,000 |
I need some clarification. If I add this rule
nft add rule ip filter INPUT ip daddr 127.0.0.1 drop
nftables will ignore it and never acknowledge because it is on end of the rules?
|
So I found answer for my issue.
The stuff is about filters..in nft terminology CHAINS. If I want to add rule, I need to add it to specific chain, otherwise it will ignore my rule and take it as nonsense.
so if I wanted to use this rule nft add rule ip filter INPUT ip daddr 127.0.0.1 drop
I already had to have created ... | NFTable clarification |
1,662,510,379,000 |
I have a problem with my nftables setup.
I have two tables, each one has a chain with the same hook but a different name and priority.
The tables are in different files which are loaded by an include argument.
Because of the priority,
I would think that the VPN-POSTROUTING chain will be executed before the INTERNET ch... |
Historically there used to be one NAT chain in a given hook (prerouting, input, output, ...). Executing a nat statement or simply accept-ing the packet being terminal for the chain, with a single chain it was also ending treatment within the hook. With nftables allowing to use more than one chain in the same hook, ter... | nftables table and chain priority |
1,662,510,379,000 |
I have a default gateway with IP address 192.168.1.1 and MAC address 5c:77:76:6e:0d:7b. It is my only wi fi modem router from which I receive internet.
But in input nftables logs I saw another one router with the same IP address and different MAC address 5c:77:77:6e:0d:7b. This unknown router sends pages which I didn'... |
Routers often have multiple virtual network interfaces, and the MAC address that gets assigned to these is made by flipping some bits of the hardware MAC address.
So the "illegal router" you see is probably another virtual interface of your "legal router". And if you block the packets (which are "legal" packets) then ... | Delete illegal router from network |
1,662,510,379,000 |
In nftables I have this
table inet my_table {
chain badips {
ip saddr 185.165.190.17 counter packets 0 bytes 0 drop
}
type filter hook input priority filter; policy drop;
# Block badips
counter packets 0 bytes 0 jump badips
}
The planning it to put a long list of IPs in badi... |
Don't add one rule per ip. Just create a single rule, and use a set. E.g.:
table inet my_table {
set badips_v4 {
type ipv4_addr
}
set badips_v6 {
type ipv6_addr
}
chain badips {
type filter hook input priority filter; policy acce... | How to avoid insert repeated rules in nftables |
1,662,510,379,000 |
On the link below is an image explaining packet flow across chains in nftables
Netfilter hooks
I understanding everything except one thing, the image does not explain at which stage is routing decision done?
According to the image it should be done in 2 places:
After prerouting hook but before input and forward hood
... |
The image is right.
The routing is done only once: since Local Process is a starting point or termination point, a packet flow go through only one routing decision.
For your second point, the flow will go through:
local process
routing decision
output
postrouting
egress
driver tx
There is nothing prior to this, so i... | natables routing decision step(s) |
1,662,510,379,000 |
I'm following the official Debian Wiki tutorial for setting up a VPN server on Debian 11.
Everything worked well except for the paragraph Forward traffic to provide access to the Internet at the end.
The following lines do not work :
IF_MAIN=eth0
IF_TUNNEL=tun0
YOUR_OPENVPN_SUBNET=10.9.8.0/24
#YOUR_OPENVPN_SUBNET=10.8... |
It looks like Debian Wiki's instructions have been written to build on top of the compatibility tables and chains created by iptables-nft (or possibly the default stub /etc/nftables.conf included in the nftables package), which is the default version of iptables on Debian 10 and newer.
If you are starting from a compl... | nftables Error: Could not process rule: No such file or directory with official Debian Wiki |
1,662,510,379,000 |
I am trying to run the following nft commands:
nft add table netdev filter
nft -- add chain netdev filter input { type filter hook ingress device vlan100 priority -500 \; policy accept \; }
nft add rule netdev filter input ip daddr 198.18.0.0/24 udp dport 1234 counter drop
However, when I try to run the second comman... |
In the nftables wiki, the netdev family is described like this:
The netdev family is different from the others in that it is used to create base chains attached to a single network interface. Such base chains see all network traffic on the specified interface, with no assumptions about L2 or L3 protocols.
"No assump... | nftables refuses to add chain |
1,662,510,379,000 |
I'm on Centos 8 Stream, a rolling release version using 4.18.0-301.1.el8.x86_64 and I find weird and non consistent behavior.
Depending on how firewalld is started, it has a different behavior.
When firewalld is booted at the boot, it adds LIBVIRT_* chains.
When firewalld is restarted with systemctl, all these chain... |
It's not precisely firewalld that's adding those chains. As the names of the chains suggest, it's libvirt adding them on top of your firewalld configuration.
CentOS 8 Stream's factory default configuration includes some preparations for running virtual machines (or for nested virtualization, if the CentOS 8 system its... | Why does firewalld enabled after a reboot and after a restart have a different behavior? |
1,662,510,379,000 |
I'm a bit frustrated by the lack of comprehensive documentation of nftables and currently I'm failing to get even a simple example to work. I'm trying just create a output rule. Here's my only table:
root@localhost ~ # nft list ruleset
table inet filter {
chain output {
type filter hook output priority 0;... |
The correct command is
root@localhost ~ # nft add rule inet filter output ip daddr 8.8.8.8 counter
Notice the inet prefix before the table name (filter). That's the table's family type. It's optional, but if you omit it, nft assumes ip (= IPv4), but I'm using inet pseudo-family (both IPv4 and I... | nftables, add output rule syntax |
1,662,510,379,000 |
Here is relevant example ruleset with 2 sample nftables NAT rules which masquerade IP from virtual machine to LAN:
#!/usr/sbin/nft -f
add table nat_4
# Sees all packets after routing, just before they leave the local system
add chain nat_4 postrouting_nat_4 {
type nat hook postrouting priority srcnat; policy acc... |
I think things are clearer if you look at the documentation for the iptables MASQUERADE target. From iptables-extensions(8):
MASQUERADE
[...]
--to-ports port[-port]
This specifies a range of source ports to use, overriding
the default SNAT source port selection heuristics (see
above). This is only valid if the rule ... | usage and meaning of masquerade [to :PORT_SPEC] |
1,662,510,379,000 |
I want to match every traffic from a server but it is at the same interface.
MAC 88:7e:25:d3:90:0b > ens19 > table 147
Therefore I made this nftables rule
table ip filter { # handle 3
chain input { # handle 1
type filter hook input priority filter; policy accept;
iif "ens19" ether saddr 88... |
hook input is specifically meant for packets where the local host is the final destination – it is only reached after routing decisions have been made, as that's how netfilter knows which packets are processed through "hook input" chains and which ones go through "hook forward" chains. So at that point, your policy ru... | MAC based routing with nftables and ipv6 |
1,662,510,379,000 |
List all ruleset currently:
sudo nft list ruleset
table inet filter {
chain input {
type filter hook input priority 0; policy accept;
iif "lo" accept
}
chain forward {
type filter hook forward priority 0; policy drop;
}
chain output {
type filter hook output priori... |
You said
Reboot pc and list all ruleset:
Check if /etc/nftables.conf exist, you should empty or delete that too and then run nft flush ruleset.
Depending on your distro, you may want to get rid of packages like netfilter-persistent if you don't want them at all.
| `nft flush ruleset` can't delete all rules permanently? |
1,662,510,379,000 |
The documentation suggests that from nftables 0.9.4 on it's possible to use typeof ip daddr (and similar) to combine IPv4 and IPv6 sets. Alas, the LTS Ubuntu version 20.04 is one patch short of that version (0.9.3).
Quote:
The typeof keyword is available since 0.9.4 and allows you to use a high level expression, the... |
Currently as of 2021-05-01 no version of kernel and nftables (including 0.9.8) can do this.
Pablo Neira Ayuso, a lead developer wrote on 2020-09-26 there's no major architectural issue preventing its implementation, but it's not done yet.
https://www.spinics.net/lists/netfilter/msg59761.html :
So you would like to co... | Prior to nftables 0.9.4 is there a way to express a set of sets to unify IPv4 and IPv6 rules? |
1,662,510,379,000 |
I was following tutorial at https://wiki.nftables.org/wiki-nftables/index.php/Main_Page
Here is what I did.
#uname -a
Linux delor 4.9.0-0.bpo.6-amd64 #1 SMP Debian 4.9.88-1+deb9u1~bpo8+1 (2018-05-13) x86_64 GNU/Linux
# sudo nft add table ip filter
# sudo nft add chain ip filter output { type filter hook input priorit... |
Your output chain is using the input hook. So it's actually a second chain working for input. Its name doesn't matter. What does matter is its hook: input.
Use instead:
# sudo nft add chain ip filter output { type filter hook output priority 0 \; }
| nftables not working, am I doing it right? |
1,662,510,379,000 |
With a standard log rule "ct state new" we get the details about a new session, however, we only get the data size of the first packet looking in LEN i.e.
2024-06-15T10:11:31.829667+00:00 deepu kernel: ALLOW INPUT: IN=ens33 OUT= MAC=ff:ff:ff:ff:ff:ff:3a:f9:d3:87:89:65:08:cc SRC=172.16.0.1 DST=172.16.0.255 LEN=72 TOS=0... |
The basic iptables/nftables counters only track the number of bytes/packages that have matched a particular rule, regardless of which connection they belong to.
For per-session statistics, you would need to track individual connections and log connection statistics whenever a connection ends. Sounds like a job for the... | How can I get nftables to log the data transferred per session? |
1,402,528,639,000 |
I have some question in closing port, I think I got some strange things.
When I use execute
nmap --top-ports 10 192.168.1.1
it shows that 23/TCP port is open.
But when I execute
nmap --top-ports 10 localhost
it show that 23/tcp port is closed.
Which of them is true? I want to close this port on my whole system, how ... |
Nmap is a great port scanner, but sometimes you want something more authoritative. You can ask the kernel what processes have which ports open by using the netstat utility:
me@myhost:~$ sudo netstat -tlnp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Pro... | How to close ports in Linux? |
1,402,528,639,000 |
Can nmap list all hosts on the local network that have both SSH and HTTP open? To do so, I can run something like:
nmap 192.168.1.1-254 -p22,80 --open
However, this lists hosts that have ANY of the list ports open, whereas I would like hosts that have ALL of the ports open. In addition, the output is quite verbose:... |
There is not a way to do that within Nmap, but your comment about not wanting "to rely on the output format of nmap" lets me point out that Nmap has two stable output formats for machine-readable parsing. The older one is Grepable output (-oG), which works well for processing with perl, awk, and grep, but is missing s... | Can nmap display only hosts with specific ports open? |
1,402,528,639,000 |
My rental Linux server doesn't respond to nmap the way I thought it would. When I run nmap it shows three open ports: 80, 443 and 8080. However, I know ports 2083, 22 and 2222 should all be open, as they're used for the web-based C-Panel, SSH and SFTP, respectively.
Has my server rental company not opened these po... |
By default, nmap scans the thousand most common ports. Ports 2083 and 2222 aren't on that list. In order to perform a complete scan, you need to specify "all ports" (nmap -p 1-65535, or the shortcut form nmap -p-).
Port 22, on the other hand, is on the list. If nmap isn't reporting it, it's because something's bloc... | nmap doesn't appear to list all open ports |
1,402,528,639,000 |
A few days ago I started to care a lot about my data security, I end up nmaping myself with: nmap 127.0.0.1
Surprise, surprise, I have lots of active services listen to localhost:
$ nmap 127.0.0.1
Starting Nmap 5.21 ( http://nmap.org ) at 2013-05-05 00:19 WEST
Nmap scan report for localhost (127.0.0.1)
Host is up (0.0... |
Determine your exposure
Taking your output from the netstat command, what looks like a lot of services is actually a very short list:
$ netstat -lntup | awk '{print $6 $7}'|sed 's/LISTEN//'| cut -d"/" -f2|sort|uniq|grep -v Foreign
avahi-daemon:r
dhclient
dropbox
nmbd
rpcbind
rpc.statd
smbd
sshd
Getting a lay of the l... | How to "close" open ports? |
1,402,528,639,000 |
The nmap man page has this to say about the -sn parameter:
-sn (No port scan) .
This option tells Nmap not to do a port scan after host
discovery, and only print out the available hosts that
responded to the scan.
The first half of the sentence mentions that there is no scan, but the second half says that... |
You're right that the documentation is worded poorly. -sn means "skip the port scan phase," and was previously available as -sP, with the mnemonic "Ping scan".
Nmap scans happen in phases. These are:
Name resolution
NSE script pre-scan phase
Host discovery ("ping" scan, but not necessarily ICMP Echo request)
Parallel... | Nmap -sn: scan or no scan? |
1,402,528,639,000 |
Today the IT manager got angry because I used nmap on the 3 servers I manage to see what ports they had open. I know I could have used netstat inside the host' shell.
He told me that "If the network goes down because of nmap I would be punished". I would like to know technically how many network bandwith / bytes would... |
This is easy enough to measure, at least if you nmap a host your machine is not otherwise communicating with. Just use tcpdump or wireshark to capture the traffic, limited to that IP address. You could also use iptables counters, etc.
I did so (using wireshark), the machine I tested on has fewer open TCP ports (5), bu... | How many bytes occupy a simple nmap to a host? |
1,402,528,639,000 |
The following IP address is for my network interface
$ nmap 192.168.0.142
Starting Nmap 7.60 ( https://nmap.org ) at 2019-03-09 11:33 EST
Nmap scan report for ocean (192.168.0.142)
Host is up (0.00047s latency).
Not shown: 996 closed ports
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
111/tcp open r... |
The other two answers both raise very important points. But in addition, you appear to have only scanned TCP and not UDP :-). So there might also be UDP services you want to worry about.
UDP scanning has a number of issues that do not apply to TCP scanning. In either case, I would start by querying the OS instead: ... | Difference between `nmap local-IP-address` and `nmap localhost` |
1,402,528,639,000 |
When I type in the command nmap –Pn –sT -sV –p0-65535 192.168.1.100, my terminal responds:
Starting Nmap 7.60 ( https://nmap.org ) at 2018-01-29 11:24 PST
Failed to resolve "–Pn".
Failed to resolve "–sT".
Failed to resolve "–p0-65535".
Nmap scan report for 192.168.1.100
Host is up (0.0075s latency).
Not shown: 999 clo... |
nmap did not recognize those options because they start with a unicode EN DASH (342 200 223, –) instead of a hyphen or regular dash (-). As a result, nmap interprets those "options" as names to resolve.
| Nmap unable to resolve flags |
1,402,528,639,000 |
Per this comment, I'm going to take advice and ask this as a separate question. I am trying to learn more about networking and security and want to play with tools to help increase my understanding.
Fing seems like a pretty cool tool - finding devices on the network and their associated MAC address. One could easily... |
I just ran Fing against my wireless network. Using tcpdump, it appears that Fing generates Address Resolution Protocol (ARP) request packets. ARP is a pretty simple protocol that runs at the Ethernet Protocol level (Data Link, OSI level 2). An ARP request packet has the broadcast address (ff:ff:ff:ff:ff:ff) as the "to... | How does FING (or any of the IP/MAC Address Mappers) work? |
1,402,528,639,000 |
I know that i can use nmap to see which ports are open on specific machine.
But what i need is a way to get it from the host side itself.
Currently, if i use nmap on one of my machines to check the other one, i get for an example:
smb:~# nmap 192.168.1.4
PORT STATE SERVICE
25/tcp open smtp
80/tcp open http
... |
On Linux, you can use:
ss -ltu
or
netstat -ltu
To list the listening TCP and UDP ports.
Add the -n option (for either ss or netstat) if you want to disable the translation from port number and IP address to service and host name.
Add the -p option to see the processes (if any, some ports may be bound by the kernel ... | A way to find open ports on a host machine |
1,402,528,639,000 |
According to https://networkengineering.stackexchange.com/a/57909/, a packet sent to 192.168.1.97 "doesn't leave the host but is treated like a packet received from the network, addressed to 192.168.1.97." So same as sending a packet to loop back 127.0.0.1.
why does nmap 127.0.0.1 return more services than nmap 192.... |
In short, they are two different interfaces (192.168.1.97 vs 127.0.0.1), and may have different firewall rules applied and/or services listening. Being on the same machine means relatively little.
| why `nmap 192.168.1.97` returns less services than `nmap 127.0.0.1`? [duplicate] |
1,402,528,639,000 |
I am testing my Debian Server with some Nmap port Scanning. My Debian is a Virtual Machine running on a bridged connection.
Classic port scanning using TCP SYN request works fine and detects port 80 as open (which is correct) :
nmap -p 80 192.168.1.166
Starting Nmap 6.47 ( http://nmap.org ) at 2016-02-10 21:36 CET... |
Albeit TCP and UDP are part of TCP/IP, both belong to the same TCP/IP or OSI layers, and both are a layer above IP, they are different protocols.
http://www.cyberciti.biz/faq/key-differences-between-tcp-and-udp-protocols/
Transmission Control Protocol (TCP) and User Datagram Protocol (UDP) are
two of the core prot... | ICMP : Port unreachable error even if port is open |
1,402,528,639,000 |
I noticed I have several networks with all ICMP messages blocked at the firewall level, except for ICMP echo and reply.
I know that there is a need at least ICMP messages type 3 in IPv4 have to be allowed for the MTU negotiation to occur.
The packets can be sniffed with the command:
sudo tcpdump icmp
However, how do ... |
You need ICMP type 3 "destination unreachable" packets to provide healthy IP connections.
The easiest way to generate ICMP packets type 3 for testing is by using the nping program.
The nping program is part of the nmap package, and as such there is a need to have it installed. For it you have to do:
sudo apt install ... | MTU (IPv4) tests in Linux |
1,402,528,639,000 |
Nmap scanning network for SNMP enabled devices:
sudo nmap -sU -p 161 --script default,snmp-sysdescr 26.14.32.120/24
I'm trying figure out how make that nmap return only devices that have specific entries in snmp-sysdescr object:
snmp-sysdescr: "Target device name"
Is that possible?
|
Nmap doesn't contain much in the way of output filtering options: --open will limit output to hosts containing open ports (any open ports). -v0 will prevent any output to the screen.
Instead, the best way to accomplish this is to save the XML output of the scan (using the -oX or -oA output options), which will contain... | Nmap scan for SNMP enabled devices |
1,402,528,639,000 |
When I execute nmap -sn 192.168.1.1-255, I get:
Nmap scan report for router (192.168.1.1)
Host is up (0.037s latency).
Nmap scan report for 192.168.1.17 # This is my smart TV
Host is up (0.054s latency).
Nmap scan report for prometheus (192.168.1.164)
Host is up (0.0020s latency).
Nmap done: 255 IP addresses (3 host... |
As I read the "help" output of nmap, "-sL" lists out the possible scan targets. On my little intranet, nmap clearly does DNS lookups: in addition to IP addresses, it gives the DNS names I've assigned, even if those hosts aren't even plugged in. But in any case, nmap -sL just lists IP addresses and host names, it doesn... | nmap -sn lists all active hosts on my network, but nmap -sL does not |
1,402,528,639,000 |
I am interested in detecting any nmap scans directed on a (my) GNU/Linux host. I would like to use snort in combination with barnyard2 and snorby for this, or if possible to perform a signature-based detection on snort unified2 logs. I noticed a similar packet to the following pops up when performing a nmap -A scan:
[... |
Have you looked at the emerging threats ruleset? Specifically their scan rules?
You will never detect detect scans with 100% accuracy. Generally speaking, thresholding is useful. On border firewalls on a large network, I look at e.g. number of distinct hosts contacted by a some remote host over a certain period. On a ... | What's the most effective way to detect nmap scans? |
1,402,528,639,000 |
I have a project where I know a single computer and a single printer will be the only things on the network. What I want to do is detect when the printer is connected to the network. I also know that the computer is 192.168.3.1. However, with DHCP I won't know the printer address (yes, it could be made static to make ... |
There's no need to scan the entire subnet if you know that you're not interested in part of it. (Avoiding the computer means you don't need to discard its result.)
nmap -oG - -sn 192.168.3.2-254 | awk '$NF=="Up" {print $2}'
or if you prefer using the XML output instead of the grep output
nmap -oX - -sP 192.168.3.2-25... | nmap to awk to sed. is there a better way? |
1,402,528,639,000 |
Is it possible to runnmap via Tor?
When I googled around, I got the impression that Tor uses Polipo / Privoxy, which are socks5 proxies. So any TCP / UDP aware applications should be able to use them as a gateway to route their traffic.
But somewhere it also said that nmap uses raw packets, so it can't be run over Tor... |
Short answer
Yes it is possible, use tsocks nmap -sT IP
Long answer
First of all Tor doesn't use privoxy, Tor provides an socks proxy for connecting via the Tor network.
This means you won't see any network routes or things like that on your system but you have to configure your applications to use the Tor socks proxy... | Run nmap via Tor |
1,402,528,639,000 |
I am looking for a quick way to scan for commonly open ports on proxies. I am doing this through php and I have been using nmap and came up with this command:
<?php
system("nmap -PN -p U:1194,T:21,22,25,53,80,110,111,143,443,465,993,995,3306,8443,553,554,1080,3128,6515,6588,8000,8008,8080,8081,8088,8090,8118,8880,8909... |
Take a look at the Rainmap Web-hosted Nmap scanner. It was developed as a Google Summer of Code project 2 years ago under the guidance of the Nmap development team
| Fastest way to port scan. NMAP? |
1,402,528,639,000 |
I used nmap to scan all the ports in the hosts in a network by using the command:
$ nmap 172.31.100.0/24
What I found is that it showed the following in the result:
Nmap scan report for 172.31.100.0
Host is up (0.0039s latency).
Not shown: 998 closed ports
PORT STATE SERVICE
23/tcp open telnet
80/... |
172.31.100.0 is the IP address of one of the hosts you scanned. If your network is actually 172.31.96.0/21 (or larger), then 100.0 is a perfectly valid IP address.
172.31.100.0 is part of the pre-CIDR Class B IP space, so you may have gotten a default network of 173.31.0.0/16 if you didn't configure otherwise (and 10... | Doing nmap on a network |
1,402,528,639,000 |
Why am I getting the "operation not permitted" with nmap - even when executed as root?
$ sudo nmap 192.168.1.2
Starting Nmap 7.12 ( https://nmap.org ) at 2017-01-13 02:12 CST
sendto in send_ip_packet_sd: sendto(5, packet, 44, 0, 192.168.1.2, 16) => Operation not permitted
Offending packet: TCP 192.168.1.1:53769 > 192... |
This looks to be an issue with the iptable_nat module in the current 4.8.x Linux kernels (< 4.8.16), as per https://bugzilla.redhat.com/show_bug.cgi?id=1402695.
The 4.9 kernel includes a "real" fix - but as for Ubuntu, I am guessing we'll have to wait for Ubuntu 17.04 (Zesty Zapus) to see this officially. (4.9 will b... | nmap raw packet privileges not working ("operation not permitted", even as root) |
1,402,528,639,000 |
I would like to find a way to print for each IP address found to have at least one open port, to print that IP address, followed by a list of open ports separated by commas. The ports and IP address should be separated by a tab delimiter.
I can do this in an ugly fashion, by grepping only the ip address, writing that ... |
This awk program should do it:
$ echo "Host: 10.0.0.101 ()Ports: 21/closed/tcp//ftp///, 22/closed/tcp//ssh///, 23/closed/tcp//telnet///, 25/closed/tcp//smtp///, 53/closed/tcp//domain///, 110/closed/tcp//pop3///, 139/open/tcp//netbios-ssn///, 143/closed/tcp//imap///, 445/open/tcp//microsoft-ds///, 3389/closed/tcp//ms-w... | Parse (grepable) nmap output to print a list of IP\t[all open ports] with text utils like awk |
1,402,528,639,000 |
How can I use nmap to find out the utorrent version installed on a PC by scanning it from another PC on the same subnet?
|
Looking at the nmap-service-probes database, it looks like nmap can't detect which version of uTorrent is running.
| How to remotely detect another machine's utorrent version with nmap? |
1,402,528,639,000 |
Extracting results from a command in a terminal
I ran a nmap scan on my local network using this command:
nmap -sP 192.168.1.*
When I ran that command I get something that looks similar to this:
Nmap scan report for macbook.att.net (192.168.1.21)
Host is up (0.019s latency).
MAC Address: 71:DF:4B:44:80:F1 (Apple)
Nma... |
You could try with 'awk' command as follow,
nmap -sP 192.168.1.* | awk -F"[)(]" '/^Nmap/{Nmap=$(NF-1); C+=1} /^MAC Address/{print C"."$(NF-1) "("Nmap")" }'
output,
1. Apple (192.168.1.21)
2. Liteon Technology (192.168.1.15)
explanations:
with awk's -F open your are telling 'awk' that your inputs are delimited wi... | Extracting results from a command in terminal |
1,402,528,639,000 |
$ nmap -p0-65535 192.168.0.142
Starting Nmap 7.60 ( https://nmap.org ) at 2019-03-10 17:53 EDT
Nmap scan report for ocean (192.168.0.142)
Host is up (0.000031s latency).
Not shown: 65531 closed ports
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
111/tcp open rpcbind
3306/tcp open mysql
33060/t... |
The mysqlx service on port 33060 is the MySQL X DevAPI service.
nmap does not use /etc/services, it uses its own database of services.
Note that anything listening on port 33060 will be reported as the mysqlx service, and that the name of a service does not necessarily have to be part of the name of the command provid... | How can I find out information about a service? |
1,402,528,639,000 |
All of a sudden, nmap throws the following error after executing the canonical sudo nmap -sP 192.168.109.* :
nmap: Target.cc:503: void Target::stopTimeOutClock(const timeval*):
Assertion `htn.toclock_running == true' failed.
Tried to reboot PC, restart switch, router and grandma but none worked.
Nmap version is 7.8... |
As it states here, this bug has been solved in version 7.9.
Since via apt-get you won't get it (7.8 is the most recent on repo), I solved this by installing nmap via Snap as follows :
sudo apt install snapd
sudo snap install nmap
Check your new nmap version via :
sudo nmap --version
which should be the following :... | Nmap 7.8 Assertion failed: htn.toclock_running == true |
1,402,528,639,000 |
I am running a clean install of Fedora 24, and I am not sure if I accidentally did some weird key combo, but I entered:
nmap -sT -Pn [IPaddress]
and, for some reason, this added a PCI network to my PC, switched to it, and did not allow me to require my usual eth0.
I restarted my PC, and am fine, now.
But what would ... |
AFAIK by default Nmap has nothing to do with your network interfaces unless you want it to. I recommend you read Gordon (Fyodor) Lyon's NMAP NETWORK SCANNING book.
For instance if you want to use a different network interface, you should pass -e option followed by required interface name, e.g. -e wlan0. So I don't thi... | Nmap Changed My Network? |
1,402,528,639,000 |
I am learning Nmap and a thought occurred to me with regards to a SYN scan...
A SYN scan sends an empty TCP packet with the SYN flag set to illicit a response from the target of either RST, indicating that the port is closed, or SYN/ACK, indicating that the port is open.
If the port is being firewalled by IPTABLES the... |
You can send back a RST with iptables -p tcp [...] -j REJECT --reject-with tcp-reset.
I doubt there is any real value to getting nmap to say a port is "closed" instead of "filtered", though. Mainly it's to get connections refused more quickly, instead of waiting for a timeout (e.g., with -j DROP) or sometimes-unrelia... | Can you send a TCP packet with RST flag set using IPTABLES as a way to trick NMAP into thinking a port is closed? |
1,402,528,639,000 |
With nmap, I want to skip the scan on port 80. I'm sure this is in the man somewhere, but I haven't found it so far. My command is simple:
nmap 24.0.0.1\24
So this will scan ports in the 24.0.0.x range; I just need to avoid port 80 (for stealth reasons).
|
You can use the --exclude-ports option. Not sure why this wasn't mentioned earlier. Maybe it's new. I am using Nmap 7.01. So in your case you could simply do:
$ nmap 24.0.0.1\24 --exclude-ports 80
| How to skip (omit) a specific port in nmap |
1,444,532,918,000 |
I have the following command to process nmap output that contains a list of ips that I've been asked to scan:
cat ping-sweep.txt | grep "report for" | cut -d " " -f5
This is providing me a list of only the ip's (one per line) which I'd then like to scan for web servers.
I can scan an individual host with the followin... |
The first step would be trying to use Nmap in the way it was designed. Since Nmap performs host discovery ("ping sweep") prior to each port scan, you can do both steps at once with this simple command:
nmap -p 80,443,8080 [TARGETS]
If you really do need to perform the host discovery separately from the port scan, the... | How to pass multiple lines to a parameter without a for loop? |
1,444,532,918,000 |
I am trying to use Host Discovery Nmap function using the -PE (ICMP Echo Ping) option to discover hosts on my local network (virtuals machines on bridged connection).
So when I run :
nmap -PE 192.168.0.0/24
I expect Nmap to send ICMP Echo Ping, but Nmap only send classic TCP request :
Indeed, I have found in the d... |
You have to disable arp-ping:
nmap -sP -PE --disable-arp-ping 192.168.56.1
| How to force Nmap to use -PE option on local network? |
1,444,532,918,000 |
[root@notebook ~] lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 12.04.4 LTS
Release: 12.04
Codename: precise
[root@notebook ~] dpkg -l nmap | grep ^ii
ii nmap 5.21-1.1ubuntu1 The Network Mapper
[root@... |
In version 6.25, Nmap switched the language of the Nmap Scripting Engine (NSE) from Lua 5.1 to Lua 5.2. This means that you must be using at least version 6.25 in order to use the scripts on nmap.org.
Ubuntu 12.04 only has Nmap 5.21 available in its repositories, but any release after 13.10 will have a compatible vers... | How to scan for heartbleed vulnerability with nmap from Ubuntu 12.04? |
1,444,532,918,000 |
I wrote a very basic python script to port scan my system. I'm running linux-mint lisa:
open_ports = []
for port in xrange(65536):
conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
conn.connect(('localhost', port))
open_ports.append(port)
conn.close()
except socket.er... |
Outbound traffic is normally sent with the higher ports. Your port scan happened while a tcp/udp session was in progress and ended before the sequential netstats
| Running a local port scan and found open ports but, don't know what they're used for? |
1,444,532,918,000 |
Is there a way to find my type of router from the command line? My IP address is the standard 192.168.1.1 IP address.
|
You could use curl http://192.168.1.1 just to get the HTML of the login page. It probably says on it.
Also, you could use arp -a to get the MAC of the router, and then look up the first 6 digits to see what hardware vendor it is.
| Find type of router |
1,444,532,918,000 |
I have a Fedora 24 server, serving an Angular2 project. Angular2 automatically opens ports 3000 and 3001 once the service is started. However, although running nmap localhost shows the ports are open, when I run an nmap from a remote computer, these ports are showing as closed.
Is there an iptables setting I can use t... |
In the end the solution was to run the following command:
firewall-cmd --zone=FedoraServer --add-port=3000/tcp
Seems that on Fedora 24, or the Fedora 24 as set up on linodes perhaps, iptables doesn't have a TCP entry.
| Fedora 24: ports show as open when scanned from server, but closed when nmapped from outside |
1,444,532,918,000 |
Cannot seem to probe virtual guests from the virtual host.
These guests can be probed from other devices on the same LAN/Network, but not the host. I can understand why it might be struggling, but I am wondering if anyone ever found a way to make it work.
HOST: OSX 10.6
GUEST: FreeBSD 8 (two of them)
Edit:
Adding some... |
The KEXT for the network card somehow had gotten corrupt. Reloaded from the install CD and then I was able to hit the guests with various NMAP probes.
| NMAP probing VirtualBox Client |
1,444,532,918,000 |
$ nmap -n -iR 0 -sL > RANDOM-IPS-TMP.txt
$ grep -o "[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*" RANDOM-IPS-TMP.txt |
egrep -v "10.*|172.[16-32].*|192.168.*|[224-255].*" > RANDOM-IPS.txt
egrep: Invalid range end
$
How can I generate random IP Addresses outside the private IP address range and the multicast IP Address range... |
You misunderstand regex syntax. [16-32] does not mean "match 16, 17, ... or 32". It means "match one character which is either 1 or 2 or in the range 6-3" (which is not a valid range, hence the error).
It's possible to write a regex to match a range of integers, but it's complex and error prone. In your case, it wo... | How to generate random IP addresses |
1,444,532,918,000 |
I want to make a script which will check if a port is open on a server. If not open stay in a while. If open continue. The break conditions is use are if "host is up" is present and not "closed". I assume conenction is ok. The problem is that the grep is not working as expected.
I have tried with following:
while tru... |
The problem is that [[$NMAP | grep "Host is up" -ne ""]] is very far from valid bash syntax. The error messages don't tell you exactly how to fix it, but they are a hint that something is seriously wrong.
[[ expression ]] requires spaces inside the brackets. See Brackets in if condition: why am I getting syntax error... | Nmap check if port is open in bash |
1,444,532,918,000 |
I have a small snippet which gives me some ips of my current network:
#!/bin/bash
read -p "network:" network
data=$(nmap -sP $network | awk '/is up/ {print up}; {gsub (/\(|\)/,""); up = $NF}')
it returns ip addresses like this
10.0.2.1
10.0.2.15
and so on.
now I want to make them look like this:
10.0.2.1, 10.0.2.15,... |
If you need exactly ", " as separator, you could use
echo "$data" | xargs | sed -e 's/ /, /g'
or if you are enough with comma as separator, then
echo "$data" | paste -sd, -
| separating an array into comma separated values |
1,444,532,918,000 |
I run nmap on a Lubuntu machine using its own private IP address.
What are those "unknown" services?
How can I find them out? Is fuser supposed to find that out?
Thanks.
$ nmap -p0-65535 192.168.1.198
Starting Nmap 7.60 ( https://nmap.org ) at 2019-03-19 23:32 EDT
Nmap scan report for olive.fios-router.home (192.168... |
What are those "unknown" services?
Those services are "unknown" because they are not listed in nmap's services file, nmap uses that to map port numbers to services. On my system, nmap uses /usr/share/nmap/nmap-services.
I found out where the file is located by doing (I am on devuan, a debian-based system like ubunt... | What are those "unknown" services listed by nmap? |
1,444,532,918,000 |
I am using CentOS 6.5 and Nmap 5.51
I want to find all alive IPs in a LAN between two IPs
Easily get the answer
sudo nmap -sP 192.168.1.100-200
my problem when my network can access to internet the total time spend is 1.78 seconds but when my network can't access to internet the total time spend is 17.79 seconds
o... |
Your nmap is trying to query DNS servers to resolve the hostnames associated with the IP addresses your scanning.
Because it cannot succeed to do so, it times out, but you get the extra delay in the meanwhile.
Use the -n option with nmap to avoid this. That would be:
sudo nmap -n -sP 192.168.1.100-200
If you had a... | Nmap too slow with a network that can't access to internet |
1,444,532,918,000 |
I'm trying to connect to a second-hand external wifi camera. It has an ethernet slot and a sticker with the MAC address but no other branding or model/serial numbers.
I am trying to find its IP address.
My current plan is to connect an ethernet cable directly between my machine and this camera, then scan all reserved... |
You could install a DHCP server and then check its logs for the IP address the camera gets.
Alternatively you could run tcpdump to see any devices talking on your LAN.
You can monitor the ethernet port with tcpdump:
sudo tcpdump -A -i eno2
In my case, I got the following which seems to confirm that the device has no... | How to get IP addr from MAC |
1,444,532,918,000 |
I'm trying to install Zenmap after installing Nmap however it's not quite working. I tried just the regular terminal command dnf install zenmap however it tells me that they're unable to find a match.
I then went to the official website to download the RPM file and tried using the command 'rpm -i filename.rpm' which t... |
Apparently Zenmap reached EOL in F28 because it relies on now deprecated Python 2.
See the issue on github:
Zenmap and Ndiff are python2 only #1176
You should still be able to make it work by installing (deprecated) Python 2 and the necessary modules.
If I look at the source code zenmap relies on /usr/bin/env python,... | How to install zenmap on Fedora |
1,444,532,918,000 |
I am remotely connected to a system using ssh and want to run nmap on a system from there. But every 5 minutes, my SSH connection breaks and so the process running on my shell stops.
How can I run nmap in the background so that any SSH session can interact with the process?
|
You could use nohup. But screen is what you are probably looking for.
| How to run Bash Script in background [duplicate] |
1,444,532,918,000 |
I just noticed that my server is being blocked for rsync from a firewall outside of my server, so I can't rsync to any target. Now, I would also like to know what are all the ports that are being blocked by that firewall.
Is there any way to use nmap to do that? I know I can use nmap to scan the opened ports in a spe... |
No, you can not nmap to scan one computer from the same computer.
By definition, packets won't travel, and packets traveling is the whole base of the internet.
You need a router, printer, light-bulb or external computer that could run some commands and use it to look back to that computer.
I believe that you can send... | How to scan outbound closed ports with nmap? |
1,444,532,918,000 |
I have a list of IPs and I need to check them for opened ports using nmap.
So far, my script is like this:
#!/bin/bash
filename="$1"
port="$2"
echo "STARTING NMAP"
while IFS= read -r line
do
nmap --host-timeout 15s -n $line -p $2 -oN output.txt | grep "Discovered open port" | awk {'print $6'} | awk -F/ {'print $1'... |
Here's one way:
#!/bin/bash
filename="$1"
port="$2"
echo "STARTING NMAP"
## Read the file in batches of 100 lines
for((i=100;i<=$(wc -l < "$filename");i+=100)); do
head -n "$i" "$filename" | tail -n 100 |
while IFS= read -r line
do
## Launch the command in the background
nmap... | bash multi-threads |
1,444,532,918,000 |
I'd like to print all ips (IP space Port) which have open https ports given a gnmap file.
An example output for a line that has only https running on port 443:
123.123.123.123 443
A more elaborate example input and desired output (not all test-cases in there):
Host: 123.123.123.123 () Ports: 80/open/tcp//http?///, ... |
If I got the “more or less open ports below 443” case correctly, this should be a generic solution handling it correctly:
awk '/\/https\// {for(i=5;i<=NF;i++)if($i~"/open/.+/https/"){sub("/.*","",$i); print $2" "$i}}' nmap-synscan.gnmap
| Use awk to find all Ports for each IP that have https open |
1,444,532,918,000 |
This was a question on my study guide, and I believe that the script is pinging the ip addresses, so the 2nd choice. Can somebody confirm this for me?
The 5th column of NMAP output below is the IP address. Armed with that information, what does the script below do?
nmap -n -p80 -sS -PN --open 192.168.1.0/24 | grep "N... |
Firstly, I like to check the linux man(ual) pages for questions like this. Also of note, is that this script uses piping: http://en.wikipedia.org/wiki/Pipeline_%28computing%29
For example, by opening terminal and typing man nmap, we can see what nmap does and what each argument means
From the man page for nmap
Nmap (“... | What does the following script do? [closed] |
1,444,532,918,000 |
I am having problem with viewing hostnames of devices located in my LAN.
On my first laptop (Ubuntu 18.04 LTS Desktop edition) result of following command:
arp -a
Is exactly what I want:
X (192.168.56.243) at 40:a3:cc:99:2d:66 [ether] on wlan0
test-test-test (192.168.56.146) at 48:bf:6b:e3:bf:5a [ether] on wlan0
TP-L... |
You don't have access to the DNS server that can translate IP addresses to names.
There are other ways to associate host names and IP addresses, but if you have more than one computer, DNS is your best answer.
And in reply to your comment, yes, /etc/resolv.conf should contain the address of the DNS server. In a small ... | ARP hostnames problem |
1,444,532,918,000 |
Recently installed nmap but I don't know how to use it. I found the documentation, but I'd rather not have to leave the command line every time I try to learn something new with it. I'm still working through a book on Linux so I apologize if this is an easy thing to do.
|
You can use man nmap to read manual of nmap. If you want to read some other documentation outside of manual files, you can save the documentation as text file and cat or less it in console to read it.
| How do I download documentation and make it accessible from the command line? |
1,444,532,918,000 |
Closing ports except 22 and 443. This dramatically slows down the nmap scans:
-A INPUT -i eth0 -p tcp -m multiport --dports 22,443 -j ACCEPT
-A INPUT -i eth0 -p tcp -j REJECT --reject-with icmp-port-unreachable
If I remove the REJECT rule, nmap is fast.
So how to make other ports look like closed ports without slowin... |
It's the 'tcp-reset' reject type that does what the OS normally does with the closed ports:
-A INPUT -i ens3 -p tcp -j REJECT --reject-with tcp-reset
| Why REJECT slows nmap? |
1,444,532,918,000 |
Wanting to setup Nmap on my Ubuntu 14.04 LTS system to detect HeartBleed vulnerability. I followed the instructions here:
http://cyberarms.wordpress.com/2014/04/20/detecting-openssl-heartbleed-with-nmap-exploiting-with-metasploit/
To create the script files and place them in the proper directory. However the script th... |
I wrote this script, and my official guide is available here. The simplest solution is to upgrade to the latest Nmap (version 6.47 as of this writing).
| Nmap script execution to detect heartbleed is failing |
1,444,532,918,000 |
First I try running nmap -sn ip/24 to check live hosts on a subnet. It returns that all 255 hosts are live which I know is not true. I do fping -g ip/24 and get that 7 hosts are up which makes more sense.
Now I'm trying to figure out network topology using nmap -sn --traceroute ip/24 and the entire range of 0-255 is ... |
you could use fping output as nmap target list:
fping -aqg ip/24 | xargs nmap -sn --traceroute
If your problem is that some gateway in your network is giving fake ARP responses (generating false positives), you can use -sn -PE to fix that:
nmap -sn -PE --traceroute ip/24
That way, nmap will exclusively show a host ... | how to use only certain addresses in subnet for traceroute? |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.