date int64 1,220B 1,719B | question_description stringlengths 28 29.9k | accepted_answer stringlengths 12 26.4k | question_title stringlengths 14 159 |
|---|---|---|---|
1,500,453,850,000 |
I am trying to experiment with DNAT in PREROUTING. I found a tutorial here. It contains the following sentence:
This is done in the PREROUTING chain, just as the packet comes in; this means that anything else on the Linux box itself (routing, packet filtering) will see the packet going to its 'real' destination.
I w... |
Your first question is already answered by the text you quoted:
This is done in the PREROUTING chain, just as the packet comes in;
this means that anything else on the Linux box itself (routing,
packet filtering) will see the packet going to its 'real'
destination.
I.e. routing and packet filtering.
For your s... | Changing Destination IP address using iptables and DNAT |
1,500,453,850,000 |
I have /etc/iptables/rule.v4 file contains many rule, the below is the line where I see the issue
-A INPUT -p tcp -m multiport --dports 22 -j ACCEPT
-A INPUT -p udp -m multiport --dports 16384:32768 -j ACCEPT
When I tried to do iptables-restore it failed with below error
root@rs-dal:/etc/iptables# iptables-restore ru... |
As user A.B. points out there is an issue with incompatibility between nftables, which Buster uses, and iptables. The best way to save iptables rules to be restored with iptables-restore between compatible versions.
Remove the offending line, and restore the rules:
iptables-restore < rules.q
Re-add the rule to your... | iptables-restore failed in Debian buster/sid if it has --multiport option in the rules file |
1,500,453,850,000 |
I am experimenting with netfilter in a Docker container. I have three containers, one a "router", and two "endpoints". They are each connected via pipework, so an external (host) bridge exists for each endpoint<->router connection. Something like this:
containerA (eth1) -- hostbridgeA -- (eth1) containerR
containerB (... |
Introduction and simplified reproducer setup
Docker loads the br_netfilter module. Once loaded, it affects all present and future network namespaces. This is for historical and compatibility reasons, as described in my answer for this Q/A.
So when this is done on the host:
service docker start
# When using linux bri... | Netfilter and forward chain traces ARP but not other packets |
1,500,453,850,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,500,453,850,000 |
I am using tc to change the MAC address of incoming packets on a TAP interface (tap0) as follows where mac_org is the MAC address of a guest in a QEMU virtual machine and mac_new is a different MAC address that mac_org should be replaced with.
tc qdisc add dev tap0 ingress handle ffff:
tc filter add dev tap0 protocol ... |
My understanding is that you are confusing the Ethernet address that you modify with tc (link layer only), with the inner CHADDR field (client's hardware address) that was embedded by the client inside the DHCPDISCOVER request (application layer which won't ever be altered by tc).
| MAC address rewriting using tc |
1,500,453,850,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,500,453,850,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,500,453,850,000 |
It's possible to pass multiple parameters to the "filterref" using "parameter" keyword. Like this:
<filterref filter='no-ip-spoofing'>
<parameter name='IP' value='10.0.0.1'/>
<parameter name='IP' value='10.0.0.2'/>
</filterref>
And use they in "no-ip-spoofing" inside "rule" statement:
<rule action='return' dire... |
Don't take it as RTFM, yet documentation has just the thing for such uses (https://libvirt.org/formatnwfilter.html#usage-of-variables-in-filters). Using two arrays of parameters and a single iterator should suffice, and I quote:
Accessing the same variables using a single iterator, for example by
using the notation $S... | libvirt nwfilter, multiple parameters |
1,500,453,850,000 |
I use a set of iptables rules that makes use of the mangle table, which contains the rows below, on two different versions of iptables v1.3.8, and v1.4.7.
Iptables v1.3.8 runs on Fedora release 8 kernel 2.6.23.1-42.fc8
Iptables v1.4.7 runs on Scientific Linux (a RHEL clone) 6.10 kernel 2.6.32-573.1
Both PCs are config... |
The main change between your two systems isn't iptables but the kernel. The older kernel is from 2007.
One notable change that affects routing (which isn't provided by OP in this question but is in OP's other question) when used with marks is src_valid_mark:
net: restore ip source validation
when using policy routing... | Same iptables rules for two different iptables versions |
1,500,453,850,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,500,453,850,000 |
I had question about IPtables.
Let's start with this example of my book:
What rules you would set for a mail server accepting connections for
EMSTP (port 465) and IMAP (port 993) having a network interface eth1
exposed to the Internet and another network interface eth2 exposed to
the corporate network?
I tried... |
First, some reminders:
-p argument is to specificy protocols like TCP, UDP, ICMP ... not higher level protocol like IMAP.
OUTPUT and INPUT chains are for the packets outgoing from the machine and incoming to the machine. If you want to filter packets that are forwarded (when your machine act as a gateway), you must ... | Iptable order of rules with example |
1,500,453,850,000 |
The Netfilter's extensions man page states that:
MASQUERADE: This target is only valid in the nat table, in the POSTROUTING chain
QUESTION: How to clone the output of the MASQUERADE target with a TEE target ?
If you look at the diagram of netfilter/iptables below, you will notice that nat.POSTROUTING is the last cha... |
As far as I know, since it's not possible to have an iptables rule executed after nat/POSTROUTING, which is the last hook provided by iptables, it's not possible to use iptables to capture a packet post-NAT.
But this is possible when using nftables, since the hook priority is user defined. nft's dup statement is a di... | How to clone the output of the MASQUERADE target with a TEE? |
1,500,453,850,000 |
I read that there's another tool for netfilter that allows you to add latency to a ratelimit.
Does anyone have an example of this?
|
I use the following script to emulate various network conditions:
#!/bin/bash
intf="dev eth0"
delay="delay 400ms 100ms 50%"
loss="loss random 0%"
corrupt="corrupt 0%"
duplicate="duplicate 0%"
reorder="reorder 0%"
rate="rate 512kbit"
tc qdisc del $intf root
tc qdisc add $intf root netem $delay $loss $corrupt $duplica... | How does one use tc to add latency to a ratelimit? |
1,544,782,873,000 |
My local machine IP: 192.168.0.35
What I did: Answer that i tried here!!
sudo iptables -t nat -A OUTPUT -p tcp --dport 80 -j DNAT --to-destination 192.168.0.35:80
The error:
Now I can not access any more IP's from my local machine and I do not know why it happened.
Any IP that is: 123.123.123.123, etc ... The result ... |
Be careful using iptables command.
To have access again you have to delete the iptables command you performed.
So do with -D option and not -A to undo the command.
sudo iptables -t nat -D OUTPUT -p tcp --dport 80 -j DNAT --to-destination 192.168.0.35:80
| iptables blocking local traffic |
1,544,782,873,000 |
As I understand, Linux kernel has five hook points for IPv4 packet flow defined in netfilter_ipv4.h file:
/* IP Hooks */
/* After promisc drops, checksum checks. */
#define NF_IP_PRE_ROUTING 0
/* If the packet is destined for this box. */
#define NF_IP_LOCAL_IN 1
/* If the packet is destined for another interfa... |
The key is that tables are grouping things by design intention. All your rules intended for filtering are in this place, all your NAT rules over there. Chains are sequences of rules, and the default chains are traversed at specific points in the path of a packet.
In theory, you could add a rule that does filtering to,... | understand chains and tables in netfilter/iptables |
1,544,782,873,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,544,782,873,000 |
Is it possible to match only the DSCP portion of the IPv4 ToS or IPv6 traffic class byte using ebtables? I see that ebtables has the --ip-tos match option for IPv4 packets and the --ip6-class match option for IPv6 packets. To my understanding, those match the entire ToS or traffic class byte (i.e. the 6 DSCP bits and ... |
Answering my own question, it doesn't seem that this is possible with ebtables (thank you for the comment @A.B), as there's no mask or specific keyword for dscp. Trying this in a legacy project that uses eb/iptables, but going to migrate to nft as there's a built-in dscp keyword that should work at the bridge layer.
| Matching DSCP portion of ToS or traffic class byte using ebtables |
1,544,782,873,000 |
The Linux netfilter has multiple hooks at different OSI model layers according to this image. However, the transportation layer protocols like TCP requires additional processing like retransmission or congestion control. Does this happen before or after netfilter framework or a specific hook? And why it's designed i... |
Okay, I found this video from Devconf 2018 with Jiri Benc talking about Linux network pipeline. TCP is a transport layer protocol; for packets that use it, the network stack must first parse the data link and network layer headers. Then, the dst_input determines if the packet is for local processing or forwarding. I... | Does Linux TCP stack processing happen before or after netfilter? |
1,544,782,873,000 |
We have small kuberentes cluster running (CentOS 7, Kuberenetes 1.13 + Flannel) and after some tweaking TCP configuration (see below), we noticed that DNS was not working properly.
I don't think that our changes are directly responsible for what I have observed, nor that kubernetes is responsible. I looked up in IP ta... |
The issue seems to be CentOS 7 default configuration.
When reloading configuration sysctl -p --system, it will also reload /usr/lib/sysctl.d/00-system.conf. In /usr/lib/sysctl.d/00-system.conf, we can see following:
# Disable netfilter on bridges.
net.bridge.bridge-nf-call-ip6tables = 0
net.bridge.bridge-nf-call-iptab... | netfilter fails to properly replace destination IP of UDP response package |
1,544,782,873,000 |
I'm trying to debug netfilter synproxy module with systemtap.
This is probe point I'm trying to add.
# stap -l 'module("ipt_SYNPROXY").statement("*")' | grep send_client_synack
module("ipt_SYNPROXY").statement("synproxy_send_client_synack@net/ipv4/netfilter/ipt_SYNPROXY.c:72")
And this is how stap script look like
pr... |
I realized it is an issue regarding gcc while compiling kernel. I applied below patch and it fixed.
https://lkml.org/lkml/2015/4/23/605
| Systemtap can not resolve probe point although it is shown in probe list |
1,442,222,686,000 |
I was able to set up a network namespace, establish a tunnel with openvpn and start an application that uses this tunnel inside the namespace. So far so good, but this application can be accessed via a web interface and I cant't figure out how to route requests to the web interface inside my LAN.
I followed a guide fr... |
I've always had issues with iptables redirections (probably my fault, I'm pretty sure it's doable). But for a case like yours, it's IMO easier to do it in user-land without iptables.
Basically, you need to have a daemon in your "default" workspace listening on TCP port 8112 and redirecting all traffic to 10.200.200.2 ... | port forwarding to application in network namespace with vpn |
1,442,222,686,000 |
I am trying to set up a VPN (using OpenVPN) such that all of the traffic, and only the traffic, to/from specific processes goes through the VPN; other processes should continue to use the physical device directly. It is my understanding that the way to do this in Linux is with network namespaces.
If I use OpenVPN nor... |
It turns out that you can put a tunnel interface into a network namespace. My entire problem was down to a mistake in bringing up the interface:
ip addr add dev $tun_tundv \
local $ifconfig_local/$ifconfig_cidr \
broadcast $ifconfig_broadcast \
scope link
The problem is "scope link", which I misunderstoo... | Feed all traffic through OpenVPN for a specific network namespace only |
1,442,222,686,000 |
Task
I need to unambiguously and without "holistic" guessing find the peer network interface of a veth end in another network namespace.
Theory ./. Reality
Albeit a lot of documentation and also answers here on SO assume that the ifindex indices of network interfaces are globally unique per host across network namespa... |
UPDATE 2023: Siemens has now released Edgeshark as OSS that provides a nice graphical web UI rendering the relationships of network interfaces in containers, the host, et cetera. It uses a Go-based implementation of the method outlined in this answer, with more bells and whistles.
Many thanks to @A.B who filled in som... | How to find the network namespace of a veth peer ifindex? |
1,442,222,686,000 |
I've set up several network namespaces on my Linux system (kernel version 3.10), and now I want to configure each network namespace to have its own DNS settings.
I created resolv.conf files in each /etc/netns/[namespace] directory, and now I want to make my system work in the following way:
In bash command line, whene... |
Just look at what is doing ip netns exec test ... in your situation, using strace.
Excerpt:
# strace -f ip netns exec test sleep 1 2>&1|egrep '/etc/|clone|mount|unshare'|egrep -vw '/etc/ld.so|access'
unshare(CLONE_NEWNS) = 0
mount("", "/", 0x55f2f4c2584f, MS_REC|MS_SLAVE, NULL) = 0
umount2("/sys", ... | Separate DNS configuration in each network namespace |
1,442,222,686,000 |
I am using network namespaces such that I can capture network traffic of a single process. The namespace is connected through the "host" via a veth pair and has network connectivity through NAT. So far this works for IP traffic and named Unix domain sockets.
A problem arises when a program needs to communicate with th... |
Connecting to a DBus daemon listening on an abstract Unix socket in a different network namespace is not possible. Such addresses can be identified in ss -x via an address that contains a @:
u_str ESTAB 0 0 @/tmp/dbus-t00hzZWBDm 11204746 * 11210618
As a workaround, you can crea... | Connect with D-Bus in a network namespace |
1,442,222,686,000 |
I am on Ubuntu 12.04, and the ip utility does not have ip netns identify <pid> option, I tried installing new iproute, but still, the option identify doesn't
seem to be working!.
If I were to write a script (or code) to list all processes in a network-namespace, or given a PID, show which network-namespace it belongs... |
You could do something like:
netns=myns
find -L /proc/[1-9]*/task/*/ns/net -samefile /run/netns/"$netns" | cut -d/ -f5
Or with zsh:
print -l /proc/[1-9]*/task/*/ns/net(e:'[ $REPLY -ef /run/netns/$netns ]'::h:h:t)
It checks the inode of the file which the /proc/*/task/*/ns/net symlink points to agains those of the fi... | How to list processes belonging to a network namespace? |
1,442,222,686,000 |
I have a process that has called unshare to create a new network namespace with just itself inside. When it calls execve to launch bash, the ip command shows that I have just an lo device. If I also create a user namespace and arrange for my process to be root inside the namespace, I can use the ip command to bring th... |
ip link has a namespace option, which in addition to a network namespace name, can use a PID to refer a process' namespace. If PID namespaces are shared between the processes, you can move devices either way; it is probably easiest from inside, when you consider PID 1 being "outside". With separate PID namespaces you ... | How do I connect a veth device inside an 'anonymous' network namespace to one outside? |
1,442,222,686,000 |
I have a cell modem connected to my server that I want to use as a means to get notification emails out when the landline dies.
To nicely separate normal network access and this exceptional cell modem access, I created a network namespace and created the network device in there as the only device. To have a program u... |
The only bug I see with your code is that you're running the user's command unnecessarily through sh -c when you should just run it directly. Running it through sh -c buys you nothing but it destroys quoting that the user originally put into the command. For example, try this:
sudo /usr/local/sbin/_oob_shim ls -l "a b... | Secure way to allow any user to run programs in specific network namespace |
1,442,222,686,000 |
I connect (via ssh -Y ...) from a machine (=client) to another machine (=server, actually in my LAN, but it is irrelevant); then I start a new network namespace (NNS, for short) on the server, I start an xterm (from the default namespace) which is displayed perfectly on my client, and lastly, from within the xterm, I ... |
I was on a similar situation, here is how I work around it.
Some background: I had to span several selenium Firefox instances within namespaces for binding them with different IP addresses. But as you know I was having the error:
Error: Can't open display: localhost:10.0
Instead of working with unix sockets as Marius... | Network namespace, ssh, X11 |
1,442,222,686,000 |
I was able to set up a network namespace and start a server that listens on 127.0.0.1 inside the namespace:
# ip netns add vpn
# ip netns exec vpn ip link set dev lo up
# ip netns exec vpn nc -l -s 127.0.0.1 -p 80 &
# ip netns exec vpn netstat -tlpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Loca... |
First: I don't think you can achieve this by using 127.0.0.0/8 and/or a loopback interface (like lo). You have to use some other IPs and interfaces, because there are specific things hardwired for 127.0.0.0/8 and for loopback.
Then there is certainly more than one method, but here's an example:
# ip netns add vpn
# ip... | How to forward traffic between Linux network namespaces? |
1,442,222,686,000 |
The Linux man page for network namespaces(7) says:
Network namespaces provide isolation of the system resources associated with networking: [...], the /sys/class/net directory, [...].
However, simply switching into a different network namespace doesn't seem to change the contents of /sys/class/net (see below for how... |
Let's look into man 5 sysfs:
/sys/class/net
Each of the entries in this directory is a symbolic link representing
one of the real or virtual networking devices that are visible in
the network namespace of the process that is accessing the directory.
So, according to this manpage, the output of ls /sys/c... | Switching into a network namespace does not change /sys/class/net? |
1,442,222,686,000 |
I have the following network topology using linux namespaces:
.--------.veth0 .--------.veth2 .--------.
| ns_snd |------------| ns_mid |------------| ns_rcv |
'--------' veth1'--------' veth3'--------'
veth0: 10.0.0.1/30
veth1: 10.0.0.2/30
veth2: 10.0.0.5/30
veth3: 10.0.0.6/30
veth0 belongs t... |
The issue is that you're trying to route a packet from namespace ns_snd through ns_mid to ns_rcv. The kernel is going to treat the namespaces as if they were separate hosts. Meaning you have to configure the kernel to act as a router.
This is rather simple to do:
sudo ip netns exec $NS_MID sysctl -w net.ipv4.ip_forwar... | routing between linux namespaces |
1,442,222,686,000 |
Is there a single (simple) command that will create a veth interface pair and assign each interface to a different network namespace?
For example, suppose that I have two namespaces: mynamespace-1 and mynamespace-2. Is there a single (simple) command that will connect these two namespaces via a veth pair where each en... |
The best that I can offer is to execute the command in one namespace (using the -n shortcut), create each endpoint with the same name, and move one of them into a different namespace in that command:
ip -n mynamespace-1 link add eth0 type veth peer name eth0 netns mynamespace-2
You'll still need to do the other stuff... | Connecting two network namespaces via a veth interface pair where each endpoint has the same name |
1,442,222,686,000 |
I have
an interface, name eth0, in my main network namespace
another interface, name jail0, in an alternate network namespace (name name0). This namespace is used by a jailed environment.
jail0 is a macvlan alias of eth0.
I see the network without any problem, from the my main system and also from my jail.
However, ... |
macvlan interface can be used in different modes which alter how data transmitted between two macvlan instances is treated. The default mode is vepa (Virtual Ethernet Port Aggregation), which possibly is why your setup doesn't work.
Short description of common modes you might want to configure:
vepa data is transmitt... | How to make reachable macvlan aliases in a different namespaces? |
1,442,222,686,000 |
I created a namespace in Linux with 'ip netns add foo', created a pair of veth interfaces and moved one in the namespace. I set up IP addresses etc., so that now I can ping my 'foo' namespace from the default namespace, i.e. a host.
However the problem is with removing a link from the namespace foo back to the default... |
From within namespace foo:
ip link set <veth-name> netns 1
From the global namespace:
ip netns exec foo ip link set <veth-name> netns 1
It moves the interface back to the global namespace.
Pitfall: avoid having the namespace named "1".
Yes, you can. You can create namespace "1". But during namespace "1" existence th... | remove link from Linux namespace |
1,442,222,686,000 |
I have an app I run in a network namespace. This works well.
I want to run the app multiple times, in different namespaces. For convenience, I want to bind mount the app's working directory to something like /tmp/nsX, inside of the namespace.
If I just do mount --bind /tmp/nsX /var/lib/my-app in the namespace, the mou... |
Why is this happening?
a network namespace doesn't change mount settings: it deals with network
but some mounted settings related to a network namespace, most prominently /sys/class/net and /proc/sys/net, as documented in the previous link do depend on the network namespace
Here there's already a difference in beha... | How can I use a bind mount in a network namespace? |
1,442,222,686,000 |
/proc/[pid]/ns/net contains a link to the inode representing the network namespace of the process with PID [pid]. Is there something similar for threads?
My use case is a multi-threaded application, where there's one main thread and a group of worker threads. The generic worker W creates a new network namespace N with... |
There is a file that associates a thread to its network namespace:
/proc/[PID]/task/[TID]/ns/net
where TID is the thread ID. This solved my issue.
| Is there a file that associates a thread to its network namespace? |
1,442,222,686,000 |
My current understanding of Linux (kernel) namespaces is that their lifetime after creation is as long as at least one of the following conditions holds true:
at least one process/thread is joined (attached, ...) to namespace X.
at least one bind-mount exists to namespace X.
at least one open fd exists referencing na... |
First, this answer to "What is the NSFS filesystem?" sheds more light on how the Linux kernel manages namespace lifecycles: using a so-called "nsfs" filesystem that the proc filesystem internally brings in. Thus, a namespace is ready for destruction when its inode isn't referenced anymore by one of the elements menti... | When does Linux "garbage-collect" namespaces? |
1,442,222,686,000 |
I have a wireguard connection (interface name wg0) to a trusted machine inside an admin network at $DAYJOB. Usually, I don't want to use wg0 for all my traffic, only for IP addresses in the 172.16.0.0/12 range. This is easily accomplished with a stanza like so in /etc/wireguard/wg0.conf:
[Peer]
# ...
AllowedIPs = 172... |
So the question is: what is the best or most canonical way to share a
wireguard interface with a network namespace, while still retaining
access to wireguard outside of the namespace?
IMO, a good approach would be to use policy-based routing for this. E.g, "any packet coming from interface A should use routing table... | How to share wireguard with namespace? |
1,442,222,686,000 |
I've followed this guide to setup a network namespace (to run VPN in). Here's my setup script:
ip netns add myns
ip link add type veth
ip link set veth1 netns myns
ip addr add 10.255.255.1/24 dev veth0
ip link set dev veth0 up
ip netns exec myns ip addr add 10.255.255.2/24 dev veth1
ip netns exec myns ip link set dev... |
In my experience, the loopback interface in the new network namespace is not brought up automatically. Check to see if it is up (example, use ip addr show in the new network namespace). If it is not up you can bring it up with something like ip netns exec myns ip link set dev lo up.
Maybe my answer should be a comme... | Access localhost from network namespace |
1,442,222,686,000 |
How can I capture traffic specifically from a network interface inside a network namespace using tshark? In my case, the network interface tun0 is moved into the network namespace called vpn.
Normally running tshark -f "port 53" clutters the output because it includes DNS queries from the main interface that the netwo... |
You can just continue with the same unshortened syntax you were using for executing a command inside a network namespace created with ip netns add:
ip netns exec vpn <command-for-capture>
Like:
ip netns exec vpn tshark -i tun0 -n -f 'port 53'
Note tshark's option -n to avoid triggering DNS resolution, especially imp... | Capture DNS traffic to and from a network namespace using tshark |
1,442,222,686,000 |
In a program I'm enumerating network namespaces by scanning /proc/pid/ for ns/net (sym) links. This program runs inside the "root" namespaces (original init) of the host itself. Normally, I need to run the scanner part as root, as otherwise I will have only limited access to other processes' /proc/pid/ information. I ... |
After some trial and error, I found out that in fact CAP_SYS_PTRACE is needed.
In contrast, CAP_DAC_READ_SEARCH and CAP_DAC_OVERRIDE don't give the required access, which includes readlink() and similar operations.
What I'm seeing can be cross-checked: first, ptrace.c gives the necessary clue in __ptrace_may_access():... | Access /proc/pid/ns/net without running query process as root? |
1,442,222,686,000 |
I have 3 Linux VMs connected like this:
/ server1 \
| ens19 2001:1::2 |
\ /
|
/ \
| ens19 2001:1::1 |
| server2 |
| ens20 2001:2::1 |
\ /
|
/ \
| ... |
There are two steps that were done initially but weren't done again in the new network namespace:
echo 1 > /proc/sys/net/ipv4/ip_forward
echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
It happens the behavior resulting from this is different between IPv4 and IPv6, as documented in the relatively new network toggle ... | IPv6 forwarding doesn't work in a network namespace |
1,442,222,686,000 |
I want to correctly match TAP/TUN devices with the processes they are using, and I want to do this from outside of these processes using TAP/TUN devices (that is, I cannot issue any ioctl()s because I don't have access to a particular file descriptor inside its process itself).
I'm aware of the answers to How to find ... |
Unfortunately, while user313992's hint about SIOCGSKNS is extremely useful for sockets, the implementation of SIOCGSKNS for TAP/TUN file descriptors is ... strange: it returns an fd for the network namespace the TAP/TUN was initially created in, but not for the current network namespace of its netdev.
Looking around m... | How to get the Linux network namespace for a tap/tun device referenced in /proc/[PID]/fdinfo/[FD]? |
1,442,222,686,000 |
I've been working on writing my own Linux container from scratch in C. I've borrowed code from several places and put up a basic version with namespaces & cgroups.
Basically, I clone a new process with all the CLONE_NEW* flags to create new namespaces for the clone'ed process.
I also set up UID mapping by inserting 0... |
I would prefer to work from a more complete specification. However from careful reading of the script and your description, I conclude you are entering a network namespace (using the script) first, and entering a user namespace afterwards.
The netns is owned by the initial userns, not your child userns. To do ping, ... | Ping not working in a new C container |
1,442,222,686,000 |
I have this local network service and this client program needing to access it. I am running them both as an unprivileged user.
I am looking for a way to sandbox the client using firejail, in a way that it cannot access network, except for localhost (or even better, except for that service).
first thing I tried was of... |
I would use and option kind of like:
firejail --interface=eth0.vlan100 --ip=someipaddress someprogram
Support for ipvlan driver was introduced in Linux
kernel 3.19.
Found Here: man firejail | Firejail
| firejail : only let a program access localhost |
1,442,222,686,000 |
Basically trying to bend bridging and NATing to my will with quite a unique project.
I've simplified what I'm doing below (VM=Kali virtual machine for testing):
ZoneX's are network namespaces, vexxx's are virtual links created with ip link
The premise is to create a gateway for the LAN which can divert traffic (based... |
The solution is to mark new connections and use the mark for policy routing:
iptables -t mangle -A FORWARD -i ve006 -m connmark -j CONNMARK --set-mark 6
iptables -t mangle -A FORWARD -i ve010 -m connmark -j CONNMARK --set-mark 10
ip rule has a test for fwmark. Thus you create a routing table for ve006 and one for ve... | How to create an internal multipath gateway |
1,442,222,686,000 |
Note
This question was originally asked about OpenVPN not setting a default gateway if one did not already exist even if you specify --redirect-gateway local or --redirect-gateway def1. As of 2.4.1, OpenVPN does set a default gateway with this option whether or not one exists already, so it's obsolete if you're using ... |
According to the manual, redirect-gateway def1 doesn't try to replace the default route, it just creates two new ones 0.0.0.0/1 and 128.0.0.0/1. How does not having a default route prevent these from being created?
If OpenVPN were only to override the default gateway it would no longer be able to get to its peer end... | Can OpenVPN create the default route if it doesn't exist? |
1,442,222,686,000 |
I am trying to use iptables to packet mark packets of a certain source/destination IP in the mangle table on a given host. The packets are later forwarded to a particular network namespace on the same host, yet the iptables rules that I've installed in that network namespace do not pick up on the mark. I am thus wonde... |
is packet marking only local to the network namespace the mark is being placed in?
Yes. the mark is local to the network namespace. Each namespace has an independent network stack, so when a packet transits from one namespace to an other it's like transiting over the wire: no mark remains.
I installed a TRACE rule ... | Linux packet mark across network namespaces |
1,442,222,686,000 |
Is cgroup a type of namespace?
I am asking this because I have seen blogs talking as if cgroup and namespaces are different. However, in different linux commands , cgroup is considered as a type of namespace. For example,
% unshare --help | grep cgroup
-C, --cgroup[=<file>] unshare cgroup namespace
% lsns --help ... |
There are a number of different namespace types, and Cgroup is one of them:
Cgroup
IPC
Network
Mount
PID
Time
User
UTS (hostname and NIS domain name)
But cgroups and cgroup namespaces are manipulated differently; cgroup namespaces virtualise cgroup hierarchies. Most of the time you’d only use cgroups directly, witho... | Is cgroup a type of namespace? |
1,442,222,686,000 |
I just started studying network namespaces and I'm looking at a very common example. This is just connecting two namespaces thanks to two veth (no bridge involved).
ip netns add net1
ip netns add net2
ip netns exec net1 ifconfig lo up
ip netns exec net2 ifconfig lo up
ip link add veth1 type veth peer name veth2
ip lin... |
TL;DR
Linux adds implicit routes when adding addresses. When the address is a /32 there can't be an implicit route added. You need then to manually add the route to other IP(s). When it's intended to route only to one destination (LAN or IP but when it's symmetric, it's often to only peer's IP), this can be abbreviate... | Directly connecting two namespaces using veth devices, what network prefix should I use? |
1,542,296,588,000 |
I am trying to understand the difference between different types of (virtual) interfaces (e.g. TUN/TAP, veth etc.) and was studying some of these types within the context of containers.
Is it possible to send packets between a container (in its own network namespace) to the host's network namespace using only TUN/TAP ... |
A tun/tap interface always belongs to some application: Packets send to the interface get read by the application, and packets written by the application enter the kernel network stack through this interface.
Typically, you'll connect up network namespace with virtual ethernet pairs (veth). They just forward packets t... | Is it possible to send packets between network namespaces using only TUN/TAP interfaces? |
1,542,296,588,000 |
How do I create a VNIC interface in linux?
What I want to do is create an interface that is linked in some way to a physical interface but functions in its own namespace.
I know the physical interface could be bridged; but this doesn't quite do what I want it to. I can also alias the interface but that too doesn't qu... |
To do this without manual bridging (brctl, etc) and re-use the physical interface I went with VLANs.
Assumptions: eth0 is the physical interface
What I did:
Create the VLAN interface: ip link add link eth0 name vlan1 type vlan id 1
Assign an IP to the interface: ip addr add x.x.x.x/24 brd x.x.x.x dev vlan1
Up the int... | Virtual NIC's in Linux? |
1,542,296,588,000 |
I am trying to use a network namespace for VPN-specific traffic, using this guide: https://schnouki.net/posts/2014/12/12/openvpn-for-a-single-application-on-linux/ on Debian.
Everything works with regard to setting up the namespace, and the bride, as shown here. The namespace is named piavpn, the veth on the namespace... |
It turned out the trick was to disable ufw:
sudo ufw disable
And then I flushed the iptables and re-added the rules, and re-wrote /etc/resolv.conf after NetworkManager overwrote it for some reason.
Now it all works perfectly.
| Using a VPN for certain applications via a network namespace |
1,542,296,588,000 |
I am trying to communicate between two network namespaces that are connected through the root namespaces using veth pairs as seen in the diagram. I am unable to perform a ping from netns A to netns B. Additionally I can ping from root namespace to both netns A (VA IP) and B (VB IP).
+-------+ +----... |
Docker changes the default forward policy to DROP:
Docker also sets the policy for the FORWARD chain to DROP. If your
Docker host also acts as a router, this will result in that router not
forwarding any traffic anymore.
As happens in OP's case:
Chain FORWARD (policy DROP 2 packets, 168 bytes)
The documentation a... | Root network namespace as transit between 2 other net namespaces |
1,542,296,588,000 |
My aim is to route the default namespace through my vpn, and create a new namespace which does not route through the vpn
(so i can selectively launch programs that should not have access to the remote vpn network).
lan address: 10.0.2.15/24 on enp0s3
vpn address: 10.111.0.10/24 on tun1
# enable forwarding
sysctl -w ne... |
It is easier to use other virtualized networking instead of bridges for this purpose.
"Don't use veth + bridge! Use macvlan!"
(from https://unix.stackexchange.com/a/546090/568691)
Add the namespace
ip netns add sample_ns
Create the macvlan link attaching it to the parent host enp0s3 (https://developers.redhat.com/b... | How to use network namespaces for vpn split tunneling |
1,542,296,588,000 |
The sender needs to transmit large data packets to the receiver (which is on the same host with 1500 MTU) and I think this can be simulated using veth with 9000 MTU, from my reading on it. But I'm not able to figure out how exactly to do that - most of the veth tutorials/articles on the internet mention network namesp... |
On Linux this setting isn't specific to veth so isn't documented along veth, but in the generic ip link command:
ip link add [ link DEVICE ] [ name ] NAME
[ txqueuelen PACKETS ]
[ address LLADDR ] [ broadcast LLADDR ]
[ mtu MTU ] [ index IDX ]
...
ip link set { DEVICE | group GROUP }
...
[ mtu MTU ]
...
You c... | How to setup veth with 9000 MTU to simulate sending and receiving large UDP multicast packets on the same host? |
1,542,296,588,000 |
I have a Linux process that creates a network namespace without registering it in /run/netns. The process has also own PID namespace. The network namespace does not have a name and I can see only id of the namespace:
# ip netns list-id
nsid 0
nsid 1
Is there a possibility to assign a name to the network namespace so ... |
There's no actual name existing in the low-level handling of namespaces. It's all handled by common actions or expectations done with every command in the iproute2 suite.
Assigning a name to an existing anonymous network namespace really means: make the iproute2 tools believe they did their usual settings when creatin... | How to assign a name to the existing anonymous network namespace |
1,542,296,588,000 |
I am trying to capture a tcpdump of a set of processes running in the mininet network emulation framework.
Mininet works by putting each process/set of processes into its own network namespace and then connecting each network namespace via veth devices.
What I am trying to do is to take a tcpdump to get a bandwidth us... |
The issue was that tcpdump was picking up the docker0 interface rather than looking on everything.
Correct command was tcpdump -i any host 10.0.0.1
| tcpdump traffic in network namespaces in `net=host` dockercontainer |
1,542,296,588,000 |
I have created a network namespace (named ppn) to run certain application in it. This works perfectly but when my commercial VPN (based on OpenVPN) is also enabled it seems that the traffic is only unidirectional.
For the creation of the network namespace, this logic was followed (also same ip addresses used): https:/... |
When packets leave the network namespace they have (in your case) a source address in the 192.168.163.0/24-network. Locally, routing back into the network namespace work just fine, but once the packets leave your local system, you need to translate this source address into an address your next-hop/gateway knows how to... | Network namespace doesn't work with vpn |
1,542,296,588,000 |
I have a Linux network namespace bind mounted at ~/mynamespace as follows:
unshare -mrn;
touch ~/mynamespace; # executed in the console opened by the first command
unshare --net=~/mynamespace true; # executed in the console opened by the first command
How can I move an interface from the anonymous network namespace c... |
unshare -mrn # which implies -U
Everything else below is run from the namespace(s) entered from above unless told otherwise.
Without using ip netns
touch $HOME/mynamespace
unshare --net=$HOME/mynamespace true
Here true ended, losing any PID reference but a mount reference was kept allowing this namespace to still e... | How to move interface into nonstandard network namespace as unprivileged user |
1,542,296,588,000 |
I am currently trying to simulate a network using network namespaces under Linux. I have already set up the nodes and connected them, and they can ping each other, one hop at a time. But I am really struggling trying to enable IP forwarding.
I am using Ubuntu Server 21.04 and networking on my system is controlled by s... |
fe80::/10 are link local addresses. I think these are unroutable (though there may be some tricks to make them routable, I never tried).
If you want to play around with IPv6 routing, don't use these; instead, assign Unique Local Addresses (ULAs, range fc00::/7) in addition to the link-local addresses (which are usuall... | IP forwarding in linux namespaces |
1,542,296,588,000 |
I'm trying to ping an external ip (in this case google) from inside a network namespace.
ip netns add ns1
# Create v-eth1 and v-peer1: v-eth1 is in the host space whereas peer-1 is supposed to be in the ns
ip link add v-eth1 type veth peer name v-peer1
# Move v-peer1 to ns
ip link set v-peer1 netns ns1
# set v-e... |
You have Docker which itself alters the firewall rules. I can't tell if that's because of Docker, but you have iptables' default policy for filter/FORWARD set to DROP preventing any routing not explicitly allowed.
EDIT: added the return direction.
To make your experiment work this should be enough (including the retur... | Unable to ping external network from namespace, probably postrouting not working |
1,542,296,588,000 |
I have two applications that use the same port for network communication (34964). I have control over (source code) the first application and it uses 192.168.0.4:34964. Whereas the other application tries to use/"claim" all IP addresses (0.0.0.0:34964), but this one I have no control over. Each application works runni... |
You have a few options.
LD_PRELOAD
You could use an LD_PRELOAD library to intercept the bind() system call to force binding to a specific address. One example of that is this, which you compile like this:
gcc -nostartfiles -fpic -shared bind.c -o bind.so -ldl -D_GNU_SOURCE
And use like this:
BIND_ADDR=127.0.0.1 LD_P... | Prevent application from using all IPs on port (0.0.0.0:34964) |
1,542,296,588,000 |
I'm interested in using a separate namespace for running a VPN client, so that every process I run into that namespace accesses the Internet through the VPN. That part I've managed to accomplish.
However, some programs communicate through the loopback interface (e.g. a daemon I want to talk to the Internet using the ... |
No, there is not a way to do that. That would break the very concept behind separation of network namespaces. There is one and only one way to "escape" that separation, and it's veth interfaces.
In a little bit more detail, it wouldn't just be a matter of somehow "sharing" a loopback interface between network namespac... | Sharing the loopback interface across network namespaces |
1,542,296,588,000 |
I have a bash script that:
does some thing
connects/opens a reverse shell.
does another thing
my-script contents:
#!/usr/bin/env bash
# does 'some thing'
sudo /usr/bin/nsenter --setuid 1000 --setgid 1000 --net=/var/run/netns/ns-a -- socat file:$(tty),raw,echo=0 tcp:10.10.10.1:2222
# does 'another thing'
Run inte... |
Okay, so it turns out it is not so trivial.
User input when
$ wgsh
wgsh@vultr /$
and piped commands:
$ wgsh <<EOD
echo 1
echo 2
echo 3
EOD
Not easy, but it is doable.
The solution is to have the local socat open the remote shell (a reverse shell). Then drop into the background, whenever piped command input is detect... | Pipe multiple commands to socat reverse shell (network-namespaced) |
1,542,296,588,000 |
I am trying to build a little project using Linux network namespaces, but am a bit overwhelmed by all the linux networking features and containerization-tech available, and thus unsure if i'm approaching this problem the right way.
THE PROBLEM / PROJECT
I currently have a simple Linux box with a single network device ... |
The approach with a bridge a veth-pairs will work, but there's a simpler one:
Use a macvlan, see e.g. here or here for some details and discussion.
That is a virtual interface that uses the physical interface (in your case, eth0) as parent (or "master"), is completely transparent to other devices that use the same par... | Linux networking: Split eth0 (w/multiple ipv4) giving each ipv4 its own virtualdevice and namespace |
1,542,296,588,000 |
I set up a virtual ethernet (veth) pair between default namespace and another namespace named RoutableNS as follow:
-------------- --------------
- veth0 - -------------- veth1 -
- 10.5.1.1 - - 10.5.1.2 -
-------------- --------------
default NS Ro... |
It's perfectly possible to masquerade or SNAT a device whose IP is not routable to the outside world. And being in a network namespace or not makes no difference.
You conveniently forgot to tell us what exactly you tried, but keep in mind that SNAT and MASQUERADE only work in the POSTROUTING table (while DNAT only wor... | SNAT to unroutable interface |
1,542,296,588,000 |
What are the default kernel parameters, when creating a new network namespace? Is there a way to override them upon creation?
I think they are inherited by the parent process. An example using unshare:
> /sbin/sysctl -a --pattern 'net.ipv4.conf.all.forwarding'
net.ipv4.conf.all.forwarding = 1
> unshare -n
> /sbin/sysc... |
I think your surmise is correct, they are inherited from the parent namespace. This seems similar to how processes clone themselves using the fork() system call, then any desired changes have to be applied by the clone, using the normal system calls. (Including replacing the current program with a completely differe... | Default kernel parameters on new network namespaces |
1,542,296,588,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,558,459,581,000 |
I've recently begun supporting Linux installed on devices with built-in nvme ssds. I noticed the device files had an extra number, beyond a number identifying the drive number and the partition number. IDE/SATA/SCSI drives normally only have a drive letter and partition number.
For example: /dev/nvme0n1p2
I got to won... |
In NVM Express and related standards, controllers give access to storage divided into one or more namespaces. Namespaces can be created and deleted via the controller, as long as there is room for them (or the underlying storage supports thin provisioning), and multiple controllers can provide access to a shared names... | What are nvme namespaces? How do they work? |
1,558,459,581,000 |
I have a laptop with NVMe SSD:
# nvme list
Node SN Model Namespace Usage Format FW Rev
---------------- -------------------- ---------------------------------------- --------- -------------------------- ---------------- ... |
The wear level is given by the “Percentage Used” field, which is specified as (page 184):
Percentage Used: Contains a vendor specific estimate of the percentage of NVM subsystem
life used based on the actual usage and the manufacturer’s prediction of NVM life. A value of
100 indicates that the estimated endurance of ... | How to evaluate the wear level of a NVMe SSD? |
1,558,459,581,000 |
I tried to run
mount /home/user/nvme0n1 -U 8da513ec-20ce-4a2d-863d-978b60089ad3 -t ext4 -o umask=0000
and the response is:
mount: /home/user/nvme0n1: wrong fs type, bad option, bad superblock
on /dev/nvme0n1, missing codepage or helper program, or other error.
However, when I remove the umask option, the SSD is m... |
You're mounting an ext4 filesystem:
... -t ext4 -o umask=0000
Per the ext4(5) man page, the ext4 filesystem does not have a umask mount option.
I want the device to have mode=777.
If you need different permissions on files and/or directories, you can set file/directory permissions on the files/directories themselves... | mount with umask does not works |
1,558,459,581,000 |
New DRAM-less NVME SSDs use a portion of the system memory as HMB (Host memory buffer).
How can I check / change NVME HMB on Linux?
(to verify it is working correctly or alter its behavior)
|
According to the NVMe base specification 2.0a, the NVME feature ID for the Host Memory Buffer is 0x0d. You can check it with the nvme get-feature command:
# nvme get-feature /dev/nvme0 -H -f 0x0d
get-feature:0xd (Host Memory Buffer), Current value:0x000001
Memory Return (MR): False
Enable Host Me... | How to check / change NVME HMB on Linux? |
1,558,459,581,000 |
I have experienced an issue nearly identical to one described in the askubuntu community.
Like that of the user who posted this issue, my system features a Kingston NVME disk, and as with that user,
my issue resolved by adding the following kernel option in the grub menu: nvme_core.default_ps_max_latency_us=0.
The us... |
The code comment within drivers/nvme/host/core.c in Linux kernel source seems to explain it best:
/*
* APST (Autonomous Power State Transition) lets us program a table of power
* state transitions that the controller will perform automatically.
*
* Depending on module params, one of the two supported techniques wi... | clarifying nvme apst problems for linux |
1,558,459,581,000 |
Why is my sequential read speed so (comparatively) slow?
While CrystalDiskMark on Win10 reports around 5GB/s (for reading as well as writing), I just do not get close to that performance on Linux.
(A copy&paste of several hundreds of GBs on Windows from/to the same drive averaged around 2,5GB/s, so I do not think CDM ... |
The culprit is sequential access. NVMEs only show their performance on many simultaneous request. So a "cp" will simply result in one [sequential] read, as does dd and also hdparm.
If you use tricks like "parallel" to create a cp process per file, the total throughput becomes a lot higher.
Windows' Explorer seems to d... | NVME SSD performance slow on Linux |
1,558,459,581,000 |
Using nvme-create-ns, we can assign namespace size and namespace capacity; what's the difference?
Is it necessary to do this before using a NVMe SSD?
|
A namespace can have a different size and capacity thanks to thin provisioning. The namespace’s size is the total size of the namespace (in logical blocks). The namespace’s capacity is the maximum number of logical blocks which can really be allocated in the namespace. So you can create a namespace which is larger tha... | What's the difference between namespace size and namespace capacity? |
1,558,459,581,000 |
I'm trying to install Arch on a Dell XPS 15 9560.
I've used nomodeset to make the text legible (otherwise it's tiny on the integrated 4k monitor) and pcie_aspm=off to stop the slew of pci bus errors as per a suggestion on the device's Arch Wiki page.
However, when I try to mount the drive I get a slew of errors (conti... |
I encountered this issue today on my Lenovo Yoga 730 with an ADATA NVMe 512G drive. I had errors when running mkfs.ext4, but it did complete. Once I tried to mount the partition I received the same error as described.
I tried the May 2019 Arch release and did not have the problem. Seems the issue was introduced with ... | Operation Not Supported Error Mounting NVME Drive on Arch Install |
1,558,459,581,000 |
I've just set up CentOS 7 on a server with NVMe drives, and was suprised not to be able to run smartctl on them:
# smartctl -a /dev/nvme0
/dev/nvme0: Unable to detect device type
Please specify device type with the -d option.
# smartctl -a /dev/nvme0 -d nvme
/dev/nvme0: Unknown device type 'nvme'
Then I noticed that... |
OK, I found 2 alternatives.
Getting a precompiled binary that works on CentOS 7
Even though their packages page only offers Smartmontools 6.2 for CentOS 7, their SVN builds page offers binaries that do work on CentOS.
The proper archive has a .linux suffix, for example I chose:
smartmontools-6.6-0-20170503-r4430.linu... | Smartmontools with NVMe support on CentOS 7 |
1,558,459,581,000 |
To optimize performance of an SSD, the Arch wiki says to run nvme id-ns /dev/nvme0n1 and evaluate the output, specifically of the last lines starting with lbaf. If there's more than one lbaf entry, then the drive supports more than one sector size option. The most pertinent information from the Arch wiki here is,
The... |
Use the -H option with the command to get the results in a human-readable format. It should look about like this:
# nvme id-ns -H /dev/nvme0n1
...
LBA Format 0 : Metadata Size: 0 bytes - Data Size: 512 bytes - Relative Performance: 2 Good (in use)
LBA Format 1 : Metadata Size: 0 bytes - Data Size: 4096 bytes - R... | How to understand the output of the nvme command? |
1,558,459,581,000 |
I bought a new NVMe SSD (SB-ROCKET-256) and installed Arch using gdisk for partioning. In theory, this SSD doesn't support 512e and I think the physical size should be 4096, am I wrong? How do I set it right? The partition table is the following:
$ parted --align optimal /dev/nvme0n1
GNU Parted 3.2
Using /dev/nvme0n1
... |
If you go to Sabrent's download page for your SSD, you'll find a package named "SSC software" - that is a Sector Size Converter.
With it, you can switch the block size presented to the system by the SSD to either 512 or 4096 bytes, but the switching process will destroy all data currently stored on the SSD.
To view t... | Wrong sector size in NVMe |
1,558,459,581,000 |
I have a Linux (Ubuntu 18, kernel 4.15) desktop booting from an M2 nvme disk.
Once a week, it will crash around midnight. The relevant log file output from /var/log/syslog.* is below:
Jul 16 00:00:00 rabbitcruncher systemd[1]: Starting Discard unused blocks...
Jul 16 00:00:00 rabbitcruncher kernel: [559644.954267] nv... |
Your Ubuntu is running inside a kvm virtual machine with AMD-Vi so it should not be running fstrim.
The fstrim service runs on a timer so as root:
rm /var/lib/systemd/timers/stamp-fstrim.timer
systemctl stop fstrim.service fstrim.timer
systemctl disable fstrim.service fstrim.timer
systemctl mask fstrim.service fstrim.... | nvme fstrim causing crash on linux, disabling with systemctl doesn't help |
1,558,459,581,000 |
I want to create a software raid on two identical SSDs
How do I create partitions and format them optimal?
lsblk
nvme0n1 259:0 0 953.9G 0 disk
nvme1n1 259:1 0 953.9G 0 disk
I probably have to use fdisk or parted to create partitions. What options do I need? Is this enough?
parted /dev/n... |
Use cfdisk to create a GPT partition table like this:
# fdisk /dev/nvme0n1 -l
Disk /dev/nvme0n1: 953,87 GiB, 1024209543168 bytes, 2000409264 sectors
Disk model: SAMSUNG MZVLB1T0HALR-00000
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal... | How to format NVMe drive in Linux suitable for raid 1 and lvm on xen Host |
1,558,459,581,000 |
Is it possible to swap logical device names of two NVME SSD drives installed in a laptop (Lenovo Legion 5 Pro 2022) without phisically swapping their port positions?
I would like the current /dev/nvme0n1 to become /dev/nvme1n1 and vice versa.
If it's possible, how do I do this?
My OS is Ubuntu 22.04LTS.
|
While it's not entirely impossible to change the order, doing so won't solve any problem and will only create more, so you shouldn't do it.
Device names are assigned on a first come, first serve basis, which means the order can change anytime and you should not rely on it at all. Stick to (PART-) UUID/LABEL, one of th... | Swap logical device names of two NVME SSD drives |
1,558,459,581,000 |
Test 1:
dd if=/dev/sdb of=/dev/sdc
/dev/sdb is a bootable OS HDD, /dev/sdc is another HDD, after executed the above dd command, the /dev/sdc become bootable.
Test 2:
dd if=/dev/sdb of=/dev/sdc
/dev/sdb is a bootable OS HDD, /dev/sdc is a PCIe NVME SSD, after excuted the above command, the /dev/sdc can not boot.
Simi... |
The PCIe NVMe SSDs I've seen are either not bootable at all, or only bootable using UEFI.
If you're using legacy BIOS-style boot, and a PCIe SSD does not appear as a bootable device, it's a pretty good clue that the PCIe SSD does not support legacy-style booting.
If you can get to the bootloader, but fail to start the... | dd copy from an OS HDD to PCIe NVME SSD, SSD can't boot |
1,558,459,581,000 |
I was wondering how to enable Kyber scheduler in Ubuntu 17.10, which has kernel 4.13 by default. I got bfq enabled using the instructions from How to enable and use the BFQ scheduler?. When I navigate to my NVMe drive, I am seeing only bfq.
cat /sys/block/nvme0n1/queue/scheduler
[noop] bfq
|
You can temporarily enable the three available schedulers via:
sudo modprobe bfq
sudo modprobe mq-deadline
sudo modprobe kyber-iosched
You can see the available modules in /lib/modules/<your kernel>/kernel/block.
To enable these modules on boot, you can add the following lines to /etc/modules-load.d/modules.conf (or... | How to enable Kyber scheduler in Ubuntu 17.10 kernel 4.13? |
1,558,459,581,000 |
My daily driver (Debian Bookworm RC3 + KDE Plasma) is configured to send me emails containing error notifications.
Today, I received the following email:
This message was generated by the smartd daemon running on:
host name: desk
DNS domain: local.lan
The following warning/error was logged by the smartd daemo... |
Try installing the nvme-cli package with
apt-get install nvme-cli
and then retrieve the errors using
nvme error-log /dev/nvme0
| How can I view the smart logs for an NVMe disk in Linux when smartclt is showing there are errors? |
1,558,459,581,000 |
After getting a new system, I moved the NVME drive from my old system to the new one, where both machines are set to boot using UEFI. As the EFI setup is machine specific, I expected to encounter trouble, and came prepared - I booted from a live USB, did the mounting and chrooting thing, and reinstalled GRUB according... |
TL;DR:
when using the Ubuntu-built GRUB boot loader, the UEFI boot entry MUST be named ubuntu (or at least, the GRUB EFI configuration file must be at EFI/ubuntu/grub.cfg.
Details:
The problem is with the GRUB setup in UEFI, Secure Boot (I assume) and how Ubuntu has this all set up: in legacy BIOS boot, the BIOS boots... | Computer boots to GRUB prompt, after moving drive from an old computer |
1,558,459,581,000 |
I've found a ton of posts on the internet regarding this error:
wrong fs type, bad option, bad superblock on /dev/xxx,missing codepage or helper program, or other error
Yet I have never found any case where the error just "sometimes" appears when booting.
Whenever I boot my linux machine I sometimes get the mentioned ... |
Problem: I told the kernel to boot "/dev/nvme1" instead of using labels or partition UUIDs; this caused a windows drive to be sometimes discovered as "nvme0" and sometimes "nvme1". Whenever the windows drive got "nvme1" (around 50% of the time) then the system couldn't boot it because of a fat-fs problem (fortunately ... | Probabilistic (~50%) error on boot regarding "wrong fs type, bad option, bad superblock...missing codepage or helper program, or other error" |
1,558,459,581,000 |
I have a U.2 SSD, which shows up as nvme1n1 in lsblk:
root@eris:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
nvme0n1 259:0 0 3.6T 0 disk
├─nvme0n1p1 259:1 0 476M 0 part /boot/efi
├─nvme0n1p2 259:2 0 38.1G 0 part /
└─nvme0n1p3 259:3 0 3.6T 0 part /data
nvme1n1 259:4 0 3.5T 0... |
Yeah,
ls -la /dev/disk/by-path
# or
cd /sys/block
for i in nvme*; do
echo "$i is `cat $i/device/address`"
done
| Is there a simple way to see which PCI device my NVME is? |
1,558,459,581,000 |
I try to prepare an nvme for encryption, so i first follow this post on SO.
But the speed of dd is really really slow (less than 100 mb/s). I see there is new option to speed up dm-crypt on kernel 5.9 (see this post), but before updating my kernel, i want to know if using nvme-cli format zero tools is equivalent to /d... |
Found the answer, this is much much better with oflag=direct, jumping from 45 Mb/s to 536 Mb/s :)
dd if=/dev/zero of=/dev/mapper/ecrypt oflag=direct bs=1M status=progress
Thanks to these two posts :
NVMe performance hit when using LUKS encryption
https://stackoverflow.com/questions/33485108/why-is-dd-with-the-direct... | Slow /dev/zero format using dd with nvme to prepare crypto, is there nvme specific tool? |
1,690,865,303,000 |
Recently, I noticed that there were extra symlinks in /dev/disk/by-id for my NVME drives, with the duplicates having the same name with _1 appended.
# ls -lF /dev/disk/by-id/nvme-Samsung_SSD_970_EVO_500GB_S466XXXXXXXXXXW{,_1}
lrwxrwxrwx 1 root root 13 Jul 29 19:22 /dev/disk/by-id/nvme-Samsung_SSD_970_EVO_500GB_S466XXX... |
Check these lines in /usr/lib/udev/rules.d/60-persistent-storage.rules:
KERNEL=="nvme*[0-9]n*[0-9]", ENV{DEVTYPE}=="disk", ATTRS{nsid}=="?*", ENV{ID_NSID}="$attr{nsid}"
# obsolete symlink that might get overridden on adding a new nvme controller, kept for backward compatibility
KERNEL=="nvme*[0-9]n*[0-9]", ENV{DEVTYPE... | udev makes duplicate /dev/disk/by-id symlinks for nvme drives & partitions |
1,690,865,303,000 |
I'm attempting to alias /dev/nvmeX as /dev/nvdX on bootup through the following guide: https://www.freebsd.org/cgi/man.cgi?query=nvd
I would like to know where the loader.conf file with the following contents are supposed to be placed to alias /dev/nvme0 as /dev/nvd0 on bootup:
nvme_load="YES"
nvd_load="YES"
loader.c... |
If the ESP is mounted at /boot/efi, the Arch loader.conf should be placed at /boot/EFI/loader/loader.conf.
If the ESP is mounted at /boot, then it should be at /boot/loader/loader.conf respectively.
And if you view the ESP filesystem through the GRUB prompt or any other mechanism that will focus on only one filesystem... | Where to place loader.conf on an EFI system partition with the GRUB bootloader? |
1,690,865,303,000 |
I am trying to image my Ubuntu disk using Clonezilla and it fails because I get an error saying:
error cannot have overlapping partitions
Below is how my disk is set up and the lsblkoutput:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop1 7:1 0 42,2M 1 loop /snap/snapd/14066
nvme0n1 259:0 0... |
Answer adapted from: how-to-fix-overlapped-partitions-in-the-mbr-table. You can try this but i think much be easier solution to just delete swap and logical partition
Fixing the partition table with sfdisk:
Boot with live Ubuntu disk;
Confirm the problem on your disk device, here /dev/sda with parted e.g.
sudo pa... | Clonezilla: cannot have overlapping partitions |
1,690,865,303,000 |
We have systems with both spinning mechanical disks, and NVME storage. We want to reduce the CPU overhead for IO by taking any IO scheduler out of the way. We want to specify this on the Linux boot command line; i.e. in GRUB_CMDLINE_LINUX, in the file /etc/default/grub.
For mechanical disks, we can append elevator=no... |
I/O schedulers are assigned globally at boot time.
Even if you use multiple elevator=[value] assignments only the last one will take effect.
To automatically/permanently set per-device schedulers you could use udev rules, systemd services or configuration & performance tuning tools like tuned.
As to your other questio... | How to specify multiple schedulers on the kernel boot command line? |
1,690,865,303,000 |
I want to write a small Linux driver extension. More specific: I want to write all the communication between the host and a M.2-nvme-ssd into a userspace file. The nvme driver is pretty big though and i have difficulties pinpointing some place to start at.
A colleague of mine has done something similar for SD cards. H... |
A colleague of mine has done something similar for SD cards. He traced the IO after the host has received the response from the card and is about to wrap up the operation (the function is sdhci_request_done).
Unlike SD cards, most data will actually be exchanged via DMA to an nvme device (usually), so your Linux can... | Where do i trace NVME IO within the Linux driver? |
1,690,865,303,000 |
I'm following along in this article to install arch in vmware on my m1 mac
I'm able to do fdisk just fine, and get the following partition table:
I then create the filesystem for partition 2 per the article with mkfs.ext4 /dev/nvme0n1p2. When I mount this with mount /dev/nvme0n1p2 /mnt, works fine
But when I attempt... |
You need to create a FAT filesystem on /dev/nvme0n1p1 before you can mount the partition:
mkfs.fat -F 32 /dev/nvme0n1p1
The step is missing in in the linked tutorial.
| Installing ArchLinux in VmWare Fusion on M1 Mac |
1,690,865,303,000 |
I've used dd to clone my old SATA SSD into a new and larger NVMe model on a Dell XPS 9360 and switched the SATA Configuration from the original RAID On to AHCI to get it booting. It works, but the new disk feels a lot slower than my old SSD, especially during boot. Boot times are up in the minutes vs the ~20 seconds I... |
Answer was simpler than I thought. This SSD had been dd'd from another laptop that had an offboard AMD GPU.
After I uninstalled the old Radeon drivers (following these instructions) boot times went back to normal.
| M.2 NVMe PCIe boot times much slower than old SATA SSD |
1,690,865,303,000 |
I have a system which I want to boot from an NVMe disk (via a PCIe riser). The system is UEFI capable, I can boot from a USB disk and install the OS (TrueNAS Scale) to the NVMe disk, and the OS shows up in the UEFI boot options. However when attempting to boot from that UEFI option, it fails to do so (just drops me in... |
I was able to get this working using vanilla rEFInd, and providing it with a driver for NVMe. I installed to a USB device, as this was a non-intrusive option that would be transparent to the system. Since TrueNAS is managing the boot disk, I don't want to interfere with it.
rEFInd will boot from the USB, and then chai... | How do I boot from an NVMe disk without bios support? |
1,690,865,303,000 |
After a recent update (not sure if that was the first including a new kernel 6.1) my ubuntu linux laptop cannot boot anymore
the error is
Volume group “ubuntu-vg” not found
Cannot process volume group ubuntu vg
IO error while decrypting keyslot.
Keyslot open failed.
Device /dev/nvme0n1p3 does not exist or access is de... |
Unfortunately adding nve and lvm to /etc/initramfs-tools/modules ,
updating initramfs and rebooting
was not effective.
Thus I reverted that change and then I tried adding
blacklist rtsx_pci
blacklist rtsx_pci_sdmmc
to (a new) file
/etc/modprobe.d/blacklist_rtsx.conf
and rebooting
and the problem was solved
(then I ha... | volume group not found on linux laptop after update |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.