date
int64
1,220B
1,719B
question_description
stringlengths
28
29.9k
accepted_answer
stringlengths
12
26.4k
question_title
stringlengths
14
159
1,466,655,932,000
I'm trying to setup multiple NAT networks in KVM that are isolated from each other and can't get it work. I face a behaviour that I can't explain, and I would like some clarification about it. If I setup 3 NAT networks in the IP range 192.168.122.0/24, 192.168.123.0/24 and 192.168.124.0/24, and start them in THAT order, VMs in 122 will not be able to ping either VMs in 123 or 124 (this is the behaviour I want), VMs in 123 will be able to ping 122 but not 124, and VMs in 124 will ping 122 and 123. Start order seems important, because it will implies the iptables rules order, which I thing is the reason of the behaviour. I have read in this doc: In this step, you choose a range of IP addresses to use inside this virtual network. They will be visible to all guests using this virtual network, but won't be seen outside of it due to the NAT. and in this tutorial: Although the Host OS and public networks cannot initiate connections back to guests in the NAT network, take note that KVM guests in other NAT do have the ability to reach it. information that seems contradictory. I'd like to understand the actual behaviour, and to know if there is a way to achieve what I want. Edit: The full setup is a bit complicated because it involves a GNS3 layer. What I have tried: Create different Virtual NAT Network through virt-manager on different IP range. For instance the result of virsh net-dumpxml on two of those network are : # Note : This one is the default one <network> <name>default</name> <uuid>5506b439-c3f6-4d8a-b901-66736c18c976</uuid> <forward mode='nat'> <nat> <port start='1024' end='65535'/> </nat> </forward> <bridge name='virbr0' stp='on' delay='0'/> <mac address='52:54:00:9c:bf:07'/> <ip address='192.168.122.1' netmask='255.255.255.0'> <dhcp> <range start='192.168.122.2' end='192.168.122.254'/> </dhcp> </ip> </network> # Note : This one is one I created through virt-manager <network> <name>nat-network1</name> <uuid>dca96cc1-b4bd-44ac-b1b9-9f581219fa94</uuid> <forward mode='nat'> <nat> <port start='1024' end='65535'/> </nat> </forward> <bridge name='virbr1' stp='on' delay='0'/> <mac address='52:54:00:2e:7d:d5'/> <domain name='defaul1'/> <ip address='192.168.123.1' netmask='255.255.255.0'> <dhcp> <range start='192.168.123.2' end='192.168.123.254'/> </dhcp> </ip> </network> Use a special interface in GNS3 (the "Cloud" one) that allows to link VMs to those NAT Virtual Network. I have linked for instance VM1 to default and VM2 to nat-network1. Both VM take an IP through DHCP in the range I have defined, both have an access to Internet. What I expected: I expected that VM that are setup to use different NAT Network would not be able to communicate. It appears it is not the case, in the way I explained at the beggining.
In the tutorial you posted it mentions: If you do not set the “dev” attribute to either the physical network device or bridge, then you will get unexpected behavior because it may take shortcuts and forward traffic directly from one KVM network to another using internal interfaces. This seems to be what would cause your issue. change: <forward mode='nat'> to: <forward mode='nat' dev='<network interface example: eth0>' > I tested this out it makes the iptables rules work.
KVM: isolation between different NAT networks
1,466,655,932,000
I’m trying to access a Web Service (port 8080) on my Raspberry Pi via both of the following interfaces (which have static IPs): Ethernet (eth0, 172.22.0.99, connected to a Netgear router). Wi-Fi (wlan0, 172.24.1.1, providing an Access Point). Currently, I can only access the web service if I connect to eth0 and gain an IP address 172.22.0.x. If I connect to the Wi-Fi Access Point on wlan0 then I correctly acquire an IP Address 172.24.1.x, hence SSH works, but the web service is inaccessible (both http://172.22.0.99:8080 and http://172.24.1.1:8080). I’ve been testing the above using a Windows 10 laptop. The actual problem is that I have a number of Arduinos which can connect to the Pi’s Wi-Fi Access Point (wlan0), but cannot then access the Pi’s Web Service. Hence instead I’m currently having to connect them via the Netgear router, and hence the Pi’s eth0. This is what I’m trying to avoid. Aside: the Pi is also running: OpenVPN, hence eth0 is bridged (br0, tap0). A Wi-Fi sniffer (wlan1alfa, renameX). 172.22.0.100/102/106/113 examples of a working Arduinos Various outputs : Windows 10 laptop when connected to the Pi’s Wi-Fi Access Point: ipconfig (on laptop 172.24.1.42): Wireless LAN adapter Wi-Fi: Connection-specific DNS Suffix . : Link-local IPv6 Address . . . . . : fe80::7489:b292:4e73:cbfd%2 IPv4 Address. . . . . . . . . . . :172.24.1.42 Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : 172.24.1.1 http://172.22.0.99:8080/ (on laptop 172.24.1.42) Unable to connect Firefox can't establish a connection to the server at 172.22.0.99. The site could be temporarily unavailable or too busy. Try again in a few moments. If you are unable to load any pages, check your computer's network connection. If your computer or network is protected by a firewall or proxy, make sure that Firefox is permitted to access the Web. http://172.24.1.1:8080/ (on laptop 172.24.1.42) The connection has timed out The server at 172.24.1.1 is taking too long to respond. The site could be temporarily unavailable or too busy. Try again in a few moments. If you are unable to load any pages, check your computer's network connection. If your computer or network is protected by a firewall or proxy, make sure that Firefox is permitted to access the Web. Pi: $ ifconfig br0 Link encap:Ethernet HWaddr 82:85:54:54:e1:8c inet addr:172.22.0.99 Bcast:172.22.255.255 Mask:255.255.0.0 inet6 addr: fe80::ba27:ebff:fe1a:16a3/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:1150213 errors:0 dropped:0 overruns:0 frame:0 TX packets:431995 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:200587924 (191.2 MiB) TX bytes:137714386 (131.3 MiB) eth0 Link encap:Ethernet HWaddr b8:27:eb:1a:16:a3 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:1150375 errors:0 dropped:0 overruns:0 frame:0 TX packets:449400 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:200603903 (191.3 MiB) TX bytes:143711369 (137.0 MiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:1128130 errors:0 dropped:0 overruns:0 frame:0 TX packets:1128130 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1 RX bytes:129944607 (123.9 MiB) TX bytes:129944607 (123.9 MiB) rename7 Link encap:UNSPEC HWaddr 00-C0-CA-8F-F8-1D-30-30-00-00-00-00-00-00-00-00 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:2753461 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:328484228 (313.2 MiB) TX bytes:0 (0.0 B) tap0 Link encap:Ethernet HWaddr 82:85:54:54:e1:8c inet6 addr: fe80::8085:54ff:fe54:e18c/64 Scope:Link UP BROADCAST RUNNING PROMISC MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:644390 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:100 RX bytes:0 (0.0 B) TX bytes:135759131 (129.4 MiB) wlan0 Link encap:Ethernet HWaddr b8:27:eb:4f:43:f6 inet addr:172.24.1.1 Bcast:172.24.1.255 Mask:255.255.255.0 inet6 addr: fe80::f446:4155:5d19:860a/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:479547 errors:0 dropped:0 overruns:0 frame:0 TX packets:488461 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:30867423 (29.4 MiB) TX bytes:40144827 (38.2 MiB) $ ip route default via 172.22.0.1 dev br0 metric 205 default via 172.24.1.1 dev wlan0 metric 303 172.22.0.0/16 dev br0 proto kernel scope link src 172.22.0.99 metric 205 172.24.1.0/24 dev wlan0 proto kernel scope link src 172.24.1.1 metric 303 $ ip addr show 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP group default qlen 1000 link/ether b8:27:eb:1a:16:a3 brd ff:ff:ff:ff:ff:ff 3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether b8:27:eb:4f:43:f6 brd ff:ff:ff:ff:ff:ff inet 172.24.1.1/24 brd 172.24.1.255 scope global wlan0 valid_lft forever preferred_lft forever inet6 fe80::f446:4155:5d19:860a/64 scope link valid_lft forever preferred_lft forever 4: wlan1alfa: <BROADCAST,MULTICAST> mtu 1500 qdisc mq state DOWN group default qlen 1000 link/ether 00:c0:ca:8f:f8:1d brd ff:ff:ff:ff:ff:ff 5: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000 link/ether 82:85:54:54:e1:8c brd ff:ff:ff:ff:ff:ff inet 172.22.0.99/16 brd 172.22.255.255 scope global br0 valid_lft forever preferred_lft forever inet6 fe80::ba27:ebff:fe1a:16a3/64 scope link valid_lft forever preferred_lft forever 6: tap0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UNKNOWN group default qlen 100 link/ether 82:85:54:54:e1:8c brd ff:ff:ff:ff:ff:ff inet6 fe80::8085:54ff:fe54:e18c/64 scope link valid_lft forever preferred_lft forever 7: rename7: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UNKNOWN group default qlen 1000 link/ieee802.11/radiotap 00:c0:ca:8f:f8:1d brd ff:ff:ff:ff:ff:ff iptables: # Add a masquerade for outbound traffic on eth0 iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE .. echo " # Forward WLAN to Eth, and back (note: incoming initiated on WLAN do not get to LAN)" sudo iptables -A FORWARD -i wlan0 -o eth0 -j FORWARD_LOG_ACCEPT -m comment --comment Accept_FORWARD_WLAN0_to_Eth0 sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j FORWARD_LOG_ACCEPT -m comment --comment Accept_FORWARD_Eth0_backTo_WLAN0 sudo iptables -A FORWARD -i eth0 -o wlan0 -j FORWARD_LOG_ACCEPT -m comment --comment Accept_FORWARD_eth0_to_wlan0 sudo iptables -A FORWARD -i wlan0 -o eth0 -m state --state RELATED,ESTABLISHED -j FORWARD_LOG_ACCEPT -m comment --comment Accept_FORWARD_wlan0_to_eth0 $ tail /var/log/messages from iptables (with everything being logged whether Accepted or Dropped): trying http://172.22.0.99:8080 : • Feb 18 13:23:25 shep kernel: [1630978.112563] IPTables-Accepted-I: IN=wlan0 OUT= MAC=b8:27:eb:4f:43:f6:60:14:b3:74:61:cf:08:00 SRC=172.24.1.42 (laptop) DST=172.22.0.99 LEN=40 TOS=0x00 PREC=0x00 TTL=128 ID=26841 PROTO=TCP SPT=51634 DPT=22 WINDOW=66 RES=0x00 ACK URGP=0 • Feb 18 13:23:37 shep kernel: [1630990.317785] IPTables-Accepted-I: IN=wlan0 OUT= MAC=b8:27:eb:4f:43:f6:60:14:b3:74:61:cf:08:00 SRC=172.24.1.42 (laptop) DST=172.22.0.99 LEN=104 TOS=0x00 PREC=0x00 TTL=128 ID=26843 PROTO=TCP SPT=51634 DPT=22 WINDOW=68 RES=0x00 ACK PSH URGP=0 • Feb 18 13:23:37 shep kernel: [1630990.318185] IPTables-Accepted-O: IN= OUT=wlan0 SRC=172.22.0.99 DST=172.24.1.42 (laptop) LEN=104 TOS=0x10 PREC=0x00 TTL=64 ID=54479 DF PROTO=TCP SPT=22 DPT=51634 WINDOW=424 RES=0x00 ACK PSH URGP=0 • Feb 18 13:23:49 shep kernel: [1631002.193203] IPTables-Accepted-I: IN=wlan0 OUT= MAC=b8:27:eb:4f:43:f6:60:14:b3:74:61:cf:08:00 SRC=172.24.1.42 (laptop) DST=172.22.0.99 LEN=52 TOS=0x00 PREC=0x00 TTL=128 ID=26851 DF PROTO=TCP SPT=51642 DPT=80 WINDOW=17520 RES=0x00 SYN URGP=0 • Feb 18 13:23:49 shep kernel: [1631002.193337] IPTables-Accepted-O: IN= OUT=wlan0 SRC=172.22.0.99 DST=172.24.1.42 (laptop) LEN=40 TOS=0x00 PREC=0x00 TTL=64 ID=51503 DF PROTO=TCP SPT=80 DPT=51642 WINDOW=0 RES=0x00 ACK RST URGP=0 • Feb 18 13:24:01 shep kernel: [1631014.835337] IPTables-Accepted-O: IN= OUT=lo SRC=172.22.0.99 DST=172.22.0.99 LEN=60 TOS=0x00 PREC=0x00 TTL=64 ID=23677 DF PROTO=TCP SPT=60692 DPT=8080 WINDOW=43690 RES=0x00 SYN URGP=0 • Feb 18 13:24:01 shep kernel: [1631014.835409] IPTables-Accepted-I: IN=lo OUT= MAC=00:00:00:00:00:00:00:00:00:00:00:00:08:00 SRC=172.22.0.99 DST=172.22.0.99 LEN=60 TOS=0x00 PREC=0x00 TTL=64 ID=23677 DF PROTO=TCP SPT=60692 DPT=8080 WINDOW=43690 RES=0x00 SYN URGP=0 • Feb 18 13:24:27 shep kernel: [1631039.962078] IPTables-Accepted-I: IN=wlan0 OUT= MAC=b8:27:eb:4f:43:f6:60:14:b3:74:61:cf:08:00 SRC=172.24.1.42 (laptop) DST=172.22.0.99 LEN=52 TOS=0x00 PREC=0x00 TTL=128 ID=26874 DF PROTO=TCP SPT=51648 DPT=80 WINDOW=17520 RES=0x00 SYN URGP=0 • Feb 18 13:24:27 shep kernel: [1631039.962176] IPTables-Accepted-O: IN= OUT=wlan0 SRC=172.22.0.99 DST=172.24.1.42 (laptop) LEN=40 TOS=0x00 PREC=0x00 TTL=64 ID=53485 DF PROTO=TCP SPT=80 DPT=51648 WINDOW=0 RES=0x00 ACK RST URGP=0 • Feb 18 13:24:37 shep kernel: [1631050.042812] IPTables-Accepted-O: IN= OUT=br0 SRC=172.22.0.99 DST=172.22.0.113 LEN=520 TOS=0x00 PREC=0x00 TTL=64 ID=55862 DF PROTO=TCP SPT=8080 DPT=50211 WINDOW=29200 RES=0x00 ACK PSH URGP=0 • Feb 18 13:24:37 shep kernel: [1631050.065256] IPTables-Accepted-I: IN=br0 OUT= MAC=82:85:54:54:e1:8c:ec:fa:bc:14:3f:6e:08:00 SRC=172.22.0.113 (Arduino) DST=172.22.0.99 LEN=40 TOS=0x00 PREC=0x00 TTL=255 ID=31426 PROTO=TCP SPT=50211 DPT=8080 WINDOW=1200 RES=0x00 ACK URGP=0 • Feb 18 13:24:49 shep kernel: [1631062.130744] IPTables-Accepted-I: IN=br0 OUT= MAC=82:85:54:54:e1:8c:ec:fa:bc:14:3f:6e:08:00 SRC=172.22.0.113 (Arduino) DST=172.22.0.99 LEN=150 TOS=0x00 PREC=0x00 TTL=255 ID=31430 PROTO=TCP SPT=50211 DPT=8080 WINDOW=1672 RES=0x00 ACK PSH URGP=0 • Feb 18 13:24:49 shep kernel: [1631062.131706] IPTables-Accepted-O: IN= OUT=br0 SRC=172.22.0.99 DST=172.22.0.113 LEN=519 TOS=0x00 PREC=0x00 TTL=64 ID=55865 DF PROTO=TCP SPT=8080 DPT=50211 WINDOW=29200 RES=0x00 ACK PSH URGP=0 • Feb 18 13:25:01 shep kernel: [1631074.255485] IPTables-Accepted-I: IN=br0 OUT= MAC=82:85:54:54:e1:8c:ec:fa:bc:14:3f:6e:08:00 SRC=172.22.0.113 (Arduino) DST=172.22.0.99 LEN=165 TOS=0x00 PREC=0x00 TTL=255 ID=31435 PROTO=TCP SPT=50211 DPT=8080 WINDOW=1645 RES=0x00 ACK PSH URGP=0 • Feb 18 13:25:01 shep kernel: [1631074.301286] IPTables-Accepted-O: IN= OUT=br0 SRC=172.22.0.99 DST=172.22.0.113 (Arduino) LEN=40 TOS=0x00 PREC=0x00 TTL=64 ID=55867 DF PROTO=TCP SPT=8080 DPT=50211 WINDOW=29200 RES=0x00 ACK URGP=0 trying http://172.24.1.1:8080 : • Feb 18 15:14:15 shep kernel: [1637627.961592] IPTables-Accepted-I: IN=br0 OUT= MAC=82:85:54:54:e1:8c:18:fe:34:d2:92:d6:08:00 SRC=172.22.0.102 (Arduino 2) DST=172.22.0.99 LEN=40 TOS=0x00 PREC=0x00 TTL=255 ID=72 PROTO=TCP SPT=52001 DPT=8080 WINDOW=1875 RES=0x00 ACK FIN URGP=0 • Feb 18 15:14:15 shep kernel: [1637627.961831] IPTables-Accepted-O: IN= OUT=br0 SRC=172.22.0.99 DST=172.22.0.102 (Arduino 2) LEN=40 TOS=0x00 PREC=0x00 TTL=64 ID=11122 DF PROTO=TCP SPT=8080 DPT=52001 WINDOW=29200 RES=0x00 ACK FIN URGP=0 • Feb 18 15:14:25 shep kernel: [1637638.193698] IPTables-Accepted-I: IN=wlan0 OUT= MAC=b8:27:eb:4f:43:f6:5c:cf:7f:3c:59:86:08:00 SRC=172.24.1.106 (Arduino 3) DST=172.22.0.99 LEN=81 TOS=0x00 PREC=0x00 TTL=255 ID=16314 PROTO=TCP SPT=49154 DPT=1883 WINDOW=1884 RES=0x00 ACK PSH URGP=0 • Feb 18 15:14:25 shep kernel: [1637638.194012] IPTables-Accepted-O: IN= OUT=lo SRC=172.22.0.99 DST=172.22.0.99 LEN=93 TOS=0x00 PREC=0x00 TTL=64 ID=3867 DF PROTO=TCP SPT=1883 DPT=50392 WINDOW=6231 RES=0x00 ACK PSH URGP=0 • Feb 18 15:14:35 shep kernel: [1637648.508430] IPTables-Accepted-I: IN=wlan0 OUT= MAC=b8:27:eb:4f:43:f6:60:14:b3:74:61:cf:08:00 SRC=172.24.1.42 (laptop) DST=172.22.0.99 LEN=104 TOS=0x00 PREC=0x00 TTL=128 ID=27282 DF PROTO=TCP SPT=52149 DPT=22 WINDOW=64 RES=0x00 ACK PSH URGP=0 • Feb 18 15:14:35 shep kernel: [1637648.508521] IPTables-Accepted-O: IN= OUT=wlan0 SRC=172.22.0.99 DST=172.24.1.42 (laptop) LEN=40 TOS=0x10 PREC=0x00 TTL=64 ID=31818 DF PROTO=TCP SPT=22 DPT=52149 WINDOW=269 RES=0x00 ACK URGP=0 • Feb 18 15:14:48 shep kernel: [1637661.183931] IPTables-Accepted-I: IN=wlan0 OUT= MAC=b8:27:eb:4f:43:f6:60:14:b3:74:61:cf:08:00 SRC=172.24.1.42 (laptop) DST=172.22.0.99 LEN=120 TOS=0x00 PREC=0x00 TTL=128 ID=27329 DF PROTO=TCP SPT=52149 DPT=22 WINDOW=68 RES=0x00 ACK PSH URGP=0 • Feb 18 15:14:48 shep kernel: [1637661.187210] IPTables-Accepted-O: IN= OUT=wlan0 SRC=172.22.0.99 DST=172.24.1.42 LEN=1500 TOS=0x10 PREC=0x00 TTL=64 ID=31852 DF PROTO=TCP SPT=22 DPT=52149 WINDOW=269 RES=0x00 ACK URGP=0 • Feb 18 15:14:58 shep kernel: [1637671.438928] IPTables-Accepted-I: IN=br0 OUT= MAC=82:85:54:54:e1:8c:18:fe:34:d2:96:51:08:00 SRC=172.22.0.100 (Arduino 4) DST=172.22.0.99 LEN=150 TOS=0x00 PREC=0x00 TTL=255 ID=1463 PROTO=TCP SPT=52080 DPT=8080 WINDOW=1680 RES=0x00 ACK PSH URGP=0 • Feb 18 15:14:58 shep kernel: [1637671.440119] IPTables-Accepted-O: IN= OUT=br0 SRC=172.22.0.99 DST=172.22.0.100 (Arduino 4) LEN=520 TOS=0x00 PREC=0x00 TTL=64 ID=60505 DF PROTO=TCP SPT=8080 DPT=52080 WINDOW=29200 RES=0x00 ACK PSH URGP=0 Edit 1 (but see Edit 2). The Web Service is 'domoticz': $ sudo netstat -taupen | grep LISTEN tcp 0 0 0.0.0.0:139 0.0.0.0:* LISTEN 0 15295 1847/smbd tcp 0 0 0.0.0.0:5901 0.0.0.0:* LISTEN 1000 11927 1437/Xtightvnc tcp 0 0 0.0.0.0:6001 0.0.0.0:* LISTEN 1000 11924 1437/Xtightvnc tcp 0 0 0.0.0.0:53 0.0.0.0:* LISTEN 0 14462 1154/dnsmasq tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 0 14453 1143/sshd tcp 0 0 0.0.0.0:1880 0.0.0.0:* LISTEN 1000 15768 716/node-red tcp 0 0 0.0.0.0:1883 0.0.0.0:* LISTEN 0 11708 903/mosquitto tcp 0 0 0.0.0.0:445 0.0.0.0:* LISTEN 0 15294 1847/smbd tcp6 0 0 :::139 :::* LISTEN 0 15293 1847/smbd tcp6 0 0 :::8080 :::* LISTEN 1000 4902627 25249/domoticz tcp6 0 0 :::53 :::* LISTEN 0 14464 1154/dnsmasq tcp6 0 0 :::22 :::* LISTEN 0 14455 1143/sshd tcp6 0 0 :::1883 :::* LISTEN 0 11709 903/mosquitto tcp6 0 0 :::445 :::* LISTEN 0 15292 1847/smbd tcp6 0 0 :::6144 :::* LISTEN 1000 4902635 25249/domoticz $ netstat -ntl Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 0.0.0.0:139 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:5901 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:6001 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:53 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:1880 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:1883 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:445 0.0.0.0:* LISTEN tcp6 0 0 :::139 :::* LISTEN tcp6 0 0 :::8080 :::* LISTEN tcp6 0 0 :::53 :::* LISTEN tcp6 0 0 :::22 :::* LISTEN tcp6 0 0 :::1883 :::* LISTEN tcp6 0 0 :::445 :::* LISTEN tcp6 0 0 :::6144 :::* LISTEN Edit 2: Following a configuration change, the Domoticz Web Server is now listening on 0.0.0.0:8080, but still fails as above. $ sudo netstat -taupen | grep domoticz tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 1000 21943078 27425/domoticz <<--- tcp 0 0 172.22.0.99:8080 172.22.0.102:52060 ESTABLISHED 1000 21949101 27425/domoticz tcp 0 0 172.22.0.99:8080 172.22.0.100:52135 ESTABLISHED 1000 21949100 27425/domoticz tcp 0 0 172.22.0.99:58528 172.22.0.99:1883 ESTABLISHED 1000 21946463 27425/domoticz tcp6 0 0 :::6144 :::* LISTEN 1000 21943086 27425/domoticz
Problem solved! I was only doing the following single flush command: sudo iptables -F Hence specifically I wasn't flushing all of the iptables rules, eg. the NAT. So I had this mess of PREROUTING & POSTROUTING duplicates: $ sudo iptables -t nat -L Chain PREROUTING (policy ACCEPT) target prot opt source destination DNAT tcp -- anywhere anywhere tcp dpt:http-alt to:192.168.0.99:8080 DNAT tcp -- anywhere anywhere tcp dpt:http-alt to:192.168.0.99:8080 DNAT tcp -- anywhere anywhere tcp dpt:http-alt to:192.168.0.99:8080 DNAT tcp -- anywhere anywhere tcp dpt:http-alt to:192.168.0.99:8080 DNAT tcp -- anywhere anywhere tcp dpt:http-alt to:192.168.0.99:8080 DNAT tcp -- anywhere anywhere tcp dpt:http-alt to:192.168.0.99:8080 DNAT tcp -- anywhere anywhere tcp dpt:http-alt to:192.168.0.99:8080 DNAT tcp -- anywhere anywhere tcp dpt:http-alt to:172.22.0.99:8080 DNAT tcp -- anywhere anywhere tcp dpt:http-alt to:172.22.0.99:8080 DNAT tcp -- anywhere anywhere tcp dpt:http-alt to:172.22.0.99:8080 DNAT tcp -- anywhere anywhere tcp dpt:http-alt to:172.22.0.99:8080 DNAT tcp -- anywhere anywhere tcp dpt:http-alt to:172.22.0.99:8080 Chain INPUT (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination Chain POSTROUTING (policy ACCEPT) target prot opt source destination MASQUERADE all -- anywhere anywhere MASQUERADE all -- anywhere anywhere MASQUERADE all -- anywhere anywhere MASQUERADE all -- anywhere anywhere MASQUERADE all -- anywhere anywhere MASQUERADE all -- anywhere anywhere MASQUERADE all -- anywhere anywhere MASQUERADE all -- anywhere anywhere MASQUERADE all -- anywhere anywhere MASQUERADE all -- anywhere anywhere MASQUERADE all -- anywhere anywhere MASQUERADE all -- anywhere anywhere MASQUERADE all -- anywhere anywhere MASQUERADE all -- anywhere anywhere Once I started using the following before creating my rules it worked (no other change): sudo iptables -F sudo iptables -X sudo iptables -t nat -F sudo iptables -t nat -X sudo iptables -t mangle -F sudo iptables -t mangle -X sudo ipset flush sudo ipset destroy sudo ipset list Apparently I should also do: sudo iptables -t raw -F sudo iptables -t raw -X Now I have: $ sudo iptables -t nat -L Chain PREROUTING (policy ACCEPT) target prot opt source destination DNAT tcp -- anywhere anywhere tcp dpt:http-alt to:172.22.0.99:8080 Chain INPUT (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination Chain POSTROUTING (policy ACCEPT) target prot opt source destination MASQUERADE all -- anywhere anywhere So now if I connect to the Pi's Wireless Access Point on 172.24.1.1 (wlan0) and get IP address 172.24.1.x I can access the Domoticz Web Server on the Pi via http://172.24.1.1:8080, which is what I want. It was previously the case that I had to go via a separate router (172.22.0.1), get IP address 172.22.0.x, and access the Pi via eth0: http://172.22.0.99:8080.
Web Server access via second interface
1,466,655,932,000
I am on double NAT (behind 2 routers). I known how to get the public IP by visiting some webpages or use dig command. Yes I known WAN IP usually same as the public IP. I talk about WAN IP #2 that can be a private IP. I tried tracert and pathping commands but didn't work. Maybe we can't known the WAN IP by general way. But I saw one IP camera app can find it. Maybe it's "tinyCam Monitor" on android.
Private LAN clients can known external IP only when the router enabled uPnP I had recheck the android app "tinyCam Monitor". She known the external IP when router is enabled uPnP feature. So I check around internet and found MiniUPnP (http://miniupnp.free.fr/) command that can show the external IP via UPnP/IGD. I don't know much about UPnP/IGD. Old routers notes UPnP implementations are potentially subject to security breaches. Badly implemented or configured UPnP IGDs are vulnerable. Security researcher HD Moore did a good work to reveal vulnerabilities in existing implementations : Security Flaws in Universal Plug and Play (PDF). A common problem is to let SSDP or HTTP/SOAP ports open to the internet : they should be only reachable from the LAN.
How to get WAN IP of a router on double NAT (not a public IP)?
1,466,655,932,000
So for at least two months I had an IP tables configuration that was working on a compute cluster to provide internet access to compute nodes that were technically offline, via the headnode. We recently had to reboot the headnode which I'm almost entirely certain flushed out whatever setting was making it work. I was able to fetch a backup of /sysconfig/iptables and was wondering why iptables-restore using this file wasn't working... Here are the contents of that backup... # Generated by iptables-save v1.4.21 on Wed May 9 09:36:22 2018 *filter :INPUT ACCEPT [1:36] :FORWARD DROP [0:0] :OUTPUT ACCEPT [1294:196435] -A INPUT -p tcp -m tcp --sport 1024:65535 --dport 372 -j REJECT --reject-with icmp-port-unreachable -A INPUT -p udp -m udp --sport 1024:65535 --dport 372 -j REJECT --reject-with icmp-port-unreachable -A INPUT -i lo -j ACCEPT -A INPUT -i enp7s0f1 -j ACCEPT -A INPUT -i enp7s0f0 -p tcp -m tcp --dport 22 -m state --state NEW -j ACCEPT -A INPUT -i enp7s0f0 -m state --state RELATED,ESTABLISHED -j ACCEPT -A INPUT -s 10.103.182.0/24 -i enp7s0f0 -p tcp -m tcp --dport 443 -m state --state NEW -j ACCEPT -A INPUT -s 10.103.182.0/24 -i enp7s0f0 -p tcp -m tcp --dport 80 -m state --state NEW -j ACCEPT -A INPUT -i enp7s0f0 -p tcp -m tcp --dport 443 -m state --state NEW,ESTABLISHED -j ACCEPT -A INPUT -p udp -m udp --dport 8649 -j REJECT --reject-with icmp-port-unreachable -A INPUT -p tcp -m tcp --dport 40000 -j REJECT --reject-with icmp-port-unreachable -A INPUT -i enp7s0f0 -p tcp -m tcp --dport 0:1023 -j REJECT --reject-with icmp-port-unreachable -A INPUT -i enp7s0f0 -p udp -m udp --dport 0:1023 -j REJECT --reject-with icmp-port-unreachable -A FORWARD -i enp7s0f0 -o enp7s0f1 -m state --state RELATED,ESTABLISHED -j ACCEPT -A FORWARD -i enp7s0f1 -j ACCEPT COMMIT # Completed on Wed May 9 09:36:22 2018 # Generated by iptables-save v1.4.21 on Wed May 9 09:36:22 2018 *nat :PREROUTING ACCEPT [19:1852] :INPUT ACCEPT [11:1496] :OUTPUT ACCEPT [18:1302] :POSTROUTING ACCEPT [16:1110] -A POSTROUTING -o enp7s0f0 -j MASQUERADE COMMIT # Completed on Wed May 9 09:36:22 2018 Any kind of help is greatly appreciated. Note: enp7s0f0 is external, public interface and enp7s0f1 is internal private interface.
Your iptables configuration looks sane, but have you checked the master switch of IPv4 forwarding? Try this command: # sysctl net.ipv4.ip_forward net.ipv4.ip_forward = 1 If it says net.ipv4_ip_forward = 0 instead, then IPv4 forwarding has not been enabled. That's easy to fix: # echo "net.ipv4.ip_forward = 1" >>/etc/sysctl.conf # sysctl -p This will enable IPv4 forwarding in a persistent manner. (Previously, IPv4 forwarding may have been enabled by something like echo 1 > /proc/sys/net/ipv4/ip_forward, which won't persist over a reboot.)
NAT/Masquerade. Was working before, now is not
1,466,655,932,000
I have openvpn client running in my centos box which I use as a router for my internal network. I have two interfaces for reach outside world. eth0 - normal internet tun0 - openvpn tunnel I disable the opevpn auto route pulling by putting "route-noexec " option and I handle all the routes manually now. after I up the openvpn tunnel my routing table is like this. Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.80.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1 10.8.0.0 0.0.0.0 255.255.255.0 U 0 0 0 tun0 192.168.44.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 192.168.11.0 0.0.0.0 255.255.255.0 U 0 0 0 dummy0 169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0 169.254.0.0 0.0.0.0 255.255.0.0 U 1003 0 0 eth1 0.0.0.0 192.168.44.1 0.0.0.0 UG 0 0 0 eth0 Now I have internal host who connected to interface 192.168.80.0 on my centos box 192.168.80.50 I need to route all traffic from this user through interface tun0 and all other traffic through eth0 I tried adding POSTROUTING rules like this iptables -t nat -A POSTROUTING -s 192.168.80.50 -o tun0 -j MASQUERADE iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE but all the clients go through only eth0 including 192.168.80.50. how can I achieve this ?
Based from this answer on SuperUser: create a routing table for some IPs: ip rule add from <sourceIP>/<mask> table <name> Then declare a new route to match the routing table <name>: ip route add default via <router> dev tun0 table <name> it would be easier to have a subnet for people needing to use the VPN because with this configuration you need to specify all the IP in the table <name>
Route certain client through Openvpn tunnel
1,493,369,676,000
I'm attempting to setup a nat router for a lab to simulate a private network connected to a WAN. I have three virtual machines: public ip 192.168.0.5/24 private ip 172.16.0.5/24 router 192.168.0.1/24 (eth0), 172.16.0.1/24 (eth1) I started by configuring each system's networking and confirmed I could ping from private->router and back and public->router and back. Then I set net.ipv4.ip_forward to 1 using sysctl.conf, and applied the changes. At this point I was unable to ping private to public and public to private. Flushing router's iptables rules fixed the problem. iptables -F iptables -t net -F iptables -t mangle -F iptables -X iptables -t nat -X iptables -t mangle-X Then following the guide for CENTOS6/RHEL6 I issued these iptables commands to setup forwarding iptables -A FORWARD -i eth1 -j ACCEPT iptables -A FORWARD -o eth1 -j ACCEPT iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE The confusion begins. I am able to ping from private to public, using a tcp dump I can confirm the IP address is masquerading correctly. However I am also able to ping from public to private. Here is a dump of linux router's /etc/sysconfig/iptables file *mangle :PREROUTING ACCEPT [0:0] :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] :POSTROUTING ACCEPT [0:0] COMMIT *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] -A FORWARD -i eth1 -j ACCEPT -A FORWARD -o eth1 -j ACCEPT COMMIT *nat :PREROUTING ACCEPT [0:0] :POSTROUTING ACCEPT [0:0] :OUTPUT ACCEPT [0:0] -A POSTROUTING -o eth0 -j MASQUERADE COMMIT I've played around with adding rejects, input state related/established. I can't seem to keep the supposedly pubic host from peering into the private network. Any ideas? I'm sure I have something wrong.
I finally figured it out! First, flush iptables like before: iptables -F iptables -t net -F iptables -t mangle -F iptables -X iptables -t nat -X iptables -t mangle -X Setup filter policies iptables -P OUTPUT ACCEPT iptables -P INPUT ACCEPT iptables -P FORWARD DROP Then setup masquerading iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE Then setup a filter to prevent routing to your private interface. This keeps public hosts from using the router as a gateway. Without this I can ping the private interface of the router from public. iptables -A INPUT -i eth1 -j ACCEPT iptables -A INPUT -j DROP Finally, setup forwarding iptables -A FORWARD -i eth1 -j ACCEPT iptables -A FORWARD -i eth0 -o eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT
CentOS 6 iptables nat router
1,493,369,676,000
I have Ethernet on my machine (enp0s10) that connected to real network, and I have lxcbr0 Ethernet bridge which gather lxc containers. And I want to make available one of lxc containers. So I wrote: IFACE=enp0s10 echo "allow inet for lxc" iptables -t nat -A POSTROUTING -o $IFACE -j MASQUERADE iptables -A FORWARD -i $IFACE -o lxcbr0 -m state --state RELATED,ESTABLISHED -j ACCEPT iptables -A FORWARD -i lxcbr0 -o $IFACE -j ACCEPT echo "allow web for lxc" iptables -A PREROUTING -t nat -i $IFACE -p tcp --dport 19980 -j DNAT --to 172.20.0.5:80 iptables -A INPUT -p tcp -m state --state NEW --dport 19980 -i $IFACE -j ACCEPT The first set of rules configure internet inside lxc container, and the second set make possible to connect web server inside lxc container, if I use url "http://machine-ip:19980". All works. But then I want make it more secure and end rules with: iptables -N logdrop iptables -A logdrop -m limit --limit 5/m --limit-burst 10 -j LOG iptables -A logdrop -j DROP iptables -A INPUT -p tcp -m state --state NEW -j logdrop iptables -A INPUT -j logdrop iptables -A FORWARD -j logdrop So I log and drop all that I not allow in explicit way. After that I got in logs: IN=enp0s10 OUT=lxcbr0 MAC=xxx SRC=192.168.1.1 DST=172.20.0.5 LEN=60 TOS=0x00 PREC=0x00 TTL=62 ID=57331 DF PROTO=TCP SPT=58432 DPT=80 WINDOW=29200 RES=0x00 SYN URGP=0 So I not allow something and packet stop on the way from enp0s10 to lxcbr0, but what exactly I missed and what need to fix?
Found here: https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/4/html/Security_Guide/s1-firewall-ipt-fwd.html If you have a default policy of DROP in your FORWARD chain, you must append a rule to allow forwarding of incoming HTTP requests so that destination NAT routing can be possible. To do this, run the following command: iptables -A FORWARD -i eth0 -p tcp --dport 80 -d 172.31.0.23 -j ACCEPT
lxc container <-> external internet, what I missed?
1,493,369,676,000
I've got a few client servers that I connect to with different VPN clients (e.g. Cisco, OpenVPN, etc). I'm trying to set up an Ubuntu 14 VM (with VPN client permanently connected) for each server to route all traffic to and from the server, so I don't need to keep switching between various VPN clients. The VM has eth0 with two static IPs (bridged to LAN), and I'd like to route all traffic directed to the static ip 10.1.1.200 through tun0 to the remote server 10.50.1.1. I've set up the following iptables rules: iptables -t nat -A POSTROUTING -s 10.1.1.200 -j SNAT --to-source 10.50.1.1 iptables -t nat -A PREROUTING -d 10.50.1.1 -j DNAT --to-destination 10.1.1.200 iptables -A FORWARD -s 10.50.1.1 -j ACCEPT iptables -A FORWARD -d 10.1.1.200 -j ACCEPT My understanding of this is that it creates a 1:1 NAT between the LAN IP (10.1.1.200) and the remote server's IP (via the OpenVPN connection) (10.50.1.1). I've enabled net.ipv4.ip_forward = 1, and I can connect to the host server from the VM fine. I've tried pinging, telnetting, and sshing from the host machine to 10.1.1.200, but I get connection refused. I've tried a few different permutations of source/destination IPs (and explicitly setting interfaces with -i and -o), but nothing works. :( Any ideas?
Fixed it! Ended up using the following, mapping the entire LAN IP range to the destination server IP range, for clients with multiple servers in the same subnet. Using masquerade so that the packet gets back to the right LAN IP. iptables -v -t nat -A PREROUTING -i eth0 -d 192.168.2.0/24 -j NETMAP --to 10.50.1.0/24 iptables -v -t nat -A POSTROUTING -o tun0 -j MASQUERADE
1:1 NAT through VM VPN
1,493,369,676,000
I have a adsl connection with static IP (lets say 1.1.1.1). My debian firewall connects Internet with ppp and IP is assigned to firewall directly; ppp0 Link encap:Point-to-Point Protocol inet addr:1.1.1.1 P-t-P:<IP-DOES-NOT-MATTER> Mask:255.255.255.255 I am using debian as a firewall/router and NAT my local clients to Internet using a basic iptables script; iptables --table nat --append POSTROUTING --out-interface ppp0 -j MASQUERADE iptables --append FORWARD --in-interface eth1 -j ACCEPT echo 1 > /proc/sys/net/ipv4/ip_forward I created a subdomain record for my external hosted domain: sub.example.com IN A 1.1.1.1 I can DNAT http connections from Internet to my local server with iptables: iptables --table nat --append PREROUTING -i ppp0 --dest 1.1.1.1 -p tcp --dport 80 -j DNAT --to 192.168.1.101:80 I also want my local clients to reach sub.example.com without any additional configuration. The iptables commands i tried in firewall (that did not work): iptables --table nat --append PREROUTING --in-interface eth1 --dest 1.1.1.1 -p tcp --dport 80 -j DNAT --to-destination 192.168.1.101:80 and iptables -t nat --append OUTPUT --dest 1.1.1.1 -p tcp --dport 80 -j DNAT --to-dest 192.168.1.101 First command routed packects to server but i did not get a reply (1.1.1.1 not configured on server). Second one did nothing. Is there a way to accomplish this with iptables ?
After @wurtel's answer i used DNAT and SNAT together and it worked. Thanks for it :) The commands are: iptables --table nat --append PREROUTING --in-interface eth1 --dest 1.1.1.1 -p tcp --dport 80 -j DNAT --to-destination 192.168.1.101:80 iptables --table nat --append POSTROUTING --out-interface eth1 -source 192.168.1.0/24 --dest 192.168.1.101 -p tcp --dport 80 -j SNAT --to-source 192.168.1.1
NAT External IP to local server using iptables
1,493,369,676,000
So i want to create a nat rule for an openVPN server. After getting trouble with the TAP/TUN Devices, it's finally working i think. Now i have to make a nat rule like so : >iptables -t nat -A POSTROUTING -s 172.16.0.0/24 -o venet0:1 -j MASQUERADE iptables v1.4.14: can't initialize iptables table `nat': Table does not exist (do you need to insmod?) Perhaps iptables or your kernel needs to be upgraded. But it doesn't work. I searched a lot and found another command iptables -t nat -A PREROUTING -i tun0 -j DNAT --to-destination 5.135.###.### This command does the same result as the previous one. Don't know what to do. I ask the host to enable nat but he tell me that i have to do it on my own.
iptables MASQUERADE is roughly the same as source nat (SNAT), as the source IP address is translated or masqueraded. iptables -t nat -A POSTROUTING -s 172.16.0.0/24 -o venet0:1 -j SNAT --to-source 1.2.3.4 1.2.3.4 is your outgoing IP address - I guess 5.135.###.### in your case.
iptables NAT on Debian openvz
1,493,369,676,000
I'm just in the process of setting up my Linux (Debian-based) router with a PPPoE connection via an ADSL/PPPoA -> PPPoE bridge. The connection works perfectly on the router itself but a traceroute through the NAT for some reason takes a long time to get the result of the first hop (to the NAT). The majority of the time the result of the hop will just be * * * but sometimes the hop does show up and there's a long delay before it tries the second hop. Here's when it doesn't show the hop at all: CallumsMacBookAir:~ Callum$ traceroute google.co.uk traceroute: Warning: google.co.uk has multiple addresses; using 173.194.41.95 traceroute to google.co.uk (173.194.41.95), 64 hops max, 52 byte packets 1 * * * //LONG DELAY 2 lo0-central10.ptn-ag03.plus.net (195.166.128.192) 22.578 ms 19.925 ms 20.990 ms 3 link-a-central10.ptn-gw01.plus.net (212.159.2.136) 19.574 ms 19.786 ms 19.343 ms 4 xe-5-3-0.ptw-cr01.plus.net (212.159.0.108) 19.540 ms 18.947 ms 25.387 ms 5 72.14.222.97 (72.14.222.97) 19.911 ms 19.706 ms 19.512 ms 6 209.85.246.244 (209.85.246.244) 19.423 ms 19.455 ms 19.655 ms 7 72.14.238.51 (72.14.238.51) 20.234 ms 24.666 ms 20.076 ms 8 lhr08s01-in-f31.1e100.net (173.194.41.95) 19.168 ms 19.518 ms 19.659 ms Sometimes it does respond in the first hop but there's still an asterisk: CallumsMacBookAir:~ Callum$ traceroute google.co.uk traceroute: Warning: google.co.uk has multiple addresses; using 173.194.41.95 traceroute to google.co.uk (173.194.41.95), 64 hops max, 52 byte packets 1 192.168.0.253 (192.168.0.253) 0.770 ms * 0.800 ms //LONG DELAY IN HERE 2 lo0-central10.ptn-ag03.plus.net (195.166.128.192) 20.301 ms 22.958 ms 32.719 ms 3 link-a-central10.ptn-gw01.plus.net (212.159.2.136) 19.142 ms 19.417 ms 18.527 ms 4 xe-5-3-0.ptw-cr01.plus.net (212.159.0.108) 19.047 ms 18.781 ms 18.887 ms 5 72.14.222.97 (72.14.222.97) 19.181 ms 19.424 ms 29.965 ms 6 209.85.246.244 (209.85.246.244) 33.559 ms 19.756 ms 25.363 ms 7 72.14.238.51 (72.14.238.51) 32.010 ms 19.753 ms 19.042 ms 8 lhr08s01-in-f31.1e100.net (173.194.41.95) 19.618 ms 19.730 ms * Is there any way to make the iptables router respond to the traceroute properly? Thanks!
Answer turned out to be the router had 2 virtual interfaces on one physical interface. Problem was solved by getting iptables to use only the virtual interface eth0:0 for the routing.
iptables - masqueraded NAT has delayed first hop in traceroute
1,493,369,676,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 chain. But in my setup, the INTERNET chain is executed first. table ip nat { chain INTERNET { type nat hook postrouting priority srcnat + 1; policy accept; oifname br2 masquerade } } table ip vpn { chain VPN-POSTROUTING { type nat hook postrouting priority srcnat - 1; policy accept; oifname br2 ip saddr 10.0.0.0/24 ip daddr 192.168.0.0/24 accept } } where is my mistake? Edit: I changed the rules and add all chains to the same table, with the same result. In the next step, I followed A.B.'s advice and add counters and logs to the rules. The order of the chains corresponds to the priority, but the accept rule for the VPN is not triggered. When I add the VPN accept rule to the INTERNET chain, right before the masquerade rule, it works like expected.
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, terminating a chain will just continue to the next chain. So if the first chain doesn't do anything (by accept-ing), the next chain gets its chance to do it instead, which is not what is intended. To solve this, the first chain (or any other chain) can leave a message passed to each next chain so it can act upon it: set a mark (an arbitrary value) for the next chain to change its behavior. Instead of accept which has zero effect (leaving the chain VPN-POSTROUTING empty also executes the default policy: accept), set a mark. So replace the rule in VPN-POSTROUTING with this one instead: nft add rule ip vpn VPN-POSTROUTING oifname br2 ip saddr 10.0.0.0/24 ip daddr 192.168.0.0/24 mark set 0xdeaf When this mark is set, it can then be used on the other chain to change behavior by not executing remaining rules. Insert this rule first in ip nat INTERNET: nft insert rule ip nat INTERNET mark 0xdeaf accept
nftables table and chain priority
1,493,369,676,000
I have a simple media player computer running Debian 10. It is located in a museum, where it continually plays a video file for an art installation (using mpv). The computer is connected to the museum's WiFi network. Sometimes, the museum emails me a new video file to play. I then proceed to copy the video file to a USB flash drive, travel to the museum, attach a keyboard to the computer, and copy over the file. When I'm at home I would like to upload a file to the computer in the museum. I can't use scp because while the computer is connected to the internet, it has no public hostname/ip address. How can I do this?
If I read the question, including the title properly, you are asking how connect from the museum computer to your computer so you can copy a video up. This is known as "reverse ssh tunneling", and basically what you do is on the museum computer you run a ssh -R command that causes a tunnel to get set up from inside their firewall to your computer. Then you ssh/scp from your computer to the port that is established by the tunneling command. Yeah, it can get confusing the first 100 or so times you do it. Some literature: https://www.howtogeek.com/428413/what-is-reverse-ssh-tunneling-and-how-to-use-it/ https://www.howtoforge.com/reverse-ssh-tunneling The problem is that you either have to: Leave the tunnel up all the time (meaning have some sort of script that restarts it) Have some mechanism of triggering the creation of the tunnel. Have the tunnel on a "timer" (say connects every day at 8 PM. An example of Number 2 would be to have the tunnel created whenever someone sticks a USB device into the machine. Then instead of emailing you the video, the museum staff would simply stick it on a USB drive themselves and insert the drive in the computer. You would then have some way of triggering a script that would create the tunnel (bonus points for random ports on the tunnel, communicated to you by the video machine sending an email (more bonus points for encrypting that email) to you that it's ready). Another solution, channeling the ghost of Reuben Garrett Lucius Goldberg. Set up an incoming mail server on the video machine. Have the museum staff send the email to "[email protected]" Have a script strip off the video from the email and de-encode it back to it's original format. Move the previous video to a backup file. Put the new video in place. Send email to have the museum staff verify that a "good" video is playing.
What's an easy way to get a reverse shell?
1,493,369,676,000
I have an Ubuntu 18.04 server with one public network interface (eth0). I'm trying to create additional "virtual" network interfaces that will also be able to access the internet with NAT rules set up. I've created a virtual interface using the following commands: ip link add type veth ifconfig veth0 192.168.1.1 Below is the output of my ifconfig: eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 10.0.0.1 netmask 255.255.255.0 broadcast 10.0.0.255 ether f2:3c:92:1f:2a:62 txqueuelen 1000 (Ethernet) RX packets 85664 bytes 111561237 (111.5 MB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 15392 bytes 2229468 (2.2 MB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 loop txqueuelen 1000 (Local Loopback) RX packets 1385 bytes 213213 (213.2 KB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 1385 bytes 213213 (213.2 KB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 veth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.1.1 netmask 255.255.255.0 broadcast 192.168.1.255 ether a6:e7:de:40:9a:28 txqueuelen 1000 (Ethernet) RX packets 27 bytes 2082 (2.0 KB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 1132 bytes 48520 (48.5 KB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 I've set "/proc/sys/net/ipv4/ip_forward" to 1: $ cat /proc/sys/net/ipv4/ip_forward 1 I also tried numerous iptables MASQUERADE, FORWARD, and NAT rules but can't get internet access working from veth0. When I ping 192.168.1.1 from the veth0 interface it all works: $ ping -I veth0 192.168.1.1 PING 192.168.1.1 (192.168.1.1) from 192.168.1.1 veth0: 56(84) bytes of data. 64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.029 ms 64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.046 ms 64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=0.085 ms 64 bytes from 192.168.1.1: icmp_seq=4 ttl=64 time=0.062 ms 64 bytes from 192.168.1.1: icmp_seq=5 ttl=64 time=0.061 ms --- 192.168.1.1 ping statistics --- 5 packets transmitted, 5 received, 0% packet loss, time 4097ms rtt min/avg/max/mdev = 0.029/0.056/0.085/0.020 ms However if I try pinging the eth0 interface IP address from veth0 I get no response: $ ping -I veth0 10.0.0.1 PING 10.0.0.1 (10.0.0.1) from 192.168.1.1 veth0: 56(84) bytes of data. --- 10.0.0.1 ping statistics --- 39 packets transmitted, 0 received, 100% packet loss, time 38900ms Below is the output of my route command: Destination Gateway Genmask Flags Metric Ref Use Iface default gw-li832.linode 0.0.0.0 UG 0 0 0 eth0 xx.xx.xx.xx 0.0.0.0 255.255.255.0 U 0 0 0 eth0 192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 veth0 I can't seem to figure out what I'm doing wrong and any help would be appreciated.
If you want to use a computer as host for virtual machines there you also wants the physical machine and the virtual ones to be reachable in both directions but if you only have one iface ... it is necessary to use a bridge (you create them with brctl or NetworkManager:s nmcli.) Though macvtap for example changes this. The physical computer's os wont see even the ARP requests from the virtual machines (if you don't connect the virtual machines and the host via an virtual bridge) due to the design of the networking stack in Linux. In the last part of this: https://wiki.archlinux.org/index.php/Network_bridge, is the recipe i used to be able to allow the physical host and the virtual machines in the machine to reach each other. One other solution could be hair-pin rules in your router/firewall. In http://man7.org/linux/man-pages/man4/veth.4.html they discusses veth devices, so in their example they treat the veth device as a pipe with two names. You didn't add a peer name in your example.
Ubuntu Server - “Virtual” Network Interface with Internet Access
1,493,369,676,000
I have media box in my network that hard coded to use specific DNS servers like Google DNS. But I want force this device to use my own DNS servers instead of hard coded DNS. Only way I think this is possible to mangle the DNS request coming from that media box IP to DNAT to my DNS server IP. but I'm not quite sure how do I put rule with mentioning source port and source ip at the same time I use openwrt router with openwrt 15.0 chaos calmer on it. iptables -t nat -A PREROUTING -p tcp --sport 53 -j DNAT --to-destination 192.168.1.153 Above query will do the job but it will mangle all the port 53 request. how can I specify this rule with IP address. or is there any other way to do it ?
Just add -d a.b.c.d immediately after tcp, to restrict the rule to packets with destination address a.b.c.d. And add -s e.f.g.h to also restrict by source address.
Mangle rule for intercept DNS traffic form specific IP and redirect to another DNS server - openwrt
1,493,369,676,000
I have a FreeBSD 7.3 server and I configured IPsec on it but now I need to put my server behind a NAT. I know in order to using NAT I should add IPsec_NAT_T to my kernel but the problem is IPsec_NAT_T is not built in and I must add patch to my kernel. How can I do that?
You have already figured out that you need to patch your kernel sources as you have a very old version. Never versions already have the option. And I think that -current (what will become 12) have deprecated the option and supports NAT-T by default. So you need to figure out what kernel source version you have locally and are building from. When you know that then you can look for a patch-set which matches your sources. Earlier versions seems to be here: https://people.freebsd.org/~vanhu/NAT-T/ https://people.freebsd.org/~vanhu/NAT-T/patch-natt-7.2-2009-05-12.diff I found two later versions here (but no directory listing): http://people.freebsd.org/~bz/20110123-01-stable7-natt.diff http://people.freebsd.org/~bz/20110603-02-stable7-natt.diff I would try the latest version first. Make a copy of your sources and use the patch command. If it applies cleanly to your 7.3 sources you should be good to go. When the patches have been applied follow the steps for recompiling your kernel. For your purpose you need to enable these: options IPSEC device crypto options IPSEC_NAT_T You can find the steps in the FreeBSD Handbook If the patch does not apply cleanly then look for other patchsets. The patches are fairly simple so it might be easier to add them manually. If you do not know how to do this - then you are much much better off upgrading your system. The pain of upgrading will be far lesser than learning how to program C to adapt the code :-)
using IPsec behind NAT in freebsd 7.3
1,493,369,676,000
I'm doing some troubleshooting in our network and VPNs and I want to monitor the traffic and I want to see if the SNAT and DNAT is working fine. I want something live like tcpdump that I can see something like: 192.168.25.40 <----> 172.16.30.245 icmp echo-request 194.30.25.10 194.30.25.10 icmp echo-reply 172.26.30.245 <----> 192.168.25.40 Is it possible to do it with tcpdump, or iptraf or iftop ? Or is there any other tool I could use to see the NAT in real time ? Thanks
I don't know what you are doing wrong, but here's an example. Setup: Two network namespaces ns0 and ns1 with two veth pairs, main namespace forwards: ns0 <------- main -------> ns1 veth0b --- veth0a veth1a --- veth1b 10.0.0.1 10.0.0.254 10.0.1.254 10.0.1.1 Doing plain tcpdump on veth0a and veth1a. Pinging ns0 from ns1 without NAT shows: IP 10.0.1.1 > 10.0.0.1: ICMP echo request, id 20765, seq 1, length 64 IP 10.0.0.1 > 10.0.1.1: ICMP echo reply, id 20765, seq 1, length 64 on veth0a, and on veth1a: IP 10.0.1.1 > 10.0.0.1: ICMP echo request, id 20765, seq 1, length 64 IP 10.0.0.1 > 10.0.1.1: ICMP echo reply, id 20765, seq 1, length 64 After enableing SNAT on veth0a with iptables -t nat -A POSTROUTING -o veth0a -s 10.0.1.1/32 -j SNAT --to 10.0.1.90 now on veth0a there is IP 10.0.1.90 > 10.0.0.1: ICMP echo request, id 20795, seq 1, length 64 IP 10.0.0.1 > 10.0.1.90: ICMP echo reply, id 20795, seq 1, length 64 while on veth1a IP 10.0.1.1 > 10.0.0.1: ICMP echo request, id 20795, seq 1, length 64 IP 10.0.0.1 > 10.0.1.1: ICMP echo reply, id 20795, seq 1, length 64 So one can clearly see the SNAT is working. As I said, you need to dump packets on both the outgoing and the incoming interface.
How to check NAT live?
1,493,369,676,000
As you know, at least 3 types of NAT are used. Of course i need to two types of them.DNAT and SNAT. DNAT : hiding server behind NAT, SNAT : hiding your client behind NAT. Question: I read a quick tutorial of PF filrewall, but didn't distinguish DNAT and SNAT in PF Firewall. How can i define ruleset as DNAT and SNAT?
I've been using NAT for a long time and this the first time I've seen the terms DNAT and SNAT. I had to go look at Wikipedia. To help you, pay attention to Wikipedia when it says "This use of DNAT is also called port forwarding". I've only ever heard it called port forwarding. The keyword you'll want on your rules is "rdr-to". Wikipedia points out that SNAT is used to mean many different things. With what you said, I'm assuming you are using SNAT in the sense of Source NAT. What you are referring to as SNAT is what PF means when it uses the rule modifier "nat-to". I don't know which tutorial you might have used, but the definitive one is at http://home.nuug.no/~peter/pf/ by Peter Hansteen. He also recently released the "Book of PF", which I own and is quite good. PF can be confusing if you are coming from Cisco (or other) nomenclature. I know this because I got rather confused when going from PF to Cisco while taking a class.
PF and types of NAT(Network Address Translation)
1,493,369,676,000
I am trying to set up hairpinning on my home network following an article and a previous question. My network is below, host B serves a few services, let's settle for SSH port 22) The reason for the hairpinning is typical: I have ssh.example.com defined on an Internet DNS and it points to my public IP (200.200.200.200) on port 2223. This port is redirected to host B (192.168.10.2:22) via iptables -t nat -A PREROUTING -i nicWan -p tcp --dport 2223 -j DNAT --to-destination 192.168.10.2:22 I want to be able to reach 192.168.10.2:22 from host A via ssh 200.200.200.200 -p 2223 Despite administrating Linux machines since 1994, I have never really looked closely at iptables because I was using shorewall and the briefly firehol. My initial problem is with understanding whether hairpinning is applicable to the whole traffic "from the LAN", or do I need a rule per destination port (the references I mentioned and several others diverge, I would prefer the former). The main issue comes from my lack of understanding of where in the iptables context (chains) I need to set what. I understand the reasons for the operation (very well described in the first reference), it is just that I do not know where to put it. Specifically, how can I say in iptables language to NAT the packets from any device on 192.168.10.0/24 that want to go to 200.200.200.200, and MASQUERADE them so that they can come back?
I'd say that your interface is wrong because your traffic from host A hits your nicLan, not nicWan. And as you said you need to masquerade so your return packages finds their way to right place. The second rule masquerades all traffic coming from your local subnet and going back to your local server. iptables -t nat -A PREROUTING -i nicLan --destination 200.200.200.200/32 --jump DNAT --to-destination 192.168.10.2 iptables -t nat -A POSTROUTING -o nicLan --source 192.168.10.0/24 --destination 192.168.10.2/32 --jump MASQUERADE As you see, I didn't define any ports, so all traffic going to your public address from your LAN is DNATted to your server in the local LAN. And don't forget to add allowing rules in your filter tables if needed.
How to hairpin a whole network segment?
1,524,839,207,000
For some reason my NAT is only allowing connections on the local network. When I ping the local network, the packets come out with the NAT gateway as the source. When I ping the remote network (Internet host etc.), the packet source is the internal IP address for the device and the responses do not get sent back properly. Any ideas about what could be configured incorrectly? router ~ # iptables -S -P INPUT ACCEPT -P FORWARD ACCEPT -P OUTPUT ACCEPT -A INPUT -i lo -j ACCEPT -A INPUT -i eth2 -j ACCEPT -A INPUT -i eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT -A INPUT -i eth0 -p tcp -m tcp --dport 22 -j ACCEPT -A INPUT -i eth0 -p tcp -m tcp --dport 3306 -j ACCEPT router ~ # iptables -S -t nat -P PREROUTING ACCEPT -P INPUT ACCEPT -P OUTPUT ACCEPT -P POSTROUTING ACCEPT -A POSTROUTING -o eth0 -j MASQUERADE The internal network is 192.168.0.0/16 and the external (NAT local) is 10.72.16.0/22. Updated with information for A.B. router ~ # ip -br link; ip -4 -br addr; ip route; ip rule lo UNKNOWN 00:00:00:00:00:00 <LOOPBACK,UP,LOWER_UP> eth0 UP 00:15:5d:e8:47:39 <BROADCAST,MULTICAST,UP,LOWER_UP> eth1 UP 00:15:5d:e8:47:3a <BROADCAST,MULTICAST,UP,LOWER_UP> eth2 UP 00:15:5d:e8:47:46 <BROADCAST,MULTICAST,UP,LOWER_UP> sit0@NONE DOWN 0.0.0.0 <NOARP> lo UNKNOWN 127.0.0.1/8 eth0 UP 10.72.16.140/22 eth1 UP 10.72.21.14/22 eth2 UP 192.168.0.1/16 default via 10.72.20.1 dev eth1 default via 10.72.16.1 dev eth0 10.72.16.0/22 dev eth0 proto kernel scope link src 10.72.16.140 10.72.20.0/22 dev eth1 proto kernel scope link src 10.72.21.14 192.168.0.0/16 dev eth2 proto kernel scope link src 192.168.0.1 0: from all lookup local 32766: from all lookup main 32767: from all lookup default And the same from an internal host: int_host ~ # ip -br link; ip -4 -br addr; ip route; ip rule lo UNKNOWN 00:00:00:00:00:00 <LOOPBACK,UP,LOWER_UP> eth0 UP 52:69:6e:00:81:95 <BROADCAST,MULTICAST,UP,LOWER_UP> usb0 DOWN 52:69:6e:00:00:00 <NO- CARRIER,BROADCAST,MULTICAST,UP> lo UNKNOWN 127.0.0.1/8 eth0 UP 192.168.0.5/16 usb0 DOWN 192.168.127.5/24 169.254.0.1/16 default via 192.168.0.1 dev eth0 169.254.0.0/16 dev usb0 proto kernel scope link src 169.254.0.1 linkdown 192.168.0.0/16 dev eth0 proto kernel scope link src 192.168.0.5 192.168.127.0/24 dev usb0 proto kernel scope link src 192.168.127.5 linkdown RTNETLINK answers: Address family not supported by protocol Dump terminated Pinging from the internal host to an external (local) host: int_host ~ # ping 10.72.16.50 PING 10.72.16.50 (10.72.16.50) 56(84) bytes of data. 64 bytes from 10.72.16.50: icmp_seq=1 ttl=127 time=1.37 ms ^C Pinging from the internal host to an external (external) host: int_host ~ # ping 172.18.221.227 PING 172.18.221.227 (172.18.221.227) 56(84) bytes of data. ^C --- 172.18.221.227 ping statistics --- 8 packets transmitted, 0 received, 100% packet loss, time 7243ms Wireshark shows that the ping came with the source being the internal IP address of the internal host: 4842 60.182197 192.168.0.5 172.18.221.227 ICMP 98 Echo (ping) request id=0x567d, seq=7/1792, ttl=62 (reply in 4843) 4843 60.182365 172.18.221.227 192.168.0.5 ICMP 98 Echo (ping) reply id=0x567d, seq=7/1792, ttl=128 (request in 4842) As expected the response never gets sent back because it goes to the non-existent 192.168.0.5 host instead of the router at 10.72.16.140 (and then to the internal 192.168.0.5 address).
The routes are applied in order. So the default route (as well as the example given to 172.18.221.227) is going through eth1 because it's first in the routing table. The only MASQUERADE rule is applied to packets going through eth0. As OP commented, there's no way an alteration in POSTROUTING could have altered the route. So there's simply no alteration done to packets going throught eth1 which keep the original RFC1918 IP. So changing the rules to also have a MASQUERADE applying to eth1 fixes it. In case the INPUT policy is set (again?) to DROP, replicating the state... ESTABLISHED to also apply from eth1 should also be considered.
Linux NAT is using the internal IP address for remote traffic
1,524,839,207,000
If i use iptables to NAT all HTTP traffic behind another network, does it overwrite user agent of HTTP headers? The rules are as follows: /usr/sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE /usr/sbin/iptables -A FORWARD -i eth0 -p tcp --dport 80 -o tap0 -m state --state RELATED,ESTABLISHED -j ACCEPT /usr/sbin/iptables -A FORWARD -i tap0 -p tcp --dport 80 -o eth0 -j ACCEPT
No it doesn't. Those rules works on TCP and IP level and does not process data in higher level (HTTP) To learn more about how iptables-based NAT works, see here
Dose iptables NAT overwrite user agent of HTTP headers?
1,524,839,207,000
I recently installed a Linux (Mint 17) virtual Machine on a Windows 7 PC. In order to be able to SSH to this virtual machine, I had to define a few rules and redirect ports as explained in other posts of this very forum (see this link for instance). I realized that there is a known bug on virtual box regarding the drop of TCP connections (see this ticket). After updating the natdnshostresolver1 however, I still experience loss of TCP connections after about 10 to 12 minutes. The virtualmachine is still on and can still access the internet but it is impossible to ssh to it. From the virtual machine, I can ssh to any other machine, it is only the "input" ssh that is not working. Does anyone know if this is a known issue with VirtualBox ? I am using version 4.3.20 of the software.
I'm not sure af the exact cause of your woes, but networking virtual machines can be complicated. Your computer is acting as a NAT router for your VM(s), and so it has to manage port forwarding and address translation, among many other things. One way of eliminating these problems can be to use bridged networking instead. Instead of providing address translation, your computer uses a series of tricks to share your network card between the virtual and real machines. Each has its own IP on the network, through one physical connection. VirtualBox, Parallels, and most VMware products (Fusion, Player etc.) have an option to enable bridged networking.
SSH to a virtual machine
1,524,839,207,000
I could enable NAT using UFW with following configuration. *nat :POSTROUTING ACCEPT [0:0] -A POSTROUTING -s 192.168.141.0/24 -o ens192 -j MASQUERADE COMMIT If I want to enable TCPMSS, I have to run the following command manually. iptables -I FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu How can I set this in UFW configuration?
It worked as expected with the following configuration. Add the following line in /etc/ufw/after.rules just before the final COMMIT line. -A ufw-after-forward -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu example: # Don't delete these required lines, otherwise there will be errors *filter :ufw-after-input - [0:0] :ufw-after-output - [0:0] :ufw-after-forward - [0:0] # End required lines # don't log noisy services by default -A ufw-after-input -p udp --dport 137 -j ufw-skip-to-policy-input -A ufw-after-input -p udp --dport 138 -j ufw-skip-to-policy-input -A ufw-after-input -p tcp --dport 139 -j ufw-skip-to-policy-input -A ufw-after-input -p tcp --dport 445 -j ufw-skip-to-policy-input -A ufw-after-input -p udp --dport 67 -j ufw-skip-to-policy-input -A ufw-after-input -p udp --dport 68 -j ufw-skip-to-policy-input # don't log noisy broadcast -A ufw-after-input -m addrtype --dst-type BROADCAST -j ufw-skip-to-policy-input # TCPMSS rule -A ufw-after-forward -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu # don't delete the 'COMMIT' line or these rules won't be processed COMMIT
Enable NAT with TCPMSS using UFW
1,524,839,207,000
On a Linux laptop, I want to give access to locally hosted VM (kvm) from LAN. I'd like to do DNAT to VM. Network client <-- LAN 192.168.3.0/24 --> host <-- bridge 192.168.113.0/24 --> guest Host wlp3s0: 192.168.3.221/24 br0: 192.168.113.1/24 net.ipv4.ip_forward = 1 Bridge: # bridge -d link 16: vnet5: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 master br0 state forwarding priority 32 cost 100 hairpin off guard off root_block off fastleave off learning on flood on mcast_flood on bcast_flood on mcast_router 1 mcast_to_unicast off neigh_suppress off vlan_tunnel off isolated off locked off Routing: default via 192.168.3.1 dev wlp3s0 proto dhcp src 192.168.3.221 metric 600 192.168.3.0/24 dev wlp3s0 proto kernel scope link src 192.168.3.221 metric 600 192.168.113.0/24 dev br0 Netfilter rule extract: table inet filter { chain forward { type filter hook forward priority 0; policy drop; ct state established,related counter accept ct state invalid counter drop tcp dport 8080 counter log prefix "forward: " accept } } table ip nat { chain prerouting { type nat hook prerouting priority dstnat tcp dport 8080 counter log prefix "dnat: " dnat to 193.168.113.201:8080 } chain postrouting { type nat hook postrouting priority srcnat iifname br0 oifname wlp3s0 counter masquerade } } Guest enp1s0: 192.168.113.201/24 Routes: default via 192.168.113.1 dev enp1s0 proto dhcp src 192.168.113.201 metric 100 192.168.113.0/24 dev enp1s0 proto kernel scope link src 192.168.113.201 metric 100 No firewall Service listening on 0.0.0.0:8080 Client address: 192.168.3.2 Tests OK Ping from host to guest (ping -c 1 192.168.113.201) Curl from host to guest service (curl -q http://192.168.113.201:8080) Access to internet from guest (curl -q https://serverfault.com) Issue Calling service from another client on LAN (curl -q http://192.168.3.221:8080) does not reach the guest. Tcpdump on wlp3s0 interface of the host: 11:10:54.063354 IP 192.168.3.2.43278 > 192.168.3.221.8080: Flags [S], seq 2985774913, win 64240, options [mss 1460,sackOK,TS val 525180874 ecr 0,nop,wscale 7], length 0 11:10:54.063388 IP 192.168.3.2.43278 > 193.168.113.201.8080: Flags [S], seq 2985774913, win 64240, options [mss 1460,sackOK,TS val 525180874 ecr 0,nop,wscale 7], length 0 (I see "forward" and "dnat" lines in syslog when forwarding and filtering are triggered.) I see no packet on br0 interface of the host. Please note the second line of tcpdump. Destination is rewritten, but on the wlp3s0 interface! I also tested with wired Ethernet instead of Wifi: exactly same behavior. Why the packet is not routed to bridge through br0? Any hint appreciated!
There is a typo in the prerouting rule. dnat to 193.168.113.201:8080 instead of dnat to 192.168.113.201:8080.
Access VM from LAN
1,524,839,207,000
I am currently Running a Bare Metal Kali with Virtualbox installed on it to the run Kioptrix Level 1. I created a NAT network in preferences with the default recommendations. This did resolve an earlier issue of the Kioptrix showing a failed boot of Eth0. However I am failing to understand and resolve the below: I can ping from the virtual machines network to my real network, but not vice versa running arp-scan -l on the host does not show the virtualbox network ip. Could this be a configuration issues on the host and by default should Linux pick up the NAT network?
With a NAT network this is exactly as it should be. If you want to be able to treat the VMs as grade 1 systems that are directly reachable, they need to be in a bridged network
Virtualbox NAT network not showing in Linux
1,524,839,207,000
On a hypervisor with multiple public IPs on a single network interface, there are two groups of Virtual Machines. Group A members get their public IP routed to them directly via the host interface (via a bridge that sets up the route). [1] Group B members are on a bridge with NAT configuration, so they get private IPs, and their connections get NAT'ed through one specific public IP. Let's call this shared address IPb. [2] For incoming connections on IPb some ports are forwarded to some Group B members. The problem I'm having is that the DNAT (port forwarding) rules are getting applied to incoming packets not only over IPb, but also from any other public IP. How can I restrict the DNAT rule to be specific to packets directed only to IPb? I tried -dst IPb in the PREROUTING rule, but this practically caused the rule to not get triggered at all (port forwarding stopped). [3] Thank you [1] auto eth0 iface eth0 inet static address <eth0-main-ip>/32 gateway <gateway-ip> pointopoint <gateway-ip> #GroupA Bridge: auto vmbr12 iface vmbr12 inet static address <eth0-main-ip>/32 bridge-ports none bridge-stp off bridge-fd 0 up ip route add <Public-IPa>/32 via <eth0-main-ip> dev vmbr12 down ip route del <Public-IPa>/32 via <eth0-main-ip> dev vmbr12 . . . [2] #GroupB Bridge: auto vmbr4 iface vmbr4 inet static address 10.0.0.1/16 bridge-ports none bridge-stp off bridge-fd 0 post-up echo 1 > /proc/sys/net/ipv4/ip_forward post-up iptables -t nat -A POSTROUTING -s '10.0.0.0/16' -o eth0 -j MASQUERADE post-up iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 22 -j DNAT --to 10.0.101.1:22 post-up iptables -A FORWARD -p tcp -d 10.0.101.1 --dport 22 -j ACCEPT post-down iptables -t nat -D POSTROUTING -s '10.0.0.0/16' -o eth0 -j MASQUERADE post-down iptables -D PREROUTING -t nat -i eth0 -p tcp --dport 22 -j DNAT --to 10.0.101.1:22 post-down iptables -D FORWARD -p tcp -d 10.0.101.1 --dport 22 -j ACCEPT . . . [3] #Using IPb in PREROUTING rule <snip> post-up iptables -t nat -A POSTROUTING -s '10.0.0.0/16' -o eth0 -j MASQUERADE post-up iptables -A PREROUTING -t nat -i eth0 -p tcp -dst IPb --dport 22 -j DNAT --to 10.0.101.1:22 post-up iptables -A FORWARD -p tcp -d 10.0.101.1 --dport 22 -j ACCEPT post-down iptables -t nat -D POSTROUTING -s '10.0.0.0/16' -o eth0 -j MASQUERADE post-down iptables -D PREROUTING -t nat -i eth0 -p tcp -dst IPb --dport 22 -j DNAT --to 10.0.101.1:22 post-down iptables -D FORWARD -p tcp -d 10.0.101.1 --dport 22 -j ACCEPT </snip>
I tried -dst IPb in the PREROUTING rule, but this practically caused the rule to not get triggered at all (port forwarding stopped). [3] Turned out this is the correct approach, but: the entry for IPb must include a subnet length. In this case I just used IPb/32 and it worked as it should.
How to restrict DNAT to just one of the public IPs?
1,524,839,207,000
Looking to solve a problem on: Ubuntu 18.04.5 Intel i3 I have two physical ports (enp1s0 & enp2s0), a router connected to enp1s0 and a camera on enp2s0. enp1s0 is 192.168.1.10 Router connected is 192.168.1.1 enp2s0 is 192.168.0.10 Camera is 192.168.0.1 I would like to be able to access the internet from the camera. (for example: ping -I enp2s0 1.1.1.1). |———--| |—--——| enp1s0 enp2s0 |_____| |_____| | | | | |--———| Camera Router |_____| | | Internet I have tried the following rules: Enabling IP forwarding via: #vim /etc/sysctl.conf net.ipv4.ip_forward = 1 #sysctl -p Updating IP tables iptables -A FORWARD -i enp2s0 -o enp1s0 -j ACCEPT iptables -A FORWARD -i enp1s0 -o enp2s0 -j ACCEPT iptables -t nat -A POSTROUTING -o enp1s0 -J MASQUERADE iptables -t nat -A POSTROUTING -o enp2s0 -J MASQUERADE I'm still not able to make the two interfaces talk - looking to ping enp1s0 from enp2s0, then access the internet from enp2s0. They have to be on different subnets. Can anyone help me understand the routing problem here to help these two subnets talk to each other?
I originally added this as an edit - but here it is as an answer: I've used iptables flush to remove any old rules (although I believe this is done on restart anyways) and changed the nat rule from what I originally thought was correct. iptables --flush iptables --table nat --flush iptables --delete-chain iptables --table nat --delete-chain iptables --table nat --append POSTROUTING --out-interface enp1s0 -j MASQUERADE iptables --append FORWARD --in-interface enp2s0 -j ACCEPT
Ubuntu routing problem between two physical ports
1,524,839,207,000
I have one physical interface eth0 on my target, running Linux. The IP address of this interface is 172.16.81.x (public IP). I have to create a virtual interface eth0:1 with IP address 173.1.1.x. I will be running socket server with custom port 49155 using IP address 173.1.1.x. From another PC/target I should not be able to ping 173.1.1.x. However, from another PC I will be running a socket client program. This client should be able to connect to port 49155 on the 172.16.81.x public IP. I have tried NAT, bridge but not successful. with below iptable rules, was able to establish server<-->client communication: echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward sudo iptables -A FORWARD -i ens33 -o 173.1.1.6 -p tcp --syn --dport 49155 -m conntrack --ctstate NEW -j ACCEPT sudo iptables -A FORWARD -i ens33 -o 173.1.1.6 -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT sudo iptables -A FORWARD -i ens33 -o 173.1.1.6 -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT sudo iptables -t nat -A PREROUTING -i ens33 -p tcp --dport 49155 -j DNAT --to-destination 173.1.1.6 sudo iptables -t nat -A POSTROUTING -o ens33 -p tcp --dport 49155 -d 173.1.1.6 -j SNAT --to-source 192.168.233.251 sudo iptables -A INPUT -m tcp -p tcp -s 192.168.233.251 --dport 49155 -j ACCEPT at this point still 173.1.1.6 is pingable from outside PC. however i have to also make 173.1.1.6 invisible for external world for that i add below rules: sudo iptables -A INPUT -d 173.1.1.6 -j DROP sudo iptables -A OUTPUT -s 173.1.1.6 -j DROP sudo iptables -A FORWARD -s 173.1.1.6 -j DROP after this ping is blocked. server <--> client communication also doesnt happen.
While I have no idea what you are actually trying to set up or achieve ultimately, given the the following case: You have two IP addresses configured on the same host (regardless of whether they are configured on the same network interface) You have some server program that binds to one of the addresses You do not want other hosts to be able to reach this host with the address bound by the aforementioned program (regardless of whether they are trying to connect to the program / port). You want other hosts to be able to connect to the aforementioned program with the other address that it is not bound to. Regardless of whether the above makes any sense in any scenario, you can do it with the following iptables rules: (Say it has the IP addresses of 192.168.1.2 and 192.168.2.2, and the server program binds to 192.168.2.2:80, and I want the other hosts to be able to connect to it with 192.168.1.2:8080) iptables -t raw -I PREROUTING -d 192.168.2.2 -j DROP iptables -t nat -I PREROUTING -d 192.168.1.2 -p tcp --dport 8080 -j DNAT --to-destination 192.168.2.2:80 (Note: these rules are applied on the host itself, not its gateway or so; since you included FORWARD rules that I can't make sense out of, I have no idea what or where you were doing) The key here is to use raw (PREROUTING) instead of filter (INPUT) to drop the unwanted traffics, as filter (INPUT) is matched against after nat (PREROUTING) is. You probably do NOT want to add an inbound interface match (-i) to the first rule, since you apparently want the address to be completely "invisible". (Well, maybe you want something like ! -i...again, I have no idea what you actually want to do, so.) For the second one, it depends on in what cases you want the DNAT to occur. For the record, I don't see any reason for you to use a public IP for this purpose anyway (although to be fair, even if you use a private IP, you'll need to choose one that does not conflict with private subnets that this host would need to reach). P.S. As far as I know, what you called "virtual interface" is nothing but an archaic way to configure more than one IP address on one network interface.
IP forwarding, masquareding, NAT
1,524,839,207,000
I have following networking setup: Gateway: Internet <-- eth0 : a.b.c.d (static address) Clients <-- eth1 : DHCP at server at 172.16.0.1, leasing 172.16.0.0/24 Client: Gateway <-- eth0: 172.16.0.0/24 Clients can reach internet and forwarding is working. I want to create some kind of "virtual" address, which clients can access via gateway, but that address would be in fact some machine on the Internet. So, when they connect to 172.32.1.1 they in fact connect to google and so on. I tried it with NAT: TARGET=$(dig -q google.com) VIRTUAL=172.32.1.1 iptables -t nat -A PREROUTING -d "$VIRTUAL" -j DNAT --to "$TARGET" iptables -t nat -A POSTROUTING -s "$TARGET" -j SNAT --to "$VIRTUAL" that somehow works, however when I ping it from gateway I get From 20.249.x.y icmp_seq=1 Destination Net Unreachable (where 20.249.x.y is my Gateway's gateway), and when I traceroute to that virtual IP from the client, I get this: traceroute to 172.32.1.1 (172.32.1.1), 30 hops max, 38 byte packets 1 172.32.1.1 (172.32.1.1) 31.886 ms 31.638 ms 34.029 ms 2 172.32.1.1 (172.32.1.1) 39.660 ms 40.489 ms 39.153 ms 3 172.32.1.1 (172.32.1.1) 41.879 ms 40.367 ms 40.436 ms 4 172.32.1.1 (172.32.1.1) 47.375 ms 48.200 ms 48.878 ms 5 172.32.1.1 (172.32.1.1) 47.801 ms 47.280 ms 47.405 ms That looks super weird to me. Is there a way to fix these issues? I was trying to use ip tunnel, but it looks like it needs different end setting up as well, which I obviously cannot do. iptables config on server contains these two rules and -A FORWARD -i eth1 -j ACCEPT only.
You might want to flush existing broken iptables rules, and start from scratch. On the Linux box acting as gateway, assume the following conditions: The linux gateway has two NICs; eth0 is LAN facing while eth1 is WAN facing. Enable IP packet forwarding on the gateway: $ sudo echo 1 > /proc/sys/net/ipv4/ip_forward Create two test virtual IPs (VIP) on eth0 as per our test plan $ sudo ifconfig eth0:1 10.1.1.1 netmask 255.255.255.0 $ sudo ifconfig eth0:2 10.8.8.8 netmask 255.255.255.0 Configure iptables as per our plan sudo iptables -t nat -A PREROUTING -d 10.1.1.1 -j DNAT --to 1.1.1.1 sudo iptables -t nat -A PREROUTING -d 10.8.8.8 -j DNAT --to 8.8.8.8 sudo iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE In this case, when a user ping the VIP 10.1.1.1, there will be redirected to Cloudflare's 1.1.1.1 If a user ping the VIP 10.8.8.8 they will be redirected to Google's 8.8.8.8 10.1.1.1 ---> 1.1.1.1 10.8.8.8 ---> 8.8.8.8
virtual gateway via NAT
1,610,042,153,000
All: Recently, I added several new iptables (RE: code snippet below) rules to route traffic through my VPN (0x1000/0x1000) for a specific destination (172.67.168.48) over port 443. The new rules NAT over the VPN as desired, but they've created an undesired effect causing other HTTP requests, unrelated to the aforementioned destination, to produce an error response 400 Bad Request. # Create the RPDB rules ip rule add from 0/0 fwmark "0x1000/0x1000" table ovpnc1 prio 9993 # VPN 1 fwmark iptables -t mangle -A PREROUTING -i br0 -p tcp -d 172.67.168.48 --dport 443 -j MARK --set-mark 0x1000/0x1000 iptables -t nat -A PREROUTING -i br0 -p tcp -m mark --mark 0x1000/0x1000 -j DNAT --to-destination 172.67.168.48:443 Any idea why other HTTP requests would be affected (400 Bad Request) by the new NAT rules when the destination address and port are clearly specified? Thank you for your time and assistance. Kind Regards, Gary
All: It turns out my original iptables -t nat rule was missing the --dport 443 definition and the reason why it was interacting with Other HTTP requests. # Create the RPDB rules ip rule add from 0/0 fwmark "0x1000/0x1000" table ovpnc1 prio 9993 # VPN 1 fwmark iptables -t mangle -A PREROUTING -i br0 -p tcp --dport 443 -d 172.67.168.48 -j MARK --set-mark 0x2000/0x2000 iptables -t nat -A PREROUTING -i br0 -p tcp --dport 443 -j DNAT --to-destination 172.67.168.48:443 -m mark --mark 0x2000/0x2000 Once the --dport 443 definition was added to the iptables -t nat rule the issue was resolved. Hope this helps someone else in the future. Respectfully, Gary
New iptables NAT produces Error 400 Bad Request for Other HTTP Requests
1,610,042,153,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 tables and AFAIK everything looked good. What I observed was following: Pod 10.23.118.10 send UDP(53) package to DNS ClusterIP 10.22.0.10 Destination IP of package is changed then from ClusterIP (10.22.0.10) to the IP of DNS's server pod (10.23.118.2) (DNAT) Server gets request, process it and then send response back to 10.23.118.10 At this point netfilter should replace source IP 10.23.118.2 with 10.22.0.10 before it forwards package, but for some reason it does not do it Libc receives package and rejects it because it sees that response came from 10.23.118.2 instead 10.22.0.10 or we get ICMP package, saying to port is unreachable. What is strange about this, is that it only happens if DNS request is sent to pod that is running on same machine. If DNS request came from pod running on other machine, everything worked fine. I suppose that we are not the only one seeing this. Did you had similar situation? I am not sure whenever this is a bug in linux's netfilter or docker/kubernetes breaks something when configuring bridge interfaces. Where should I look for more information? Here is TCP configuration we tried to apply: net.core.somaxconn = 1000 net.core.netdev_max_backlog = 5000 net.core.rmem_max = 16777216 net.core.wmem_max = 16777216 net.ipv4.tcp_wmem = 4096 12582912 16777216 net.ipv4.tcp_rmem = 4096 12582912 16777216 net.ipv4.tcp_max_syn_backlog = 8096 net.ipv4.tcp_slow_start_after_idle = 0
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-iptables = 0 net.bridge.bridge-nf-call-arptables = 0 Once this is done (netfilter disabled on bridge), NAT-ing will not work properly on docker0 bridge. Interestingly, once you restart docker and query system with sysctl -a, you can see following: net.bridge.bridge-nf-call-ip6tables = 1 net.bridge.bridge-nf-call-iptables = 1 I can only assume that this settings are changed by docker itself during start. Which explains why restarting docker usually helps.
netfilter fails to properly replace destination IP of UDP response package
1,610,042,153,000
I have an Ubuntu VPS which is accessible. Also, I have a local Windows PC which is not, because of NAT. What I want to do, but am struggling with: I want that all traffic to certain port to the VPS be redirected (maybe through the SSH connection I can make from the local Windows PC to the VPS) to the local PC, making the server I run on said PC reachable from others in the Internet. Most guides on the web regarding this matter are meant for SSH connection tunneling and only between linux devices. Can someone lend me a hand to pull this in the scenario described? Thanks!
If port forwarding is not an option, the only thing I can think of is SSH remote port forwarding, which is fairly straightforward. ssh -R <PORT_ON_VPS>:127.0.0.1:<PORT_ON_HOME_SERVER> <VPS_IP> So, for example, if you run a web server on your home server on port 80, and would like that to be accessible via the VPS, you could connect to your VPS from your home server using ssh -R 8080:127.0.0.1:80 <VPS_IP>. Then, http://VPS_IP:8080 would reach your web server on your home server. See more about this option here. That being said, SSH is not exactly the fastest thing in the world, and I don't recommend this setup in a production environment. The use case for the above would be more to share an application temporarily so someone could access it from the outside for demonstration purposes.
How to use my VPS to redirect traffic to certain port tomy Windows PC which is behind NAT?
1,610,042,153,000
I‘m trying to set up a DS-Lite AFTR. Because of the overlapping addresses of the tunnel connections to the B4s, a normal NAT table does not work (already tried iptables -t nat -A POSTROUTING -j MASQUERADE), as described in RFC 6333. An extended NAT table would also contain the source IPv6 address of the packet sent by the B4, which means the AFTR then knows which tunnel to use in order to forward the packet. How to do that extension on Linux? I‘m using a Debian based system (Ubuntu 18.04). I‘m establishing tunnels using ip tunnel add dslite mode ip4ip6 local <IPv6 address of AFTR> remote <IPv6 address of B4> The AFTR has the address 192.0.0.1/29 on each tunnel interface and the B4s have the address 192.0.0.2/29 on their tunnel interfaces. Note: I notice a lack of resources on that topix which is a shame. This is exactly why I‘m asking here. Any help is appreciated!
OK, I've actually done it now. Let me take you through the process of me setting it up. My configuration partly survives reboots. First, I've tested this with 2 B4s, 1 AFTR and all the systems manually set up. Also I assume that your AFTR has the IPv6 address 2000::1, the first B4 has the address 2000::2 and the second one has the address 2000::3. The WAN interface of the AFTR has the name eth0 here. Let's get into it now. First, I created the tunnels on the AFTR and the B4s manually. On the AFTR: root@AFTR:~# ip tunnel add dslite mode ip4ip6 local 2000::1 remote 2000::2 root@AFTR:~# ip tunnel add dslite2 mode ip4ip6 local 2000::1 remote 2000::3 root@AFTR:~# ip link set dslite up; ip link set dslite2 up root@AFTR:~# ip a add 192.0.0.1/29 dev dslite; ip a add 192.0.0.1/29 dev dslite2 Now we can already establish the tunnels on the B4s. On B4 1: root@B4-1:~# ip link set dslite up root@B4-1:~# ip a add 192.0.0.2/29 dev dslite root@B4-1:~# ip route add default via 192.0.0.1 dev dslite On B4 2: root@B4-2:~# ip link set dslite up root@B4-2:~# ip a add 192.0.0.2/29 dev dslite root@B4-2:~# ip route add default via 192.0.0.1 dev dslite Now the tunnels are configured and up. But the NAT has not been implemented yet on the AFTR. root@AFTR:~# iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE (eth0 is the Internet side network card) root@AFTR:~# echo "1 dslite" >> /etc/iproute2/rt_tables root@AFTR:~# ip route add default dev dslite table dslite root@AFTR:~# iptables -t mangle -A PREROUTING -i dslite -j MARK --set-mark 1 root@AFTR:~# iptables -t mangle -A POSTROUTING -j CONNMARK --save-mark root@AFTR:~# iptables -t mangle -I PREROUTING -j CONNMARK --restore-mark root@AFTR:~# ip rule add fwmark 1 iif eth0 table dslite root@AFTR:~# echo "2 dslite2" >> /etc/iproute2/rt_tables root@AFTR:~# ip route add default dev dslite2 table dslite2 root@AFTR:~# iptables -t mangle -A PREROUTING -i dslite2 -j MARK --set-mark 2 root@AFTR:~# ip rule add fwmark 2 iif eth0 table dslite2 root@AFTR:~# sysctl -w net.ipv4.fwmark_reflect=1 Now the B4s should be able to reach the IPv4 (and of course IPv6) Internet. But this doesn't mean that they can reach each other, don't forget that when experimenting. It's finally solved...
DS-Lite: Extended NAT binding table
1,610,042,153,000
I want to have access to remote machines that connected to remote server behind the nat (actually it's just another computer with linux). Here you can see scheme. I'm using logmein hamachi to create connection between local machine and remote server and then sshuttle to tunnel traffic. But after few minutes of using sshuttle hamachi terminates connection and I need to restart its service. Hamachi works fine if I not using sshuttle. My sshuttle command: sshuttle -r [email protected] -x xxx.xxx.xxx.xxx 0/0 -vv Maybe there is another way to share network through nat? I need to get access to sites, services, machines that belongs to servers local network.
Didn't want to do this, but I created OpenVPN server on remote server and share local network to clients. And it's seems to work fine.
Getting access to remote machines through remote server behind the NAT
1,610,042,153,000
I'm trying to follow this guide to setup NAT on my Synology NAS. It worked great for me! I had everything working perfectly. But when I came back the next morning, the NAS had done a system update [DSM 6.2.2-24922]... The scripts were gone and after recreating them I get errors that the NAT kernel modules cannot be loaded. Trying to isolate the issue with the insmod, I was able to determine which modules are failing, and see that it is because of "unknown symbols." Here's what I see (note that the variables here are defined in the script at the above link): # for MODULE in ${KERNEL_MODULES_NAT}; do "${BIN_SYNOMODULETOOL}" --insmod "${SERVICE}" ${MODULE} || echo ${MODULE} = $?; done nf_conntrack.ko = 1 nf_defrag_ipv4.ko = 1 nf_conntrack_ipv4.ko = 1 nf_nat.ko = 1 nf_nat_redirect.ko = 1 nf_nat_ipv4.ko = 1 iptable_nat.ko = 255 xt_nat.ko = 255 nf_nat_masquerade_ipv4.ko = 1 xt_REDIRECT.ko = 255 ipt_MASQUERADE.ko = 255 # dmesg | tail -10 [ 2448.777252] iptable_nat: Unknown symbol ipt_alloc_initial_table (err 0) [ 2448.784021] iptable_nat: Unknown symbol ipt_do_table (err 0) [ 2448.789913] iptable_nat: Unknown symbol ipt_unregister_table (err 0) [ 2448.796544] iptable_nat: Unknown symbol ipt_register_table (err 0) [ 2448.818608] xt_nat: Unknown symbol xt_unregister_targets (err 0) [ 2448.824851] xt_nat: Unknown symbol xt_register_targets (err 0) [ 2448.862765] xt_REDIRECT: Unknown symbol xt_unregister_targets (err 0) [ 2448.869368] xt_REDIRECT: Unknown symbol xt_register_targets (err 0) [ 2448.891826] ipt_MASQUERADE: Unknown symbol xt_register_target (err 0) [ 2448.898429] ipt_MASQUERADE: Unknown symbol xt_unregister_target (err 0) I'm really not sure how to fix it. Maybe try to downgrade DSM? Maybe update the objects which are failing to load? Any ideas?
In the end I just installed a TinyCore Virtual Machine on the NAS which can handle the NAT. It seems a bit unnecessary, but I guess it's a little more controllable... so it works.
Synology NAS insmod unknown symbol
1,610,042,153,000
I am trying to setup configuration where all connections to port 161 will go through another gateway (through openvpn) while others are going directly [localhost] -> [gateway] -> [remote] - OK [localhost] <- [gateway] <- [remote] - packet dissappears after vpn tunnel. I am able to sniff that on tun0 iface, then it dissappears. What I did: added gw1 to rt_tables then used this rules ip route add default via 10.8.0.1 dev tun0 table gw1 ip rule add fwmark 0x1 table gw1 iptables -A OUTPUT -t mangle -o eth0 -p tcp --dport 443 -j MARK --set-mark 1 iptables -A POSTROUTING -t nat -o tun0 -p tcp --dport 443 -j SNAT --to 10.8.0.2 iptables -A OUTPUT -t mangle -o eth0 -p udp --dport 161 -j MARK --set-mark 1 iptables -A POSTROUTING -t nat -o tun0 -p udp --dport 161 -j SNAT --to 10.8.0.2 So I am testing tcp and udp connections and what I see: On remote side everything works correctly and packet is send back to gateway to eth0 On gateway packet gets passed back to vpn tunnel (tun0) On localhost that sent that packet I see how packet arrive to 10.8.0.2 (tun0) in tshark and then it dissapears. And localhost does TCP-retransmission or resends UDP packet. I checked packet capture in wireshark and all ports are correct so it's using same random dynamic port during all that trasfer: back and forward. I also tried using masquerade on localhost instead of SNAT without any success. Tried redirecting packets with DNAT to 127.0.0.1 with no success but I am not sure, maybe I'm doing anything wrong. Why that packet dissapears after tun0? My input chain allows everything for now. Maybe I need to enable or disable any new "features" in sysctl.conf that I am not concerned about? Thanks
My rules are correct Solution: for f in /proc/sys/net/ipv4/conf/*/rp_filter; do echo 0 > $f; done echo 1 > /proc/sys/net/ipv4/route/flush Now everything is working fine. Note that you need to disable that on every iface, option "all" are not working fine.
Trying to setup port redirection through 2nd gateway
1,610,042,153,000
imagine that on the same host I have 2 services: an ssh daemon listening on port 22 a socks5 proxy listening on port 1080 I want to multiplex both services using only port 22 but depending on the source port. For example: if source port is one of (1,2,3,4,5,6) then it goes to 1080 otherwise it does to port 22 This rule works one way iptables -t nat -A PREROUTING -p tcp -m tcp --dport 22 -m multiport --sports 1,2,3,4,5,6 -j REDIRECT --to-ports 1080 But I don't know what rule to put for the way back. I suppose something along the lines of: iptables -t nat -A POSTROUTING -p tcp -m tcp ..... But I don't seem to get the right one. Update: this seems to work for a single port: iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 22 --sport 2 -j DNAT --to :1080
And here we go: iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 22 -m multiport --sports 1:6 -j DNAT --to :1080 I knew it was simple.
Multiplex multiple services on same port discriminating by source port
1,610,042,153,000
I've just noticed that MASQUERADE iptables rule added by lxc has ! -d part: iptables -t nat -A POSTROUTING -s 10.0.3.0/24 ! -d 10.0.3.0/24 -j MASQUERADE My guess is that -s 10.0.3.0/24 -d 10.0.3.0/24 can only be observed when sending data from one container to the other one (ping, ssh, you name it). And omitting the ! -d part can only affect performance. To unknown extent. Am I right?
This rule allows two different containers on the same subnet to talk to each other without being NAT'd So a container with 10.0.3.100 talking to 10.0.3.101 will appear as 10.0.3.100 to the other container and not as the host address. This can be beneficial for various purposes (e.g. logging of activity, access controls) because the target container can identify the source container. It also allows these containers to not need default routes (it's all local subnet) so can be beneficial from a security perspective. And, of course, it removes unnecessary NAT overhead!
Source NAT rule for LXC containers
1,610,042,153,000
Network Interface Configuration 192.168.0.0 Out 1(enp10s0f0) - Local 01(enp10s0f1) 192.168.10.0 - Local 02(enp10s0f2) - Local 03(enp10s0f3) 59.27.1.128 Out 2(enp11s0f0) - Local 04(enp11s0f1) 192.168.11.0 - Local 05(enp11s0f2) - Local 06(enp11s0f3) There are 2 lines for out-bound. Each line share its outbound connection to Locals. Out 1 => Local 01~02, Out 2 => Local 03~04 So I made a script to configure iptables as following iptables -t nat -A POSTROUTING -o enp10s0f0 -j MASQUERADE -s 192.168.10.0/24 iptables -t nat -A POSTROUTING -o enp11s0f0 -j MASQUERADE -s 192.168.11.0/24 iptables -A FORWARD -i enp10s0f0 -o enp10s0f1 -m state --state RELATED,ESTABLISHED -j ACCEPT iptables -A FORWARD -i enp10s0f0 -o enp10s0f2 -m state --state RELATED,ESTABLISHED -j ACCEPT iptables -A FORWARD -i enp10s0f0 -o enp10s0f3 -m state --state RELATED,ESTABLISHED -j ACCEPT iptables -A FORWARD -i enp10s0f1 -o enp10s0f0 -j ACCEPT iptables -A FORWARD -i enp10s0f2 -o enp10s0f0 -j ACCEPT iptables -A FORWARD -i enp10s0f3 -o enp10s0f0 -j ACCEPT iptables -t mangle -A PREROUTING -i enp10s0f1 -p tcp -m tcp --dport 80 -j TPROXY --on-ip 0.0.0.0 --on-port 8080 --tproxy-mark 0x1/0x1 iptables -t mangle -A PREROUTING -i enp10s0f2 -p tcp -m tcp --dport 80 -j TPROXY --on-ip 0.0.0.0 --on-port 8080 --tproxy-mark 0x1/0x1 iptables -t mangle -A PREROUTING -i enp10s0f3 -p tcp -m tcp --dport 80 -j TPROXY --on-ip 0.0.0.0 --on-port 8080 --tproxy-mark 0x1/0x1 iptables -t mangle -A PREROUTING -i enp10s0f0 --source 192.168.10.0/24 -j ACCEPT iptables -t mangle -A PREROUTING -i enp10s0f0 --destination 192.168.10.0/24 -j ACCEPT iptables -t mangle -A PREROUTING -i enp10s0f0 -p tcp -m tcp --sport 80 -j MARK --set-mark 0x1/0x1 ip rule add fwmark 0x1/0x1 table 2 ip route add local 0.0.0.0/0 dev lo table 2 //Do this for enp11, too But One of out-line, which is plugged later, doesn't work as expected. (OS reconfigure the routing table after the line is plugged. So out-line first plugged only works. Second one not.) Local-lines connected on another out-line works. I guess it is caused by routing table... but I couldn't figure out the problem. This is 'ip route' shows. default via 59.27.1.129 dev enp11s0f0 proto static metric 2 default via 192.168.0.1 dev enp10s0f0 proto static metric 100 59.27.1.128/26 dev enp11s0f0 proto kernel scope link src 59.27.1.176 metric 2 169.254.0.0/16 dev enp11s0f0 scope link metric 2 192.168.0.0/24 dev enp10s0f0 proto kernel scope link src 192.168.0.22 metric 100 192.168.10.0/24 dev enp10s0f1 proto kernel scope link src 192.168.10.251 metric 100 192.168.11.0/24 dev enp11s0f1 proto kernel scope link src 192.168.11.251 metric 2 222.118.178.36 via 59.27.1.129 dev enp11s0f0 proto dhcp metric 2 Thank you.
It was a problem of routing table. Exactly the same one. Ref. NAT box with multiple internal and external interfaces have to divide table and add rules for lookup based on IP.
Building Router with Transparent Web Resource Cache
1,610,042,153,000
Hello I have a set of raspberry pi installed on a client location. The RPis has internet access but not public ip. I was looking for an opensource solution to monitoring the devices some kind of software that can be instaled to send information to a cloud server about system health, uptime and such things. Its not possible to install a vpn no get access to the raspberrys installed on the client or any kind of network solutions. The Rpis has internet access but cannot be accessed from outside
Icinga2 is also able to handle this configuration. Sattelite Icinga2 system can execute tests on the sattelite host (Raspberry) and send test results to the central monitoring host. It is also able to pull its configuration from the central monitoring host. Although I like Icinga very much, I still feel that learning Icinga2 only to monitor just one Raspberry can be probably an overkill.
remote server monitoring without public ip
1,610,042,153,000
I have the following configured for my two network interfaces. eth1 10.93.90.1 (Production Network) eth0 192.160.0.1 (Private Network/Labb Network) I want to configure eth0 with NAT so I can communicate through eth1 onto the production network. This is what I have tried: [email protected] # echo 1 > /proc/sys/net/ipv4/ip_forward [email protected] # iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE [email protected] # iptables -A FORWARD -i eth0 -o eth1 -j ACCEPT [email protected] # iptables -A FORWARD -i eth1 -o eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT But the node that is connected to the eth0 interface with the ip address 192.168.0.236 can't communicate with other nodes on the production network (10.0.0.0). It can however communicate with the host: [email protected] # ping 10.93.90.1 10.93.90.1 is alive! But not any other hosts on the production network: [email protected] # ping 10.93.89.1 No response from 10.93.89.1 This works fine when I ping from the host itself: [email protected] # ping 10.93.89.1 PING 10.93.89.1 (10.93.89.1) 56(84) bytes of data. Am I missing something here? Or is this not possible to do with only using NAT? UPDATE 1 Routing table for host eth1 (10.93.90.1): [email protected] # route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface default fafne-vlan93.se 0.0.0.0 UG 0 0 0 eth1 10.93.0.0 * 255.255.0.0 U 0 0 0 eth1 192.168.0.0 * 255.255.255.0 U 0 0 0 eth0 Routing table for host eth0 (192.168.0.236) [email protected] # ip route list default via 192.168.0.1 dev eth0 default dev eth0 scope link metric 99 169.254.0.0/16 dev eth0 proto kernel scope link src 169.254.221.167 169.254.0.0/16 dev eth0 scope link metric 99 192.168.0.0/24 dev eth0 proto kernel scope link src 192.168.0.236 UPDATE 2 I have changed the following rule: iptables -A FORWARD -i eth1 -o eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT To: iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT I have also added the following rule to debug the ping: iptables -I FORWARD -j LOG --log-prefix 'SNOOP_' And here is the what got logged when I pinged from 192.168.0.236 to 10.93.89.1: Apr 1 09:14:44 lnxchrispet kernel: [2415274.711664] SNOOP_IN=eth0 OUT=eth1 MAC=90:e2:ba:3c:87:c4:ac:cc:8e:37:47:a6:08:00 SRC=192.168.0.236 DST=10.93.89.1 LEN=84 TOS=0x00 PREC=0x00 TTL=63 ID=9639 DF PROTO=ICMP TYPE=8 CODE=0 ID=0 SEQ=0 Apr 1 09:14:44 lnxchrispet kernel: [2415274.711935] SNOOP_IN=eth1 OUT=eth0 MAC=7c:05:07:0e:36:03:70:54:d2:7c:45:be:08:00 SRC=10.93.89.1 DST=192.168.0.236 LEN=84 TOS=0x00 PREC=0x00 TTL=63 ID=58826 PROTO=ICMP TYPE=0 CODE=0 ID=0 SEQ=0 UPDATE 3 This is all the loaded kernel modules for nat: [email protected] # lsmod |grep nat iptable_nat 12928 1 nf_nat 18231 2 iptable_nat,ipt_MASQUERADE nf_conntrack_ipv4 14078 3 nf_nat,iptable_nat nf_conntrack 52720 5 nf_conntrack_ipv4,nf_nat,iptable_nat,ipt_MASQUERADE,xt_state ip_tables 22042 2 iptable_nat,iptable_filter x_tables 19118 6 ip_tables,iptable_nat,ipt_MASQUERADE,iptable_filter,xt_state,ipt_LOG This module seems to be missing, is it relevant? nf_nat_ipv4 I tried to load it but I dosen't seem to work: [email protected] # modprobe -v nf_nat_ipv4 [email protected] # lsmod |grep nat iptable_nat 12928 1 nf_nat 18231 2 iptable_nat,ipt_MASQUERADE nf_conntrack_ipv4 14078 3 nf_nat,iptable_nat nf_conntrack 52720 5 nf_conntrack_ipv4,nf_nat,iptable_nat,ipt_MASQUERADE,xt_state ip_tables 22042 2 iptable_nat,iptable_filter x_tables 19118 6 ip_tables,iptable_nat,ipt_MASQUERADE,iptable_filter,xt_state,ipt_LOG UPDATE 4 Something doens't seem right, the modules regarding NAT is missing: [email protected] # ls -l /lib/modules/3.2.0-4-amd64/kernel/net/netfilter total 1076 drwxr-xr-x 2 root root 4096 Mar 4 06:42 ipset drwxr-xr-x 2 root root 4096 Mar 4 06:42 ipvs -rw-r--r-- 1 root root 10416 Feb 29 18:10 nf_conntrack_amanda.ko -rw-r--r-- 1 root root 4336 Feb 29 18:10 nf_conntrack_broadcast.ko -rw-r--r-- 1 root root 14440 Feb 29 18:10 nf_conntrack_ftp.ko -rw-r--r-- 1 root root 67360 Feb 29 18:10 nf_conntrack_h323.ko -rw-r--r-- 1 root root 12944 Feb 29 18:10 nf_conntrack_irc.ko -rw-r--r-- 1 root root 116096 Feb 29 18:10 nf_conntrack.ko -rw-r--r-- 1 root root 5552 Feb 29 18:10 nf_conntrack_netbios_ns.ko -rw-r--r-- 1 root root 32528 Feb 29 18:10 nf_conntrack_netlink.ko -rw-r--r-- 1 root root 14416 Feb 29 18:10 nf_conntrack_pptp.ko -rw-r--r-- 1 root root 16672 Feb 29 18:10 nf_conntrack_proto_dccp.ko -rw-r--r-- 1 root root 11912 Feb 29 18:10 nf_conntrack_proto_gre.ko -rw-r--r-- 1 root root 15192 Feb 29 18:10 nf_conntrack_proto_sctp.ko -rw-r--r-- 1 root root 8992 Feb 29 18:10 nf_conntrack_proto_udplite.ko -rw-r--r-- 1 root root 10664 Feb 29 18:10 nf_conntrack_sane.ko -rw-r--r-- 1 root root 36480 Feb 29 18:10 nf_conntrack_sip.ko -rw-r--r-- 1 root root 6352 Feb 29 18:10 nf_conntrack_snmp.ko -rw-r--r-- 1 root root 10240 Feb 29 18:10 nf_conntrack_tftp.ko -rw-r--r-- 1 root root 11400 Feb 29 18:10 nfnetlink.ko -rw-r--r-- 1 root root 20120 Feb 29 18:10 nfnetlink_log.ko -rw-r--r-- 1 root root 18920 Feb 29 18:10 nfnetlink_queue.ko -rw-r--r-- 1 root root 4952 Feb 29 18:10 nf_tproxy_core.ko -rw-r--r-- 1 root root 44016 Feb 29 18:10 x_tables.ko -rw-r--r-- 1 root root 6904 Feb 29 18:10 xt_addrtype.ko -rw-r--r-- 1 root root 7688 Feb 29 18:10 xt_AUDIT.ko -rw-r--r-- 1 root root 4912 Feb 29 18:10 xt_CHECKSUM.ko -rw-r--r-- 1 root root 4384 Feb 29 18:10 xt_CLASSIFY.ko -rw-r--r-- 1 root root 5440 Feb 29 18:10 xt_cluster.ko -rw-r--r-- 1 root root 4144 Feb 29 18:10 xt_comment.ko -rw-r--r-- 1 root root 5480 Feb 29 18:10 xt_connbytes.ko -rw-r--r-- 1 root root 8776 Feb 29 18:10 xt_connlimit.ko -rw-r--r-- 1 root root 6560 Feb 29 18:10 xt_connmark.ko -rw-r--r-- 1 root root 6272 Feb 29 18:10 xt_CONNSECMARK.ko -rw-r--r-- 1 root root 7032 Feb 29 18:10 xt_conntrack.ko -rw-r--r-- 1 root root 4400 Feb 29 18:10 xt_cpu.ko -rw-r--r-- 1 root root 7232 Feb 29 18:10 xt_CT.ko -rw-r--r-- 1 root root 6376 Feb 29 18:10 xt_dccp.ko -rw-r--r-- 1 root root 4352 Feb 29 18:10 xt_devgroup.ko -rw-r--r-- 1 root root 5448 Feb 29 18:10 xt_dscp.ko -rw-r--r-- 1 root root 6176 Feb 29 18:10 xt_DSCP.ko -rw-r--r-- 1 root root 4704 Feb 29 18:10 xt_esp.ko -rw-r--r-- 1 root root 17592 Feb 29 18:10 xt_hashlimit.ko -rw-r--r-- 1 root root 5280 Feb 29 18:10 xt_helper.ko -rw-r--r-- 1 root root 4472 Feb 29 18:10 xt_hl.ko -rw-r--r-- 1 root root 5896 Feb 29 18:10 xt_HL.ko -rw-r--r-- 1 root root 10888 Feb 29 18:10 xt_IDLETIMER.ko -rw-r--r-- 1 root root 4848 Feb 29 18:10 xt_iprange.ko -rw-r--r-- 1 root root 5672 Feb 29 18:10 xt_ipvs.ko -rw-r--r-- 1 root root 8168 Feb 29 18:10 xt_LED.ko -rw-r--r-- 1 root root 4456 Feb 29 18:10 xt_length.ko -rw-r--r-- 1 root root 6480 Feb 29 18:10 xt_limit.ko -rw-r--r-- 1 root root 4200 Feb 29 18:10 xt_mac.ko -rw-r--r-- 1 root root 4936 Feb 29 18:10 xt_mark.ko -rw-r--r-- 1 root root 5144 Feb 29 18:10 xt_multiport.ko -rw-r--r-- 1 root root 4536 Feb 29 18:10 xt_NFLOG.ko -rw-r--r-- 1 root root 6080 Feb 29 18:10 xt_NFQUEUE.ko -rw-r--r-- 1 root root 4792 Feb 29 18:10 xt_NOTRACK.ko -rw-r--r-- 1 root root 9536 Feb 29 18:10 xt_osf.ko -rw-r--r-- 1 root root 4272 Feb 29 18:10 xt_owner.ko -rw-r--r-- 1 root root 5192 Feb 29 18:10 xt_physdev.ko -rw-r--r-- 1 root root 4224 Feb 29 18:10 xt_pkttype.ko -rw-r--r-- 1 root root 5896 Feb 29 18:10 xt_policy.ko -rw-r--r-- 1 root root 5120 Feb 29 18:10 xt_quota.ko -rw-r--r-- 1 root root 5960 Feb 29 18:10 xt_rateest.ko -rw-r--r-- 1 root root 8968 Feb 29 18:10 xt_RATEEST.ko -rw-r--r-- 1 root root 4072 Feb 29 18:10 xt_realm.ko -rw-r--r-- 1 root root 20136 Feb 29 18:10 xt_recent.ko -rw-r--r-- 1 root root 5432 Feb 29 18:10 xt_sctp.ko -rw-r--r-- 1 root root 6856 Feb 29 18:10 xt_SECMARK.ko -rw-r--r-- 1 root root 10432 Feb 29 18:10 xt_set.ko -rw-r--r-- 1 root root 8704 Feb 29 18:10 xt_socket.ko -rw-r--r-- 1 root root 5056 Feb 29 18:10 xt_state.ko -rw-r--r-- 1 root root 5232 Feb 29 18:10 xt_statistic.ko -rw-r--r-- 1 root root 5088 Feb 29 18:10 xt_string.ko -rw-r--r-- 1 root root 5024 Feb 29 18:10 xt_tcpmss.ko -rw-r--r-- 1 root root 8496 Feb 29 18:10 xt_TCPMSS.ko -rw-r--r-- 1 root root 5616 Feb 29 18:10 xt_TCPOPTSTRIP.ko -rw-r--r-- 1 root root 6376 Feb 29 18:10 xt_tcpudp.ko -rw-r--r-- 1 root root 9216 Feb 29 18:10 xt_TEE.ko -rw-r--r-- 1 root root 6024 Feb 29 18:10 xt_time.ko -rw-r--r-- 1 root root 10848 Feb 29 18:10 xt_TPROXY.ko -rw-r--r-- 1 root root 4184 Feb 29 18:10 xt_TRACE.ko -rw-r--r-- 1 root root 5176 Feb 29 18:10 xt_u32.ko The current kernel is 3.2.0-4-amd64 on Debian Wheezy system [email protected] # uname -r 3.2.0-4-amd64 [email protected] # lsb_release -a No LSB modules are available. Distributor ID: Debian Description: Debian GNU/Linux 7.9 (wheezy) Release: 7.9 Codename: wheezy I will try to install the wheezy-backports kernel, 3.16.0-0.bpo.4-amd64. UPDATE 5 I could load the correct modules after booting the wheezy-backports kernel 3.16.0-0.bpo.4-amd64 [email protected] # uname -r 3.16.0-0.bpo.4-amd64 [email protected] # modprobe -v iptable_nat insmod /lib/modules/3.16.0-0.bpo.4-amd64/kernel/net/netfilter/x_tables.ko insmod /lib/modules/3.16.0-0.bpo.4-amd64/kernel/net/netfilter/nf_conntrack.ko insmod /lib/modules/3.16.0-0.bpo.4-amd64/kernel/net/netfilter/nf_nat.ko insmod /lib/modules/3.16.0-0.bpo.4-amd64/kernel/net/ipv4/netfilter/nf_nat_ipv4.ko insmod /lib/modules/3.16.0-0.bpo.4-amd64/kernel/net/ipv4/netfilter/ip_tables.ko insmod /lib/modules/3.16.0-0.bpo.4-amd64/kernel/net/ipv4/netfilter/iptable_nat.ko [email protected] # lsmod |grep nat iptable_nat 12646 1 ip_tables 25967 2 iptable_filter,iptable_nat nf_nat_ipv4 12912 1 iptable_nat nf_nat 18159 3 ipt_MASQUERADE,nf_nat_ipv4,iptable_nat nf_conntrack 91426 6 ipt_MASQUERADE,nf_nat,xt_state,nf_nat_ipv4,iptable_nat,nf_conntrack_ipv4
So it seems like the Debian Wheezy installation had a faulty kernel or NAT wasn't fully supported for it. It was missing one specific kernel module, nf_nat_ipv4. As can be seen here: [email protected] # lsmod |grep nat iptable_nat 12928 1 nf_nat 18231 2 iptable_nat,ipt_MASQUERADE nf_conntrack_ipv4 14078 3 nf_nat,iptable_nat nf_conntrack 52720 5 nf_conntrack_ipv4,nf_nat,iptable_nat,ipt_MASQUERADE,xt_state ip_tables 22042 2 iptable_nat,iptable_filter x_tables 19118 6 ip_tables,iptable_nat,ipt_MASQUERADE,iptable_filter,xt_state,ipt_LOG Install 3.16.0-0.bpo.4-amd64 kernel The default kernel for Debian Wheezy is 3.2.0-4-amd64. So instead I installed the wheezy-backports kernel 3.16.0-0.bpo.4-amd64. [email protected] # apt-get update [email protected] # apt-get install linux-image-3.16.0-0.bpo.4-amd64 linux-headers-3.16.0-0.bpo.4-all-amd64 The following packages have unmet dependencies: linux-image-3.16.0-0.bpo.4-amd64 : Depends: initramfs-tools (>= 0.110~) but it is not going to be installed E: Unable to correct problems, you have held broken packages. APT complained that the correct initramfs-tools package couldn't be installed as a dependency. So I hade to install that from wheezy-backports fist: [email protected] # apt-get -t wheezy-backports install initramfs-tools I could then install the 3.16.0-0.bpo.4-amd64 kernel: [email protected] # apt-get install linux-image-3.16.0-0.bpo.4-amd64 linux-headers-3.16.0-0.bpo.4-all-amd64 I then reboot the system and continued with loading the NAT kernel moduels. Loading the NAT kernel modules I checked first if I had loaded the correct kernel: [email protected] # uname -r 3.16.0-0.bpo.4-amd64 The system is currently running the backports kernel. I then proceeded with loading in the NAT kernel modules: [email protected] # modprobe -v iptable_nat insmod /lib/modules/3.16.0-0.bpo.4-amd64/kernel/net/netfilter/x_tables.ko insmod /lib/modules/3.16.0-0.bpo.4-amd64/kernel/net/netfilter/nf_conntrack.ko insmod /lib/modules/3.16.0-0.bpo.4-amd64/kernel/net/netfilter/nf_nat.ko insmod /lib/modules/3.16.0-0.bpo.4-amd64/kernel/net/ipv4/netfilter/nf_nat_ipv4.ko insmod /lib/modules/3.16.0-0.bpo.4-amd64/kernel/net/ipv4/netfilter/ip_tables.ko insmod /lib/modules/3.16.0-0.bpo.4-amd64/kernel/net/ipv4/netfilter/iptable_nat.ko [email protected] # lsmod |grep nat iptable_nat 12646 1 ip_tables 25967 2 iptable_filter,iptable_nat nf_nat_ipv4 12912 1 iptable_nat nf_nat 18159 3 ipt_MASQUERADE,nf_nat_ipv4,iptable_nat nf_conntrack 91426 6 ipt_MASQUERADE,nf_nat,xt_state,nf_nat_ipv4,iptable_nat,nf_conntrack_ipv4 Testing NAT I then configured ip forwarding and NAT again as it disappeared after boot: [email protected] # echo 1 > /proc/sys/net/ipv4/ip_forward [email protected] # iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE Then I tested to ping from 192.168.0.236 and it worked: [email protected] # ping 10.93.89.1 10.93.89.1 is alive! Conclusions The problem were that the correct NAT kernel modules couldn't be loaded and to fix this I had to install the kernel from the wheezy-backports and the load the NAT kernel modules.
NAT for second interface on private network
1,610,042,153,000
I had a tough misleading error while connecting in AWS VPC subnets. The error did occur in B->A connection, and did not happen while A->B, so at the beginning I thought that it is library bug. It happened to be caused by AWS-system "double layer routing, and the NAT instance in the subnet, that did redirect packets over wrong network channel, causing ssh to drop connection. Below there is a copy of mine post with 'case-study', that was deleted from the original thread: As far as I can tell this isn't even attempting to answer the question, so I'm deleting it. If you have a separate question feel free to post it as one |@michael-mrozek In my case: as @patrick suggested (ssh_exchange_identification: read: Connection reset by peer): CLIENT (subnetB 172.16.3.76) ssh 172.16.0.141 -vvv -p23 OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 19: Applying options for * debug2: ssh_connect: needpriv 0 debug1: Connecting to 172.16.0.141 [172.16.0.141] port 23. debug1: Connection established. debug1: permanently_set_uid: 0/0 debug1: identity file /root/.ssh/id_rsa type -1 debug1: identity file /root/.ssh/id_rsa-cert type -1 debug1: identity file /root/.ssh/id_dsa type -1 debug1: identity file /root/.ssh/id_dsa-cert type -1 debug1: identity file /root/.ssh/id_ecdsa type -1 debug1: identity file /root/.ssh/id_ecdsa-cert type -1 debug1: identity file /root/.ssh/id_ed25519 type -1 debug1: identity file /root/.ssh/id_ed25519-cert type -1 debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2 ssh_exchange_identification: read: Connection reset by peer SERVER (SubnetA 172.16.0.141) $(which sshd) -d -p 23 debug1: sshd version OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014 debug1: key_parse_private2: missing begin marker debug1: read PEM private key done: type RSA debug1: private host key: #0 type 1 RSA debug1: key_parse_private2: missing begin marker debug1: read PEM private key done: type DSA debug1: private host key: #1 type 2 DSA debug1: key_parse_private2: missing begin marker debug1: read PEM private key done: type ECDSA debug1: private host key: #2 type 3 ECDSA debug1: could not open key file '/etc/ssh/ssh_host_ed25519_key': No such file or directory Could not load host key: /etc/ssh/ssh_host_ed25519_key debug1: rexec_argv[0]='/usr/sbin/sshd' debug1: rexec_argv[1]='-d' debug1: rexec_argv[2]='-p' debug1: rexec_argv[3]='23' Set /proc/self/oom_score_adj from 0 to -1000 debug1: Bind to port 23 on 0.0.0.0. Server listening on 0.0.0.0 port 23. debug1: Bind to port 23 on ::. Server listening on :: port 23. debug1: Server will not fork when running in debugging mode. debug1: rexec start in 5 out 5 newsock 5 pipe -1 sock 8 debug1: inetd sockets after dupping: 3, 3 debug1: getpeername failed: Transport endpoint is not connected debug1: get_remote_port failed https://superuser.com/questions/856989/ssh-error-ssh-exchange-identification-read-connection-reset-by-peer The VPC setup and case description: I do have AWS EC2 Amazon instances running in the VPC (172.16.0.0/16) There is public subnetA (172.16.0.0/24), with NAT-instanceA (172.16.0.200) with attached elastic IP The other instances in subnetA communicates to the internet via instanceA (default via 172.16.0.200 dev eth0) There are instances in subnetB (172.16.3.0/24) route table is similar to https://stackoverflow.com/questions/10243833/how-to-connect-to-outside-world-from-amazon-vpc The problem: The hosts both from subnetA and subnetB can ping/communicate. The hosts from subnetA can ssh to host in subnetB The hosts from subnetB can ssh to instanceA in subnetA NONE of the hosts in subnetB can ssh to OTHER instance in subnetA (other than instanceA), there is an error : ssh_exchange_identification: read: Connection reset by peer IF_AND_ONLY_IF the instances in SubnetA HAVE defaut gateway set to NAT-InstanceA (example 'default via 172.16.0.200 dev eth0'). If there is instance_in_subnetA with not_changed default gateway (example 'default via 172.16.0.1 dev eth0'), then You can ssh to that instance from SubnetBhosts comment: If there won't be a NAT in subnetA, the instances in subnetA won't have outgoing internet connection So... The problem is probably caused by Amazon AWS Router and/or NAT configuration. For the moment, I guess, that despite the fact, that the VPC routing table is set to: Destination Target 172.16.0.0/16 local 0.0.0.0/0 igw-nnnnn The subnetA instances are in 172.16.0.0/24 (edit: source of the problem: routing table redirecting traffic other than 172.16.0.0/24 via NAT instance, overriding AWS-side-Routing: 172.16.0.0/16) default via 172.16.0.200 dev eth0 172.16.0.0/24 dev eth0 proto kernel scope link src 172.16.0.60 The subnetB instances are in 172.16.3.0/24 When hosts from subnetB connect to instances in subnetA (other than NAT-instanceA), the traffic goes like: 172.16.3.X/24 --> 172.16.3.1 --> 172.16.0.Y V ??? <-- 172.16.3.200 (NAT) And that is the problem. I would have to tcpdump that and verify, it might be fixable via NAT rules, though it is more complex than it should be. Actually, the rule in AWS router Destination Target 172.16.0.0/16 local should in theory cover the VPC/16 subnet, but the instance/24 subnet + NAT gateway hide the functionality on the "system_level".
On the instances in subnetA (with NAT-instance 172.16.0.200), the routing table looks like: default via 172.16.0.200 dev eth0 172.16.0.0/24 dev eth0 proto kernel scope link src 172.16.0.141 actually, the one addition: $ ip r a 172.16.3.0/24 via 172.16.0.1 (or ip r a 172.16.3.0/16 via 172.16.0.1) Fixes the system routing table: default via 172.16.0.200 dev eth0 172.16.0.0/24 dev eth0 proto kernel scope link src 172.16.0.141 172.16.3.0/24 via 172.16.0.1 dev eth0 and shifts the VPC subnets routing over to AWS routers Destination Target 172.16.0.0/16 local 0.0.0.0/0 igw-nnnnn
AWS VPC NAT | ssh_exchange_identification: read: Connection reset by peer [closed]
1,530,517,786,000
I had similar issues before but i don't remember how i solved it. When i try to copy something to USB stick, with FAT, it stops near the end, sometimes at 100%. And of course, when i transfer the memory stick somewhere else, it doesn't contain complete file. (file is a movie!) I tried to mount device with mount -o flush, but i get same issue. Also, i did format the USB stick with new FAT partition... Any idea what cold i do? p.s. I believe it's not related to OS, which is Debian, and i believe that coping from SSD drive doesn't make it stuck.
The reason it happens that way is that the program says "write this data" and the linux kernel copies it into a memory buffer that is queued to go to disk, and then says "ok, done". So the program thinks it has copied everything. Then the program closes the file, but suddenly the kernel makes it wait while that buffer is pushed out to disk. So, unfortunately the program can't tell you how long it will take to flush the buffer because it doesn't know. If you want to try some power-user tricks, you can reduce the size of the buffer that Linux uses by setting the kernel parameter vm.dirty_bytes to something like 15000000 (15 MB). This means the application can't get more than 15MB ahead of its actual progress. (You can change kernel parameters on the fly with sudo sysctl vm.dirty_bytes=15000000 but making them stay across a reboot requires changing a config file like /etc/sysctl.conf which might be specific to your distro.) A side effect is that your computer might have lower data-writing throughput with this setting, but on the whole, I find it helpful to see that a program is running a long time while it writes lots of data vs. the confusion of having a program appear to be done with its job but the system lagging badly as the kernel does the actual work. Setting dirty_bytes to a reasonably small value can also help prevent your system from becoming unresponsive when you're low on free memory and run a program that suddenly writes lots of data. But, don't set it too small! I use 15MB as a rough estimate that the kernel can flush the buffer to a normal hard drive in 1/4 of a second or less. It keeps my system from feeling "laggy".
Gnome, nautilus copy files to USB stops at 100% or near
1,530,517,786,000
In Gnome 3.18, it was possible to change the titlebar height of all windows by changing the css in ~/.config/gtk-3.0/gtk.css as per Reduce title bar height in gnome 3 / gtk+ 3. .header-bar.default-decoration { padding-top: 0px; padding-bottom: 0px; } .header-bar.default-decoration .button.titlebutton { padding-top: 0px; padding-bottom: 0px; } /* No line below the title bar */ .ssd .titlebar { border-width: 0; box-shadow: none; } In Gnome 3.20, this appears to no longer apply to windows with a headerbar/CSD (gnome-specific buttons in the title bar), such as Nautilus (Files), Settings, Photos, Contacts, etc. The tweak still reduces the titlebar height for other applications, such as gnome-terminal and gVim. How do I reduce the height of the titlebar in gnome-programs such as Nautilus in Gnome 3.20? Update I have also tried what is suggested in this reddit thread. I tried both window.ssd and .ssd only, no dice. This works, see the answer I posted for more details window.ssd headerbar.titlebar { padding-top: 1px; padding-bottom: 1px; min-height: 0; } window.ssd headerbar.titlebar button.titlebutton { padding-top: 1px; padding-bottom: 1px; min-height: 0; } and /* shrink headebars */ headerbar { min-height: 38px; padding-left: 2px; /* same as childrens vertical margins for nicer proportions */ padding-right: 2px; } headerbar entry, headerbar spinbutton, headerbar button, headerbar separator { margin-top: 2px; /* same as headerbar side padding for nicer proportions */ margin-bottom: 2px; } /* shrink ssd titlebars */ .default-decoration { min-height: 0; /* let the entry and button drive the titlebar size */ padding: 2px } .default-decoration .titlebutton { min-height: 26px; /* tweak these two props to reduce button size */ min-width: 26px; }
Note: If you are on PopOS, there is an option to "Remove Window Titles" in the top bar menu that also controls tiling. This is what I use currently myself and it works great for only removing the superfluous non-CSD titlebars. Headerbar/CSD Actually, a section of the code that I found via reddit and posted above, namely headerbar entry, headerbar spinbutton, headerbar button, headerbar separator { margin-top: 2px; /* same as headerbar side padding for nicer proportions */ margin-bottom: 2px; } DOES modify the headerbars/CSDs. However the effect is not immediate. Even if you reload gnome, you might need to close all windows, wait a while, or log out and log back in again to see the effect. I am still not seeing any difference in the header bar when modifying the following. headerbar { min-height: 38px; padding-left: 2px; /* same as children's vertical margins for nicer proportions */ padding-right: 2px; } Standard titlebar The two sections for the normal window titlebars work as expected. .default-decoration { min-height: 0; /* let the entry and button drive the titlebar size */ padding: 2px } .default-decoration .titlebutton { min-height: 26px; /* tweak these two props to reduce button size */ min-width: 26px; } Titlebar border You can use the following to remove the titlebar border if you are running the default adwaita theme. From https://bbs.archlinux.org/viewtopic.php?id=211102 window.ssd headerbar.titlebar { border: none; background-image: linear-gradient(to bottom, shade(@theme_bg_color, 1.05), shade(@theme_bg_color, 0.99)); box-shadow: inset 0 1px shade(@theme_bg_color, 1.4); }
How to change the titlebar height in standard GTK apps and those with headerbars/CSDs on Gnome 3.20
1,530,517,786,000
My question is similar to this one, however the answers provided are not sufficient. I'm a linux occasional user / learner, not having much background to understand what to do reading between the lines. I've Ubuntu and Nautilus, in a mode that shows a left pane, without the appropriate content. At the moment a flat list, not a tree, shows personal folders, disk drives and network places (plus some bookmarks I managed to add). I assume I got the spatial view. I'd like to have a tree. In the selected answer, the fix is to hit F9 to show the left pane. Not working. F9 just hides and shows this left pane I don't want. "View" menu also suggested is not even possible, since I've no menu displayed either. The other suggestion to hit Alt-F2 to open a command prompt and then launch gconf-editor. Tried that, and got command not found. Also tried sudo gconf-editor in a terminal. Got the same result. Did a little google work, but I mustn't express my problem correctly, results are similar to the linked question. What's wrong with my configuration?
This is the most near that you can get of what you want, otherwise look for another file manager: Look for 'Preferences', in the 'Views' tab, select "View new folders using: list view", then select the 'Display' tab, there will be a Checkbox that tells you 'Navigate folders in a tree', close Nautilus. Now open a folder and select list view, that way you will have a tree like behavior in the main panel. If you don't like how it's shown then try with another file manager.
How to show the tree view in left pane of Nautilus?
1,530,517,786,000
Is there a Linux equivalent of the Windows Shift+Right-click sequence? I use this a lot on files and directories to get the 'hidden' "Copy as path" option in the pop-up menu. It saves a lot of typing (and typos) when using the command line. I'm hoping that Linux has something similar, so I can go to the 'Files' window in a GUI (Gnome3 in my case) and just copy a file or directory location as a path and then paste it in a terminal window. This function would be especially handy in Linux given the heavy reliance on the terminal! Is this possible?
If you click 'Copy' from the right-click context menu in Nautilus (file manager in GNOME3) and paste the contents in a text field (text editor, text box, etc.), it will paste the path instead of the file itself.
Mouse shortcut to copy the path to a file in the Gnome file manager
1,530,517,786,000
Since I installed EasyTag on my Arch Linux several other programs use EasyTag instead of Nautilus as filebrowser. For example, Firefox starts EasyTag if I click on "open containing folder". Where can I set Nautilus as my "standard file browser"?
You can define the default file browser by editing the file ~/.local/share/applications/mimeapps.list. Open this file and change the line inode/directory as follow inode/directory=nautilus.desktop; If this doesn't work, you should change the filemanager in the file /usr/share/applications/mimeinfo.cache by adding (or updating) this line inode/directory=nautilus.desktop
Set standard file browser for "open containing folder"
1,530,517,786,000
I am using Trisquel 7.0 with Nautilus 3.10.1 installed. Whenever I display properties of a file, I've one file-specific tab like: Image,Audio/Video,Document etc. which displays special information about it. Example for a Image: Example for a PDF Document: How does Nautilus get this type of file-specific information? And how do I print this information (MetaData) with te command-line?
For the first level of information in the command line, you can use file. $ file gtu.pdf gtu.pdf: PDF document, version 1.4 For most formats, and more detailed information, you can also use Exiftool: NAME exiftool - Read and write meta information in files SYNOPSIS exiftool [OPTIONS] [-TAG...] [--TAG...] FILE... exiftool [OPTIONS] -TAG[+-<]=[VALUE]... FILE... exiftool [OPTIONS] -tagsFromFile SRCFILE [-SRCTAG[>DSTTAG]...] FILE... exiftool [ -ver | -list[w|f|r|wf|g[NUM]|d|x] ] For specific examples, see the EXAMPLES sections below. This documentation is displayed if exiftool is run without an input FILE when one is expected. DESCRIPTION A command-line interface to Image::ExifTool, used for reading and writing meta information in a variety of file types. FILE is one or more source file names, directory names, or "-" for the standard input. Information is read from source files and printed in readable form to the console (or written to output text files with -w). Example: $ exiftool IMG_20151104_102543.jpg ExifTool Version Number : 9.46 File Name : IMG_20151104_102543.jpg Directory : . File Size : 2.8 MB File Modification Date/Time : 2015:11:04 10:25:44+05:30 File Access Date/Time : 2015:11:17 18:56:49+05:30 File Inode Change Date/Time : 2015:11:11 14:55:43+05:30 File Permissions : rwxrwxrwx File Type : JPEG MIME Type : image/jpeg Exif Byte Order : Big-endian (Motorola, MM) GPS Img Direction : 0 GPS Date Stamp : 2015:11:04 GPS Img Direction Ref : Magnetic North GPS Time Stamp : 04:55:43 Camera Model Name : Micromax A121 Aperture Value : 2.1 Interoperability Index : R98 - DCF basic file (sRGB) Interoperability Version : 0100 Create Date : 2002:12:08 12:00:00 Shutter Speed Value : 1/808 Color Space : sRGB Date/Time Original : 2015:11:04 10:25:44 Flashpix Version : 0100 Exif Image Height : 2400 Exif Version : 0220 Exif Image Width : 3200 Focal Length : 3.5 mm Flash : Auto, Did not fire Exposure Time : 1/809 ISO : 100 Components Configuration : Y, Cb, Cr, - Y Cb Cr Positioning : Centered Y Resolution : 72 Resolution Unit : inches X Resolution : 72 Make : Micromax Compression : JPEG (old-style) Thumbnail Offset : 640 Thumbnail Length : 12029 Image Width : 3200 Image Height : 2400 Encoding Process : Baseline DCT, Huffman coding Bits Per Sample : 8 Color Components : 3 Y Cb Cr Sub Sampling : YCbCr4:2:0 (2 2) Aperture : 2.1 GPS Date/Time : 2015:11:04 04:55:43Z Image Size : 3200x2400 Shutter Speed : 1/809 Thumbnail Image : (Binary data 12029 bytes, use -b option to extract) Focal Length : 3.5 mm Light Value : 11.9 There are also specific commands for some type of files, like pdf: $ pdfinfo gtu.pdf Title: Microsoft Word - Thermax Ltd Author: User Creator: PScript5.dll Version 5.2.2 Producer: GPL Ghostscript 8.15 CreationDate: Tue Jan 27 11:51:38 2015 ModDate: Tue Jan 27 12:30:40 2015 Tagged: no Form: none Pages: 1 Encrypted: no Page size: 612 x 792 pts (letter) Page rot: 0 File size: 64209 bytes Optimized: yes PDF version: 1.4
How to print Metadata of a file with the help of command-line?
1,530,517,786,000
How can I close all opened Nautilus (explorer) windows from the terminal?
nautilus -q or killall nautilus If nautilus is in the middle of doing something you should use the first command as it allows nautilus to exit gracefully. The second command just "terminates" nautilus so if invoked in the middle of e.g. a copy/move operation you might end up with corrupted data.
Closing all Nautilus windows from terminal
1,530,517,786,000
I have been using xterm for all my work. I realized that the features that desktop environments like GNOME has to provide are not of much use to me. Now, is it possible that I remove GNOME and KDE altogether and use some window manager only in run level 5 (X11) to play videos, use browser, and occasionally file manager like Nautilus. How can I do it? Is it a good idea? Which window manager would you suggest? What I have done so far: I installed Window Maker. When I rebooted, I was offered one more choice at the time of login - GNOME, KDE, Window Maker. I chose Window Maker. It gives me multiple workspaces, customizable keyboard shortcuts, without usual desktop features like panel, notification area, desktop icons. But I have observed that whenever I launch Nautilus, the desktop background changes to the one I set on GNOME and all desktop icons are restored as they were in GNOME, though the keyboard shortcuts of Window Maker still works. But to remove GNOME background and desktop icons I have to logout and login again. How can I fix it so that launching of Nautilus does not bring GNOME background? Should I use some other file manager? Update I have complied and installed dwm. It was not difficult at all. Though I needed to do the following steps to make dwm show in the menu of my login screen. $ cd /usr/share/xsessions/ $ vim dwm.desktop In the dwm.desktop I wrote: [Desktop Entry] Encoding=UTF-8 Name=dwm Comment=To start dwm session Exec=/usr/local/bin/dwm Type=Application This time when I got to login, I got dwm in the menu. Update I solved the nautilus problem using following steps. $ gconftool-2 --recursive-list "/apps" |less Here I searched for nautilus. It gave me /apps/nautilus: /apps/nautilus/preferences: show_icon_text = local_only start_with_sidebar = true click_policy = double background_color = #ffffff start_with_toolbar = true start_with_location_bar = true mouse_back_button = 8 thumbnail_limit = 10485760 directory_limit = -1 ... After that it was a simple matter of setting keys $ gconftool-2 --get "/apps/nautilus/preferences/show_desktop" $ true $ gconftool-2 --set "/apps/nautilus/preferences/show_desktop" --type bool false $ gconftool-2 --get "/apps/nautilus/preferences/exit_with_last_window $ false $ gconftool-2 --set "/apps/nautilus/preferences/exit_with_last_window" --type bool true $ gconftool-2 --get "/apps/nautilus/preferences/media_automount_open $ true $ gconftool-2 --set "/apps/nautilus/preferences/media_automount_open" --type bool false Useful links: dwm Primer GConf Command Line Tool
I asked a similar question once. It is definitely a good idea if you find yourself ignoring the miscellaneous tools and features that come with the desktop environment. The solution is, you don't need to install a desktop environment (or anything you don't use), just a window manager of your choice. I (also) asked another question about lightweight window managers. The summary is, if you want lots of effects go Compiz, otherwise choose a lightweight one like dwm. Regarding Nautilus, do you really need it or some of it features? If not then you should probably switch to something else, maybe Thunar.
How to get rid of desktop environment and use a window manager only?
1,530,517,786,000
Would be nice to be shown the magic button that will help me remove this eyesore: It's Nautilus 2.30 on Debian (and has been there in previous versions as far as I can remember).
This list gets created by analyzing .desktop files located at: /usr/share/applications ~/.local/share/applications There might be more than one usecase per application, take for example the media player banshee which has three .desktop files by default: $ ls -1 /usr/share/applications/banshee* /usr/share/applications/banshee-1-audiocd.desktop /usr/share/applications/banshee-1.desktop /usr/share/applications/banshee-1-media-player.desktop The only difference between those files is the starting parameter and the MimeType list. banshee-1.desktop: General media files banshee-1-audiocd.desktop: Audio CD's banshee-1-media-player.desktop Audio player (Also used by rhythmbox, vlc, and others) So we have three 'Banshee Media Player' in the 'Open with' list (and maybe also in the 'Main Menu'). The other way of filling this space is by creating personal .desktop files in ~/.local/share/applications. Either manually or by using a tool. alacarte (or right-click on 'Main Menu' -> 'Edit Menu') is one of those. Every time you create or move an application within alacarte, a new .desktop file gets placed inside ~/.local/share/applications. Disabling an application will "remove" it from the 'Main Menu', but not from the 'Open with' list. But the 'Delete' button does, by creating a identical copy from /usr/share/applications into ~/.local/share/applications and adding Hidden=true to the .desktop file, thus "overwriting" the system-wide inherited values. Deleting two of those entries from alacarte results in: $ ls -1 ~/.local/share/applications/banshee* /home/user/.local/share/applications/banshee-1-audiocd.desktop /home/user/.local/share/applications/banshee-1-media-player.desktop Removing any entries from ~/.local/share/applications will reverse to the preexisting state (three banshee items). If you really don't have any duplicates in those two folders, try removing any duplicates from alacarte or playing with the Hidden=true option in the corresponding .desktop files.
How to remove duplicate entries in 'Open With' Nautilus dialogue?
1,530,517,786,000
I have a Bash script I was trying to make to help me run a rather complex command with small changes that it would ask me about through echo and read. I have found solutions to force it to run a terminal to execute the command, but I'm not interested in that. What I would like it to do is, if I space out and just hit Enter on it in Nautilus (making it run with Run Software), it'll just gently pop up a notification saying "Please run this from a terminal." I can get the popup to happen -- as in I know the command -- but I can't get the Bash script to tell if it's being run inside a terminal or not, it seems to always think so. Is it even possible?
From man bash under CONDITIONAL EXPRESSIONS: -t fd True if file descriptor fd is open and refers to a terminal. Assuming fd 1 is standard out, if [ -t 1 ]; then should work for you. The Advanced Shell Scripting Guide claims that -t used this way will fail over ssh, and that the test (using stdin, not stdout) should therefore be: if [[ -t 0 || -p /dev/stdin ]] -p tests if a file exists and is a named pipe. However, I'd note experientially this is not true for me: -p /dev/stdin fails for both normal terminals and ssh sessions whereas if [ -t 0 ] (or -t 1) works in both cases (see also Gilles comments below about issues in that section of the Advanced Shell Scripting Guide). If the primary issue is a specialized context from which you wish to call the script to behave in a way appropriate to that context, you can sidestep all these technicalities and save your self some fuss by using a wrapper and a custom variable: !#/bin/bash export SPECIAL_CONTEXT=1 /path/to/real/script.sh Call this live_script.sh or whatever and double click that instead. You could of course accomplish the same thing with command line arguments, but a wrapper would still be needed to make point and click in a GUI file browser work.
How can a Bash script tell how it was run?
1,530,517,786,000
Today gvfsd-metadata process was running for a whole day hogging 100% of a single core of my CPU. Is there any reason for it to do it?
AFAIK gvfsd-metadata is a process that collects file metadata when you use Nautilus. If your metadata store got corrupted somehow, it might get stuck on an infinite loop. So you'll have to kill that process, and remove the metadata store. pkill gvfsd-metadata rm -rf .local/share/gvfs-metadata
Why ``gvfsd-metadata`` process is hogging 100% of a single core for a long time
1,530,517,786,000
When I hit N in Nautilus under a folder, it behaves like I am searching files which contains N. Can I make it so that it only leads me to the first file whose name starts with N, like Windows Explorer?
When I press the letter N in a folder in Nautilus that contains files whose names start with a letter N it jumps to the first one of these files. Pressing it a 2nd time will begin the search by name (a little box pops up in the lower right hand corner). There isn't a way to change this behavior using Nautilus. I believe you can use other file explorers though such as mc (aka. midnight commander - terminal based) or Dolphin (KDE). There's a pretty extensive list of file explorers on wikipedia. Check out the section of *nix ones for other alternatives.
Make Nautilus navigate to the first file beginning with the typed letter
1,530,517,786,000
Any idea on how may be changed context-menu from default gnome-terminal to tilix in Ubuntu 18.04 Bionic Beaver? Already tried renaming /usr/bin/gnome-terminal to /usr/bin/gnome-terminalbackup, then /usr/bin/tilix to /usr/bin/gnome-terminal, but without success, context-menu keeps running `gnome-terminal.
a) Run apt install filemanager-actions-nautilus-extension b) Run FileManager-Actions Configuration Tool c) File => New Action d01) Action tab: Mark Display item in location context menu d02) Command tab: Path: /usr/bin/tilix Parameters: --working-directory=%d/%b Working directory: %d e) Restart Nautilus
Change Ubuntu 18.04 Nautilus context menu "Open in Terminal" from "Gnome-terminal" to "Tilix"
1,530,517,786,000
I'd like to use Nautilus as default in XFCE instead of Thunar, but how can I remove full Thunar? I have already typed sudo apt-get remove thunar gvfs-backends But I still have problems because if I click on a folder in the desktop Thunar starts. Can someone help me? Thank you.
Try to look at this similar question of turning your default file-manager into Nautilus: https://askubuntu.com/questions/47208/how-to-stop-thunar-being-default-file-browser You should be able to remove Thunar completely by running following command: sudo apt-get purge thunar*
How to use Nautilus as default in XFCE?
1,530,517,786,000
I am posting this in order to provide an answer, as a way to have a simpler method than using nautilus-actions (launched with nautilus-actions-config-tool), while avoiding to write each time an entire action file from scratch. On the other, while nautilus-actions-config-tool will not be used, nautilus-actions has to be installed for the actions to appear in the context menu.
Reminder: While with this solution the nautilus-actions will not be used in order to add the new context menu actions, it has to be installed for Nautilus to even have the actions feature at all, and for the actions to appear in the context menu. The idea is to have a ready-made but incomplete action file that is to be edited and saved under a new name for each new context menu action. This generic file can in turn be accessed each time with a launcher file (as if it were an app) or from the context menu itself (with another specific action file previously created). Create the folder ~/.local/share/file-manager/actions. To create the ready-made action file, do: gedit ~/.local/share/file-manager/actions/new-action.desktop With these lines: [Desktop Entry] Type=Action ToolbarLabel=<name-of-action> Name=<name-of-action> Profiles=profile-zero; #TargetContext=false #keep the above commented if you WANT the action to appear when you select files of the type specified by the line MymeTypes; un-comment it if you DO NOT WANT your new action to appear when you select the specified files #TargetLocation=true #keep the above commented if you DO NOT WANT the action to appear when right clicking an empty area; remove the comment when you WANT that. [X-Action-Profile profile-zero] Folders=*; Exec= Name=Default profile MymeTypes= #the above line specifies the types of files for which your new action appears when you select them (remove the line 'TargetContext=false' to achieve that) #DO NOT SAVE directly after editing! #USE "SAVE AS" TO SAVE YOUR NEW ACTION FILE! And save it. That can be accessed directly of course, but it's nicer to have an easier way to open the ready-made file. This could be done through a launcher file: gedit ~/.local/share/applications/Nautilus_action.desktop With this content: [Desktop Entry] Type=Application Name=New Nautilus action Icon=nautilus Categories=System;Settings; Exec=sh -c 'gedit ~/.local/share/file-manager/actions/new-action.desktop' Making it executable: chmod +x ~/.local/share/applications/Nautilus_action.desktop After that it can be started from a menu or app launcher: The above is meant to open the generic ~/.local/share/file-manager/actions/new-action.desktop, edit, and save it with a different name. How to do it: Run the launcher "New Nautilus action" When the generic file is open in gedit, edit these lines that will define your new Nautilus menu action (that is: the menu name, the action-file name, and the command to execute): ToolbarLabel= Name= Exec= TargetContext=false The above should be commented (have # before it) if you want the menu action to appear when you select files (of the types specified by the line MymeTypes; see below on the ! option). If you do not want it to appear on selection (a rare case when you want an action only to appear on empty area inside folders), remove the comment (#). TargetLocation=true Considering the above line, if you do not want your new menu action to appear when you right-click an empty area, add # before it; remove the comment if you need the action to appear when you click an empty area inside folders. Add to the following line the mime-types of files for which your new action appears when you select them (remove/comment the line 'TargetContext=false' to achieve that): MymeTypes=; Add the mime types like: inode/directory for folders, audio/* for audio, etc to specify for which selection you want the action to appear; to exclude a certain mime type use ! before it. (For example: if you use an action to convert audio to mp3 you would want it to appear for all audio excepting mp3 files; in this case it should be MymeTypes=!audio/mp3;audio/*.) Look in a file's properties (Basic/Type) in Nautilus to see its mime type. DO NOT SAVE THE FILE directly or your new action will overwrite the generic action file! Use 'Save as' to save the file with a DIFFERENT NAME.
Add a new Nautilus context menu action without using `nautilus-actions`
1,530,517,786,000
I use nautilus as file manager and would like to use Vim instead of Gedit to edit my text files. Many files (log files, empty files, …) are already opened with Vim, however not all of them, e.g. tex files and XML files are still opened with Gedit. update-alternatives --get-selections | grep edit yields editor auto /usr/bin/vim.gnome gnome-text-editor manual /usr/bin/vim.gnome readline-editor auto /usr/bin/rlwrap and I have also set the VISUAL and EDITOR environment variables to point to vim. Although the questions is about changing the default applicatin for any file type, it is fine to respond with a solution that just addresses the mentioned problem changing the default editor, since that is what bothers me at the moment. EDIT: The answer of “hesse” worked for most file types, but not for all. For instance Makefiles are still opened with Gedit. file --mime-type Makefile returns text/plain, which is already included in ~/.local/share/applications/defaults.list. However file --mime-type somefile also returns text/plain but is opened with Vim. I use Debian unstable.
You should take a look in ~/.local/share/applications/defaults.list under [Default Applications]. There you should set the text/plain to point to the .desktop entry for vim, which is usually located in /usr/share/applications/. E.g: text/plain=gvim.desktop
Set default application for particular file types in nautilus
1,530,517,786,000
I have noticed that Nautilus (GNOME Files) can extract some RAR files that cannot be extracted using free packages like unrar-free or file-roller via CLI, nor using GUI tools like Engrampa or Xarchiver. Don’t know why exactly. No passwords involved or anything unusual, just (what seems like) regular RAR files. Maybe different formats? Anyway, I’d like to know what (if any) standalone tool does Nautilus use for extracting RAR files so I could do it myself on the command line. I only use Debian free repositories, so I guess it should be a free package... This is my first question, let me know if I should improve anything. Thanks!!
Nautilus uses libarchive to process archives; this supports some RAR formats without any external helpers. bsdtar is a command-line tool using the same library; in Debian it’s packaged as libarchive-tools.
What free tool does Nautilus use to extract RAR files?
1,530,517,786,000
I see Ubuntu screenshots showing that one can right-click an ISO, and have an option to "Open with Archive Mount". How do I get that running elsewhere where it isn't default (Debian in my case)? This is so as to avoid having to use the command-line to loop-mount it. Note that I use GNOME 2.30.
I found this feature request which suggests that it is part of the nautilus package: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=529297 I found the file "mount-archive.desktop" at: http://bazaar.launchpad.net/~ubuntu-branches/ubuntu/natty/nautilus/natty/annotate/head:/debian/mount-archive.desktop On my Ubuntu PC it is at /usr/share/applications/mount-archive.desktop
How to get Nautilus to "Open with Archive Mounter"?
1,530,517,786,000
Chrome offers a menu for each downloaded item, in which one can Show in Folder the item. This menu-command automatically launches Nautilus at the desired location. Nice. However, now my main desktop management is Fluxbox. So, when Nautilus wakes up, it just replaces my background, and kills all my fluxbox menus, (i am left with an almost empty gtk menus). In such circumstance, I must use ~$ killall nautilus to get my fluxdesktop back to normal. This is really funny, but only a dozen of times. I was wondering if I could parametrize Chromium in some way under linux so as to make Chromium not call Nautilus, but rather call Thunar or PcManFm which are the two file system management I use. I use Ubuntu 12.04 for info.
Nautilus seems to be the default application to open a directory, more precisely to open a file of type inode/directory. Furthermore Nautilus has the bad habit to mess with the desktop as you have noticed. What you need to do is to tell the system what default application to use to open a directory and chromium will obey. In this example I use midnight commander as file manager of choice, feel free to change it to your preferred one. First you need to ensure that there's a .desktop file which is required by the XDG specification. For GUI file managers the chance is good that there already is a suitable .desktop file, for terminal applications usually you have to create your own one. Check out the directory /usr/share/applications for existing files. Create a file ~/.local/share/applications/midnight-commander.desktop with the following content: [Desktop Entry] Name=Midnight Commander Exec=mc %U Terminal=true StartupNotify=false Type=Application MimeType=inode/directory The next step is to register this application with the inode/directory MIME type: xdg-mime default midnight-commander.desktop inode/directory You can confirm a successful registration with xdg-mime query default inode/directory which should output midnight-commander.desktop. Now you can click on “Open in Folder” in chromium and a terminal should pop up with midnight commander opened in the directory. No need to even restart the desktop session or the browser. If you want to use Nautilus just without having it to mess with your desktop, you need to copy and rename the corresponding .desktop file from /usr/share/applications and replace nautilus %U with nautilus --no-desktop %U
Change Chromium from automatically launches Nautilus with the Show In Folder command
1,530,517,786,000
I am using Nautilus now, and back then when i was using Ubuntu i could right-click on an ISO file and automount it without the need to issue any command. But now i am using Nautilus in Archlinux and it seems that it doesn't have the needed plugin for that to work, is anybody know what is the package name, or what should i do in order to get that feature ?
I have found a Great guide on how to do that, (it is in the Arch wiki but it works with all nautilus at every distro). Install the nautilus-actions and fuseiso packages with you package manager. Create a file with the a name like nautilus-actions-iso-mount.sh where ever you want (e.g /usr/bin/), and paste in it the following: #! /bin/bash FILE=basename "$1" MOUNTPOINT="$HOME/Desktop/$FILE" fuseiso -p "$1" "$MOUNTPOINT" Create another file with a name like nautilus-actions-iso-umount.sh where ever you want (e.g /usr/bin/), and paste in it the following: #! /bin/bash FILE=basename "$1" MOUNTPOINT="$HOME/Desktop/$FILE" fusermount -u "$MOUNTPOINT" Make the files executeables: with chmod +x /<path_to_scripts>/nautilus-actions-iso-* And finelly do the follwing in order to add the scripts you have created before to your nautilus menu: start nautilus-actions-config (System -> Preferences -> Nautilus Actions Configuration). Add a new action with the following settings: Label: Mount ISO Icon: A symbol of your choice (eg: gtk-cdrom) Path: /<path_to_scripts>/nautilus-actions-iso-mount.sh Parameters: %F Working directory: %d Basenames: *.iso ; *.nrg ; *.bin ; *.img ; *.mdf (for each add a seperated entry) Match case: "must match one of" Mimetypes: */* With this action you can mount ISO-images to your Desktop. It will create an folder in ~/Desktop with the name of the iso. fuseiso will mount the iso to this folder. And a second one: Label: Unmount ISO Icon: A symbol of your choice (eg: gtk-cdrom) Path: /<path_to_scripts>/nautilus-actions-iso-umount.sh Parameters: %F Working directory: %d Basenames: *.iso ; *.nrg ; *.bin ; *.img ; *.mdf (for each add a seperated entry) Match case: "must match one of" Mimetypes: */* This second action will unmount the mounted iso and remove the folder from the desktop. Sometimes you have to logout to be able to mount any image of the given types simply by right clicking it in Nautilus and selecting Mount ISO. To unmount it again, just right click the corresponding folder on your desktop and select Unmount ISO. And there you are, it works flawlessly. I have tested it with Gnome 3.
Nautilus, mount ISO file with right-click menu
1,530,517,786,000
This has been discussed before here. What I'd like to know is how to turn these: Recursive chmod only files within this folder: find . -type f -exec chmod 0600 {} \; Recursive chmod only folders within this folder: find . -type d -exec chmod 0755 {} \; into a bash script, so it could be something like: For files: rchmodf 744 . For directories: rchmodd 755 . and... also maybe into a nautilus right click menu option if that's possible.
Here's a script you can call by passing the mode as the first argument and one or more directory names as subsequent arguments. Under Linux, if you don't pass any directory name, it'll be as though you passed . (the current directory). Name this script rchmodf, make it executable (chmod a+rx /path/to/rchmodf) and put it somewhere on your $PATH. #!/bin/sh mode=$1; shift find "$@" -type f -exec chmod "$mode" {} + Explanations: mode=$1; shift sets the variable mode to the first argument of the script and removes that first argument from the list. "$@" expands to the list of all arguments. If you like, you can make a script that accepts both a directory mode and a file mode. #!/bin/sh dir_mode=$1; shift file_mode=$1; shift find "$@" -type d -exec chmod "$dir_mode" {} + -o -type f -exec chmod "$file_mode" {} + Note that 744 isn't a useful file mode; 644 (user-writable and world-readable) and 755 (also world-executable) are much more common. Also, changing every file in a tree to be executable or not to be executable is rarely useful; you'll probably want to call this script with arguments like +rX (capital X, to set the executable bit only for directories and for files that are already executable). In fact, the X symbolic mode is probably what you were after with these scripts: chmod -R +rX .. With bash or zsh, there's another way to act recursively but on directories only. For bash, you need version 4 and to run shopt -s globstar first. chmod a+rx **/*/ In zsh, you can act on files only by suffixing (.): chmod a+r **/*(.). I'll pass on the Nautilus question.
Recursive chmod only folders or only files via script or nautilus menu?
1,530,517,786,000
GTK applications mark files as recently used by adding them to the XML in ~/.local/share/recently-used.xbel, but I am frequently working with files from terminal-driven applications like latex, and these are not marked in the GTK list and hence not available from the "Recent" bookmark in GUI file browsers/pickers etc.. Is there a CLI command I can use to explicitly add files to the Recent list, for smoothing operations between the terminal and GUI sides of my Linux usage? Either an official way, or a fast & simple hack with the side-effect of writing to the recently-used.xbel file!
The following Python script will add all the files given as arguments to the recently-used list, using GIO: #!/usr/bin/python3 import gi, sys gi.require_version('Gtk', '3.0') from gi.repository import Gtk, Gio, GLib rec_mgr = Gtk.RecentManager.get_default() for arg in sys.argv[1:]: rec_mgr.add_item(Gio.File.new_for_path(arg).get_uri()) GLib.idle_add(Gtk.main_quit) Gtk.main() The last two lines are necessary to start the Gtk event loop; if you don’t do that, the changed signal from the manager won’t be handled, and the files won’t be added to the recently-used list.
Can I mark files as recently-used from the command line?
1,530,517,786,000
Does anyone know of a way to assign a shortcut key combination to the menu items in the context menu that pops up in nautilus when you click on a file?
There already is one. It's Shift+F10. This is a standard keystroke and works in many apps. And of course many keyboards have a dedicated context-menu key; it's the complement of the Windows key. Either should work. Both do for me on Ubuntu 14.04 with Unity & Nemo.
Is there a way to assign a shortcut key to nautilus' right click context menu?
1,530,517,786,000
Where are these special URIs used in Nautilus defined in Ubuntu? recent:/// trash:/// x-nautilus-desktop:/// computer:/// burn:/// These can instantly open special locations in Nautilus by typing them in the path bar. And why doesn't these work when I open Nautilus as root (is first time when I see that root doesn't have privileges to do something)?
EDIT After doing some more digging I found that you can launch nautilus as root and get access to the special URIs by using dbus. The command would be sudo dbus-launch nautilus And then the URIs are all available. To be honest I am not 100% why this works but some of the original information I found below may still be helpful. The reason those URIs exist is because Nautilus uses a virtual file system called Gnome Virtual File System (gvfs) which is built on top of another virtual file system called FUSE. Specifically those URIs are configured in the /usr/lib/gvfs/ directory named gvfsd-*. These are binary files so don't try and edit them. When you mount a Samba share using Nautilus it uses the gvfsd-mount command (stored in /usr/bin) to mount the share you specify. The share is then mounted in /run/user/<UID>/gvfs/ where is your user id (typically 1000 for single user systems). As for root being able to use these URIs, Ubuntu, and I'm assuming other distributions, configures fuse so that root cannot use the virtual file system for security reasons. You'll notice in the /run/user folder there is no 0 directory for the root user. The /etc/fuse.conf file by default is not configured to allow the root user access. This means that if your user mounts a share even the root user cannot view the share without configuring Fuse to allow it. I have not actually tested giving root access to the Fuse file system or special URIs but you may have luck configuring it as described in this link or reading through the Fuse man page. Sorry for the RTFM answer, but I couldn't find a definitive solution and it depends on what version of Ubuntu you are on as some of the directories/commands changed in recent versions.
Nautilus special URIs
1,530,517,786,000
when I use mouse to click and drag it doesn't drag but selects multiple files instead. I use latest stable arch with Wayland and Gnome.
I found the problem, I unknowingly enabled the experimental new views option. Disabling it fixed the issue.
Drag and drop not working in Gnome3 file manager, selects multiple files instead
1,530,517,786,000
I have a bunch of directories at the same level and would like to sort them according to the last modified date of the content (recursive) inside them. However, in nautilus, it looks like the directories' "last modified date" are only updated if new files are created inside. Is there anyway to show the recursive "last modified date" of these directories? Edit: I only needed to know the date to the nearest minute. So I've adopted Stéphane Chazelas's solution with minor modifications to reduce the clutter: find . -mindepth 2 -type f -printf '%TF %TH:%TM/%P\0' | LC_ALL=C sort -zt/ -k2,2 -k1,1r | LC_ALL=C sort -t/ -zmsuk2,2 | LC_ALL=C sort -z | cut -zd/ -f1,2 | tr '\0/' '\n\t'
The last modification time of a directory (think like phone directory, not folder) is the time it was last modified, like when an entry was removed, added or edited in that directory. To find out the newest regular file recursively in it, you would need to read the contents of that directory and every directory within and for each file, check the file's modification time. That's a costly thing to do, I wouldn't expect any file manager application to do it. You could however script it. With the GNU implementations of find and sort (and any Bourne-like shell), you could do: TZ=UTC0 find . -mindepth 2 -type f -printf '%TFZ%TT/%P\0' | LC_ALL=C sort -zt/ -k2,2 -k1,1r | LC_ALL=C sort -t/ -zmsuk2,2 | LC_ALL=C sort -z | tr '\0' '\n' Which would give something like: 2020-02-08Z19:17:22.3588966190/Scripts/.distfiles 2020-02-09Z09:25:37.5336986350/StartupFiles/zshrc 2020-07-26Z20:33:17.7263164070/Misc/vcs_info-examples 2020-07-26Z20:33:17.7463157170/Util/ztst-syntax.vim 2020-08-22Z18:06:17.9773156630/Functions/VCS_Info 2020-08-30Z11:11:00.5701005930/autom4te.cache/requests 2020-08-30Z11:11:31.5245491550/Config/defs.mk 2020-08-30Z11:11:31.6085449480/Etc/Makefile 2020-08-30Z11:12:10.9305773600/INSTALL.d/share/zsh/5.8.0.2-dev/help 2020-10-22Z05:17:15.3808945480/Completion/Base/Utility 2020-10-22Z05:17:15.3928938520/Doc/Zsh/zle.yo 2020-10-22Z05:17:15.3968936190/Src/zsh.h 2020-10-22Z05:17:15.3968936190/Test/D02glob.ztst 2020-10-22Z05:17:15.4168924590/.git/logs/refs/heads/master That is, giving the newest regular file in each directory with its timestamp. Directories without regular files in them are not shown. To only see the list of directories, insert a cut -zd/ -f2 | before the tr command. For a prettier output like in the zsh approach, you could replace the tr command with: LC_ALL=C gawk -v RS='\0' -F / '{ dir = $2; mtime = $1 sub("[^/]*/[^/]*/", "") printf "%-20s %s (%s)\n", dir, mtime, $0}' While we're at using gawk, we could also tell find to print the timestamp as a fractional Unix epoch time and gawk reformat it in local time: find . -mindepth 2 -type f -printf '%T@/%P\0' | LC_ALL=C sort -zt/ -k2,2 -k1,1rn | LC_ALL=C sort -t/ -zmsuk2,2 | LC_ALL=C sort -zn | LC_ALL=C gawk -v RS='\0' -F / '{ dir = $2; split($1, mtime, ".") sub("[^/]*/", "") printf "%-20s %s (%s)\n", dir, strftime("%FT%T." mtime[2] "%z", mtime[1]), $0}' Which would give an output like: cross-build 2019-12-02T13:48:33.0505299150+0000 (cross-build/x86-beos.cache) m4 2019-12-02T13:48:33.4615093990+0000 (m4/xsize.m4) autom4te.cache 2019-12-02T13:50:48.8897482560+0000 (autom4te.cache/requests) CWRU 2020-08-09T17:17:21.4712835520+0100 (CWRU/CWRU.chlog) include 2020-08-09T17:17:21.5872807740+0100 (include/posixtime.h) tests 2020-08-09T17:17:21.8392747400+0100 (tests/type.right) .git 2020-08-09T17:17:21.8472745490+0100 (.git/index) doc 2020-08-09T17:35:35.1638603570+0100 (doc/Makefile) po 2020-08-09T17:35:35.3758514290+0100 (po/Makefile) support 2020-08-09T17:35:36.7037954930+0100 (support/man2html) lib 2020-08-09T17:35:42.3755564970+0100 (lib/readline/libhistory.a) builtins 2020-08-09T17:35:42.5035511020+0100 (builtins/libbuiltins.a) examples 2020-08-09T17:35:47.1513551370+0100 (examples/loadables/cut) INSTALL.d 2020-08-09T17:35:47.3993446790+0100 (INSTALL.d/lib/bash/cut)
sort directories by last modified content (recursive)
1,530,517,786,000
When I filter-as-you-type the file list in Nautilus, the result list gets sorted "by relevance" by default. How is this defined? What makes a file more relevant than another file? Can I change this default sorting of the result list to alphabetical sorting, aka "A-Z"? (I should note that I have export LC_ALL=C.UTF-8 in my .bashrc, to have Nautilus respect punctuation in file names) I am using Fedora Silverblue 37, with Gnome 43
Regarding the "relevance" algorithm, I looked at the Nautilus source code, and it appears that a file's relevance score is computed as a sum of scores based on how recently the file was accessed or modified, its "proximity" (how close the file is to the current directory in the file system hierarchy), and how well the search term matches. This last score is called fts_rank, which I assume means "full text search rank", meaning it will search the contents of the file as well. The recency score goes up to a maximum of 100, and the proximity score can be at most 10,000. The FTS score I don't have any values for, but presumably it should have a pretty large weight when determining the total score. The exact formula can be seen here.
What defines the "by relevance" sort criteria in Nautilus, and can it be changed?
1,530,517,786,000
I am using Linux Mint 14 Nadia . Earlier whenever I right clicked any folder I got options like Extract it, Compress etc. But now I am not getting them . Probably I changed/deleted some of the utilities . I have nautilus installed on my system . Is there any way I can get those 2 features back in the options list when I right click any folder ?
From the Linux Mint Forum I found the following post, Extract, Compress in right-click menu. According to that post you have 2 options: Use Caja instead of Nautilus (I believe Caja is just a fork of Nautilus) Install File Roller + xarchiver According to that post these are the steps required to install File Roller: open synaptic manager search for file roller select file roller to install search for xarchiver select xarchiver to install restart
How to get extract/compress option on right clicking?
1,530,517,786,000
I've installed the latest Scientific Linux 6. But when I opened the included Nautilus file manager, there is no file tree sidebar and no toolbar, nor status bar. How do I activate them?
For the sidepane, you can either hit F9 or go to View and select sidepane. Similarly, for the toolbar and status bars, select them from the View menu.
How to show Nautilus toolbar and file tree sidebar?
1,530,517,786,000
Currently I'm using i3 window manager (but I guess that this applies to other non-standard window managers as well). Whenever I run nautilus it also starts a full screen desktop, which I have to close. Possible solution is to start nautilus with: nautilus --browser --no-desktop, which solves this problem only partially, as sometimes nautilus is launched automatically by other applications and in this case it would be launched without --browser --no-desktop options. Is there any gnome3 config option that allows me to suppress desktop launching?
Yes, there is a dconf value that controls this. Run the following command to disable drawing of the desktop by Nautilus: gsettings set org.gnome.desktop.background show-desktop-icons false Source: https://askubuntu.com/a/237984/81372
Launching nautilus file browser launches gnome desktop, how to suppress it
1,530,517,786,000
It looks like I can get to the waste-basket through nautilus, but when I look at the location given by properties, I see "trash:///". But I can't "cd trash:///". Where is the waste-basket? And in general, if I can find a file in nautilus, how do I get there from terminal? I've had some similar issues in the past with mounted media as well, so a general answer would be greatly appreciated. In case it is relevant, I'm using PinguyOS.
trash:// is a protocol, not a location. A post on AskUbuntu says it should be in ~/.local/share/Trash. Try there.
How to find Nautilus wastebasket in the file system
1,530,517,786,000
I don't know what changed and I don't know how to set it back, but now Super+E launches baobab instead of Nemo. I have check the keyboard - shortcuts configurations. and Launchers/Home Folder is associated to Super+E. There is no custom shortcuts. So my issues are of 2 types: the shortcut configuration seems correct in cinnamon panel, still it launches the wrong application(baobab), which doesn't appear in said configuration. What can I check and correct to get back default behavior: Super+E => Home folder? A package name to reinstall the default bindings would be ok as well. EDIT: when downloading with Firefox, "show in folder" menu trigger nemo, but When downloading with chrome, "show in folder" trigger baoab. So chrome seem to use the same information as cinnamon to launch nemo, but which one ? PS: So far I didn't found any answer that solve this specific issue (including on askubuntu.com. lsb_release -a ouputs No LSB modules are available. Distributor ID: LinuxMint Description: Linux Mint 18 Sarah Release: 18 Codename: sarah
I finally found the issue in /usr/share/applications/mimeinfo.cache, with the following entry: inode/directory=org.gnome.baobab.desktop;nemo.desktop; changing it back to: inode/directory=nemo.desktop; solved the issue. It's the chrome behavior and the answer to Change Chromium from automatically launches Nautilus with the Show In Folder command that get me to the solution. EDIT: /usr/share/applications/mimeinfo.cache is regenerated from .desktop files present in folder /usr/share/applications/. Initial error is in org.gnome.baobab.desktop and reappear each time mimeinfo.cache is regenereated. It is not clear how to fix this.
Cinnamon: lost default nemo launch for shortkey win + E
1,530,517,786,000
Running other desktop environments than Unity or Gnome with a different file manager than Nautilus, it might be a good idea to install Dropbox without Nautilus. But advice on Dropbox involves installing Nautilus too. Nautilus has conflicts with some file managers, as it takes over the desktop (workspace) and the file manager integration of many programs. In Xubuntu with Thunar this is a big problem. Also with Cinnamon and Nemo in Linux Mint Nautilus changed the desktop and took over integration with Firefox. But it seemed ok on Elementary OS. Fewer problems on Lubuntu too, if I am not mistaken. I want to ask for other people's experience on installing Dropbox without Nautilus on various Linux systems and find if there's one single way to do it or system specific ways etc. Trying to follow this advice on Linux Mint (sudo apt-get install dropbox python-gpgme) it had installed Nautilus already! Update after answer on Linux Mint. As I am already using other Linux distros and will in the future, I expect other solutions for a few other distros, DE, and file managers. I will also update my answer to add them if I can.
Installing the Dropbox deb files from the Dropbox website (Ubuntu or Debian, I have not tested others) will not install Nautilus, although gdebi says a Nautilus extension will be installed. Installing just Dropbox from Ubuntu sources in Synaptic or in terminal will neither install Nautilus. File manager integration is also provided in Synaptic (Ubuntu sources) with the packages nemo-dropbox and caja-dropbox, as well as with libnet-dropbox-api-perl. After installing Dropbox with Nautilus (sudo apt-get install dropbox python-gpgme) Un-installing Nautilus works without glitches but there is limited integration with the file manager at this point, maybe opening Dropbox folder from the tray icon, but without Dropbox features in the file manager (folder symbols and menu integration). Tested with Cinnamon and Nemo. For Nemo/Cinnamon. There is nemo-dropbox. "Nemo dropbox is an extension that integrates the dropbox web service with your cinnamon desktop. - installing this package will download the proprietary dropbox binary from dropbox.com." That should mean that the simplest solution of installing Dropbox without Nautilus for Nemo file manager is to just install the extension nemo-dropbox: that will install Dropbox with Nemo integration. But that is limited to Nemo. For Caja file manger: caja-dropbox. "Caja dropbox is an extension that integrates the dropbox web service with your mate desktop. -- to use this package you need to install the proprietary dropbox package from https://www.dropbox.com/install." So, you need to have Dropbox before installing this. As far as I can tell, libnet-dropbox-api-perl is enough in order to have file manager integration (tested with Nemo without nemo-dropbox). For Dolphin: Based on this KDE-reddit post: Install dolphin-plugins, then enable the Dropbox service under Configure Dolphin... > Services > Dropbox. This adds the option "Move to Dropbox" for non-dropbox-ed items; inside Dropbox folder it shows this Among the numerous Dolphin service menus that are included in the KDE-Services package there is one that provides Dropbox options. Check-marks on dropbox items may be absent with icon-sets lacking the proper files at ICONSET/emblems/scalable. Copying the files from a different icon-set will fix this problem.
How to install Dropbox (and have Dropbox file manager integration) without Nautilus?
1,530,517,786,000
When searching for files, I often prefer using locate (because of the speed). However, I end up opening a terminal just for that purpose and then closing it again. Not a big problem for me, but my girlfriend often forgets command names. Is there a way to have Nautilus to use mlocate for searching? Ideally, I'd love to have the results displayed separately (because a file in locatedb may no longer exist), but I'm ok if it doesn't. Failing that, is there some GUI to locate?
I've not seen a way to incorporate these results into Nautilus, but there are GUIs for search in mlocate's database. The one that I'm most familiar with is called catfish. It's generally in most of the standard distros' repos. The main website is here, titled: Catfish is a versatile file searching tool.. The project's Launchpad site is another additional resource if needed. excerpt from website Catfish is a search GUI powered by locate and find behind the scenes, with autocompletion from Zeitgeist and locate. The advanced options allow filtering by date and file type. The interface is intentionally lightweight and simple, using only GTK+. Example Search                            Results      Advanced filtering      References GTK Frontend for locate
Is there a way to have Nautilus include mlocate in the results?
1,530,517,786,000
Elementary OS uses a program called files as the default file manager. I would like to use Nautilus as my default file manager as used in Ubuntu 12.04 . I have GNOME Nautilus 3.4.2 installed on my machine, but however the only way to invoke this file manager is using the terminal. How do I set this as default and have an icon in the application menu. The Desktop Entry, nautilus.desktop looks like this. [Desktop Entry] Name=Files Comment=Access and organize files Exec=nautilus %U Icon=system-file-manager Terminal=false Type=Application StartupNotify=true OnlyShowIn=GNOME;Unity; Categories=GNOME;GTK;Utility;Core; MimeType=inode/directory;application/x-gnome-saved-search; X-GNOME-Bugzilla-Bugzilla=GNOME X-GNOME-Bugzilla-Product=nautilus X-GNOME-Bugzilla-Component=general X-GNOME-Bugzilla-Version=3.4.2 Actions=Window; X-Ubuntu-Gettext-Domain=nautilus [Desktop Action Window] Name=Open a New Window Exec=nautilus OnlyShowIn=Unity; Edit: Updated the Desktop entry to get answer for adding Nautilus to Application menu.
eOS should support xdg-mime command which you can use to change the default file manager. Try these commands: # what's the current default file manager? xdg-mime query default inode/directory # set nautilus as a default file manager xdg-mime default nautilus.desktop inode/directory application/x-gnome-saved-search
How do I set Nautilus as default file manager in Elementary OS
1,530,517,786,000
I have a question for some time in my head: I have an external hard drive, when I want to dismount it I simply give in the icon that says: "Remove unit safely" in the Nautilus (use Nautilus from Gnome 3.14 in Debian 8), but in reality what is the process behind? It's a way to see what really happens? Some kind of logs? I imagine that the first process is umount /wherever/its/mount, but I noticed that when I unmount it using umount the led of the external hard drive stays on (when Windows OS turn off the led), so: the umount command should also cuts off the power of the USB port where the hard drive is connected? Or is another command doing this? Thanks
umount command itself doesn't cut off power to the drive, mounting really means linking a filesystem on drive with a directory, so unmounting just does that - unlinks a mount from particular directory; and as far as Nautilus file manager goes that's not what it uses under the hood, in fact it uses GMount objects from the standard Gio API for all GNOME-related type of development. Without confusing you too much, let me explain it in terms of source code and documentation. Brief search through source code reveals that in nautilus-file-operations.c file, the nautilus_file_operations_unmount_mount_full function calls do_unmount, which calls g_mount_eject_with_operation function. That last one belongs to GMount portion of API. Ejecting would involve sync-ing remaining data that needs to be written to the mount, unmounting a volume or drive, and then powering it off in case of USB drive or optical disk. If you're expecting a shell command that can power off a drive just like in Nautilus, there is one via udisks or udisksctl, and if I'm not mistaken udisksctl comes with OSes that use systemd (but don't quote me on this last statement, that's an opinion only). That makes use of UDisks2, which is actually another API for handling drives and volumes via D-Bus interface; it is actually quite nice and I've used for developing my own indicator on Ubuntu. So TL;DR: Nautilus uses Gio API to handle mounts, but doesn't call any external or standalone command-line utility There is command-line equivalent that performs similar operations as Nautilus You can always write your own using Gio API, UDisks API, or call external udisks or udisksctl command. See also: https://askubuntu.com/q/5845/295286
How works the "eject usb driver" from Gnome?
1,291,124,878,000
I find that ctrl clicking a file:///full-path-to-file hyperlink printed by a program in the terminal e.g. to stdout, assumes a full path in order to open the file in the default editor configured. Is there a way to equivalently have hyperlinks that are relative paths, in the terminal? what might be the necessary syntax for that?
The inherent problem with relative paths is: relative to what? Relative to the working directory of the immediate child of the terminal emulator (typically: your shell) at the time of ctrl-clicking would be pretty much useless, all your links would break as soon as you cd away. What you'd need at the very least is to be relative to the directory of the child process at the time the text is emitted. This raises some problems. First, the terminal emulator needs to be aware of its child's working directory (via e.g. the OSC 7 sequence, or some closer shell integration like in iTerm2), which then could still be incorrect during the execution of utilities that internally change their working directory (e.g. make). Moreover, emulators would need to remember this information for each and every printed character cell which could be quite expensive. You might be interested in a pretty new feature of certain terminal emulators: explicit hyperlinks. Using a special sequence, the visible text can be turned into a hyperlink pointing to any location. The target of the hyperlink still needs to be specified as an absolute URI, yet the displayed text could be whatever you want (maybe just some relative pathname, or even something utterly different).
Terminal-clickable relative file path hyperlink
1,291,124,878,000
I have a network with several RHEL6 workstations and RHEL IdM Server (a.k.a. FreeIPA) as a domain controller. Every LDAP user can log into the every workstation. When the user is logging in for the first time, SSSD creates $HOME/$USER directory for them. I would like to set customized Gnome configuration for each user with this command: nautilus-actions-new --label="Shred" --tooltip="Purge file" --icon="gtk-dialog-warning" --toolbar-label="Shred" --command="shred" --parameters="-f -u -v -z %f" -g As I know, Gnome settings are stored locally in the homedir of each user and there is no possibility to set them globally for every user. So I wonder are there any hooks to SSSD's new homedir creating event in order to run the mentioned command?
Store the files in the skeleton directory. When a new user is created, the files in that directory should be copied to their home directory. The directory is normally /etc/skel.
How to run script when SSSD creates home directory for a new user
1,291,124,878,000
Whenever I have files cut or copied to the clipboard and want to paste them inside a folder using the mouse in the 'Files' application (default file browser in Ubuntu) I have to first change from list view to icon view then scroll to the end of the list of icons to find a 'hole' to click without selecting another file so I can find paste on the menu. Am I missing something or is the application really this flawed?
You can go to parent directory right click on desired directory and select "Paste into folder" or create a new tab then hold the shift and right click anywhere you want to paste. The other option is to use drag and drop or keyboard shortcuts (which you already know about it).
How to drop/paste files into a folder using the 'Files' application (Nautilus)?
1,291,124,878,000
I am copying some files from an external drive to my desktop running Ubuntu. I can see the "File Operations" dialog which shows copying process. How do I find this particular process in ps aux | grep command? I thought it would be some cp command but there is no cp command running! So how does this copying work? Please provide any pointers.
The process name is nautilus. Nautilus contains its own code to copy files, this code is executed inside the nautilus process, not in a subprocess. You can see for yourself what subprocesses Nautilus runs by logging its system calls with strace: strace -f -o /tmp/nautilus.strace nautilus The clone system call creates new processes (it's a generalization of fork). The execve system call runs another program in the same process. Running another program thus entails clone followed by execve. You can quickly see what programs Nautilus executes (or tries to) with grep execve /tmp/nautilus.strace You'll find that Nautilus creates subprocesses for some things such as previewing the content of certain types of files, but it does the file copying on its own.
What is the actual process name when nautilus is copying files?
1,291,124,878,000
When I copy, move, or delete a file in Nautilus or using the corresponding commands (cp, mv, or rm) does the same tool perform the action behind the wraps? I ask because nautilus tends to hang on big files or too many files. I have the impression that it's not that efficient.
No it doesn't just make calls to cp, mv, etc. Rather, it makes calls to a GTK+ library that contains wrapper functions around C/C++ system libraries that also contain functions. It is these C/C++ functions that are shared across Nautilus and commands such as cp, mv, etc. Example You can use the system tracing tool strace to attach to a running nautilus process like so: $ strace -Ff -tt -p $(pgrep nautilus) 2>&1 | tee strace-naut.log Now if we perform some operations within Nautilus we'll see the system calls that are being made. Here's a sampling of the logs during the copy/paste of file /home/saml/samsung_ml2165w_print_drivers/ULD_Linux_V1.00.06.tar.gz. [pid 25897] 22:28:36.909183 lstat("/home/saml/samsung_ml2165w_print_drivers/ULD_Linux_V1.00.06.tar.gz", {st_mode=S_IFREG|0664, st_size=16090900, ...}) = 0 [pid 25897] 22:28:36.909259 access("/home/saml/samsung_ml2165w_print_drivers/ULD_Linux_V1.00.06.tar.gz", R_OK) = 0 [pid 25897] 22:28:36.909302 access("/home/saml/samsung_ml2165w_print_drivers/ULD_Linux_V1.00.06.tar.gz", W_OK) = 0 [pid 25897] 22:28:36.909339 access("/home/saml/samsung_ml2165w_print_drivers/ULD_Linux_V1.00.06.tar.gz", X_OK) = -1 EACCES (Permission denied) [pid 25897] 22:28:37.580109 lstat("/home/saml/samsung_ml2165w_print_drivers/ULD_Linux_V1.00.06.tar.gz", {st_mode=S_IFREG|0664, st_size=16090900, ...}) = 0 [pid 25897] 22:28:37.580169 access("/home/saml/samsung_ml2165w_print_drivers/ULD_Linux_V1.00.06.tar.gz", R_OK) = 0 [pid 25897] 22:28:37.580215 access("/home/saml/samsung_ml2165w_print_drivers/ULD_Linux_V1.00.06.tar.gz", W_OK) = 0 [pid 25897] 22:28:37.580249 access("/home/saml/samsung_ml2165w_print_drivers/ULD_Linux_V1.00.06.tar.gz", X_OK) = -1 EACCES (Permission denied) [pid 26667] 22:28:39.222446 lstat("/home/saml/samsung_ml2165w_print_drivers/ULD_Linux_V1.00.06.tar.gz", {st_mode=S_IFREG|0664, st_size=16090900, ...}) = 0 [pid 26667] 22:28:39.222981 lstat("/home/saml/samsung_ml2165w_print_drivers/ULD_Linux_V1.00.06.tar.gz", {st_mode=S_IFREG|0664, st_size=16090900, ...}) = 0 [pid 26667] 22:28:39.223201 lstat("/home/saml/samsung_ml2165w_print_drivers/ULD_Linux_V1.00.06.tar.gz", {st_mode=S_IFREG|0664, st_size=16090900, ...}) = 0 [pid 26667] 22:28:39.223304 lstat("/home/saml/samsung_ml2165w_print_drivers/ULD_Linux_V1.00.06.tar.gz", {st_mode=S_IFREG|0664, st_size=16090900, ...}) = 0 [pid 26667] 22:28:39.223397 lstat("/home/saml/samsung_ml2165w_print_drivers/ULD_Linux_V1.00.06.tar.gz", {st_mode=S_IFREG|0664, st_size=16090900, ...}) = 0 [pid 26667] 22:28:39.223444 open("/home/saml/samsung_ml2165w_print_drivers/ULD_Linux_V1.00.06.tar.gz", O_RDONLY) = 46 [pid 26667] 22:28:39.223658 open("/home/saml/samsung_ml2165w_print_drivers/ULD_Linux_V1.00.06 (copy).tar.gz", O_WRONLY|O_CREAT|O_EXCL, 0664) = 47 [pid 25897] 22:28:39.235249 read(14, "\f\0\0\0\0\1\0\0\0\0\0\0000\0\0\0ULD_Linux_V1.00."..., 1024) = 96 [pid 26667] 22:28:39.388744 lstat("/home/saml/samsung_ml2165w_print_drivers/ULD_Linux_V1.00.06 (copy).tar.gz", <unfinished ...> [pid 26667] 22:28:39.388853 chmod("/home/saml/samsung_ml2165w_print_drivers/ULD_Linux_V1.00.06 (copy).tar.gz", 0100664 <unfinished ...> [pid 26667] 22:28:39.388959 stat("/home/saml/samsung_ml2165w_print_drivers/ULD_Linux_V1.00.06 (copy).tar.gz", <unfinished ...> [pid 26667] 22:28:39.389061 utimes("/home/saml/samsung_ml2165w_print_drivers/ULD_Linux_V1.00.06 (copy).tar.gz", {{1388460519, 222672}, {1384901700, 0}} <unfinished ...> [pid 26667] 22:28:39.391274 lstat("/home/saml/samsung_ml2165w_print_drivers/ULD_Linux_V1.00.06 (copy).tar.gz", <unfinished ...> [pid 26667] 22:28:39.391848 access("/home/saml/samsung_ml2165w_print_drivers/ULD_Linux_V1.00.06 (copy).tar.gz", R_OK <unfinished ...> [pid 26667] 22:28:39.391955 access("/home/saml/samsung_ml2165w_print_drivers/ULD_Linux_V1.00.06 (copy).tar.gz", W_OK <unfinished ...> [pid 26667] 22:28:39.392059 access("/home/saml/samsung_ml2165w_print_drivers/ULD_Linux_V1.00.06 (copy).tar.gz", X_OK <unfinished ...> [pid 26667] 22:28:39.392734 lgetxattr("/home/saml/samsung_ml2165w_print_drivers/ULD_Linux_V1.00.06 (copy).tar.gz", "security.selinux" <unfinished ...> The system calls, lstat, access, open, read, etc. are the lower level calls that would be in common.
Are nautilus and command-line commands the same?
1,291,124,878,000
This was easy in Thunar, but now I'm on a machine where I'm trying to do everything in the Gnome desktop world. In Nautilus, I'm in some deep-down folder. How do I open an xterm (rxvt, aterm, gnome's terminal app, whichever) with its working directory already set to the location Nautilus is showing?
There is a very useful Nautilus extension called nautilus-open-terminal that does just what you asked. You should find it in the standard repositories. Once installed you should have a "Open in terminal" entry in the File menu.
How to start an xterm from Nautilus, running in the folder I'm viewing?
1,291,124,878,000
I'm using Debian Jessie 64-bit with Gnome 3.14.1. My TIF image files are opening by default in the PDF Viewer, don't ask why. In Nautilus, I right-click on the file, click Open With|Other Application... If I right-click "Image Viewer", there is only "Forget association". Where is the "create default association" button? EDIT I've found a ~/.config/mimeapps.list, which contains image/tiff=eog.desktop; It seems that something else is overriding this configuration. EDIT2 It seems to be /etc/gnome/defaults.list, which contains image/tiff=evince.desktop which is the PDF viewer in question. Removing this line solved this problem. The problem remains, though, if there should be a button "add default" to the image above.
[Debian 10.0.0 Buster + GNOME] I see the same deficient behaviour using 'open with' as you describe. Select any file having the MIMETYPE of interest then right-click -> Properties. Select the 'Open With' tab. And there you should see the Set as default button.
How do I create a default file association in Debian with Gnome?
1,291,124,878,000
I'm on Debian. I have a file called Sóanr.jpg. According to https://emojidissector.com/, this is made of the following code points: S 0053 LATIN CAPITAL LETTER S o 006F LATIN SMALL LETTER O ́ 0301 COMBINING ACUTE ACCENT a 0061 LATIN SMALL LETTER A n 006E LATIN SMALL LETTER N r 0072 LATIN SMALL LETTER R When I create a zip of this file, and then unzip it, the LATIN SMALL LETTER O and the COMBINING ACUTE ACCENT get put together into a new code point: S 0053 LATIN CAPITAL LETTER S ó 00F3 LATIN SMALL LETTER O WITH ACUTE a 0061 LATIN SMALL LETTER A n 006E LATIN SMALL LETTER N r 0072 LATIN SMALL LETTER R This is not what I want. How do I preserve the original unicode code points? EDIT: I was able to successfully zip and unzip following Stephen Kitt's example below. Yay! This is great news. However, I continue to have the above problem when using Nautilus right-click -> Extract Here. If I extract my archive using Nautilus right-click -> Extract Here, my unicode characters come out changed as described above. So I guess Nautilus is not using unzip. (How I create the zip doesn't seem to matter -- either with the zip command or with Nautilus's right-click -> Compress.) The question becomes: Is there a way to create a zip archive so that Nautilus' default unzipping program doesn't clobber my unicodes? (And: How can I figure out what program Nautilus is using to Extract Here?) Before zip: $ ls S* | od -a -t x1 0000000 S o L soh a n r . z i p nl 53 6f cc 81 61 6e 72 2e 7a 69 70 0a After right-click -> Extract Here: $ ls S* | od -a -t x1 0000000 S C 3 a n r . j p g nl 53 c3 b3 61 6e 72 2e 6a 70 67 0a
You don’t need to do anything: $ touch So<0301>anr.jpg $ ls So* | od -a -t x1 0000000 S o L soh a n r . j p g nl 53 6f cc 81 61 6e 72 2e 6a 70 67 0a 0000014 $ zip -9 unitest.zip So* adding: Sóanr.jpg (stored 0%) $ unzip -v unitest.zip | grep Stored | od -a -t x1 0000000 sp sp sp sp sp sp sp 0 sp sp S t o r e d 20 20 20 20 20 20 20 30 20 20 53 74 6f 72 65 64 0000020 sp sp sp sp sp sp sp sp 0 sp sp sp 0 % sp 0 20 20 20 20 20 20 20 20 30 20 20 20 30 25 20 30 0000040 2 - 0 2 - 2 0 2 3 sp 1 2 : 2 6 sp 32 2d 30 32 2d 32 30 32 33 20 31 32 3a 32 36 20 0000060 0 0 0 0 0 0 0 0 sp sp S o L soh a n 30 30 30 30 30 30 30 30 20 20 53 6f cc 81 61 6e 0000100 r . j p g nl 72 2e 6a 70 67 0a 0000106 This shows that the file name is stored as it was created. Extracting the file preserves the name: $ rm So* $ unzip unitest.zip Archive: unitest.zip extracting: Sóanr.jpg $ ls So* | od -a -t x1 0000000 S o L soh a n r . j p g nl 53 6f cc 81 61 6e 72 2e 6a 70 67 0a 0000014 Nautilus doesn’t use unzip to extract archives, it uses libarchive. Other tools which use libarchive exhibit the same issue: $ bsdtar -tf unitest.zip | od -a -t x1 0000000 S C 3 a n r . j p g nl 53 c3 b3 61 6e 72 2e 6a 70 67 0a 0000013 I don’t see any relevant bug filed against libarchive (see the output of ldd /usr/bin/nautilus), you may want to open one after testing whether the latest release still behaves in this way.
How do I create a zip that preserves unicode character composition on linux?
1,291,124,878,000
I have NFS server. I can mount it manually: sudo mount -t nfs myserver:/srv/nfs /mnt But I can also mount it with file managers, as I'm broadcasting its presence using avahi. I can mount it via thunar (xfce's file manager), but I'm not able to access it via GNOME's Nautilus. Nautilus says: Unable to access location: Mountpoint does not exist. GVFS log says: nfs: Added new job source 0x55c37a44e2f0 (GVfsBackendNfs) nfs: Queued new job 0x55c37a43cf30 (GVfsJobMount) nfs: send_reply(0x55c37a43cf30), failed=1 (Mountpoint does not exist) Server side /etc/exports: # /etc/exports - exports(5) - directories exported to NFS clients # # Example for NFSv2 and NFSv3: # /srv/home hostname1(rw,sync) hostname2(ro,sync) # Example for NFSv4: # /srv/nfs4 hostname1(rw,sync,fsid=0) # /srv/nfs4/home hostname1(rw,sync,nohide) # Using Kerberos and integrity checking: # /srv/nfs4 *(rw,sync,sec=krb5i,fsid=0) # /srv/nfs4/home *(rw,sync,sec=krb5i,nohide) # # Use `exportfs -arv` to reload. /srv/nfs 192.168.1.0/24(rw,sync,no_subtree_check,all_squash,insecure) Server side /etc/avahi/services/nfs.service: <?xml version="1.0" standalone='no'?> <!DOCTYPE service-group SYSTEM "avahi-service.dtd"> <service-group> <name replace-wildcards="yes">%h-nfs</name> <service> <type>_nfs._tcp</type> <port>2049</port> <txt-record>path=/srv/nfs</txt-record> </service> </service-group>
I have the same problem and I might have found out why. It might be because of NFSv4 not supported
Can't access NFS via GNOME Nautilus. (Mountpoint does not exist)
1,291,124,878,000
In the Nautilus file manager (Files 3.6.3), when dragging and dropping a file into a directory, the behaviour appears to be dependent on the file-system location of the target folder. (either local or remote) Dragging and dropping to a local directory triggers a "move" of the source item, and this is the behaviour that I am used to and prefer. But if the target directory is a remote directory, for example on an NFS mount, then it triggers a "Copy" action. As it's not immediately obvious from the icon or context that the directory is remote, and further that the copy action might take some time, I am often left with the source files in place, and I don't notice that has happened until later. This is undesirable. I am aware that I can force a "Move" action using a <Shift> and Drag, and also that I can force a move using the mv command line. However I wish to configure Nautilus to attach the "Move" action to the drag and drop of a file to a remote directory. For me, this is the most common use case, and simplest and most efficient way to achieve that. I understand that this choice to default to copy-for-remote-targets may have derived from a desire to ensure the consistency of the operation. However it breaks the abstraction of the common interface provided by the virtual file system. I am looking for the configuration options that control that behaviour.
From Nautilis help Drag files to copy or move Open the file manager and go to the folder which contains the file you want to copy. Click Files in the top bar, select New Window (or press Ctrl+N) to open a second window. In the new window, navigate to the folder where you want to move or copy the file. Click and drag the file from one window to another. This will move it if the destination is on the same device, or copy it if the destination is on a different device. For example, if you drag a file from a USB memory stick to your Home folder, it will be copied, because you're dragging from one device to another. You can force the file to be copied by holding down the Ctrl key while dragging, or force it to be moved by holding down the Shift key while dragging.
Which configuration option controls whether Nautilus "copies" or "moves" a file/folder on drag and drop for a remote target directory?
1,291,124,878,000
I use the Nemo file manager on Linux Mint 19 Tara. Usually I only work with the compact view without thumbnails (see image A), but occasionally I switch to icon view with thumbnails (see image B). To switch from A to B I have to Open the settings Enable thumbnails Change to icon view and to switch back from B to A Open the settings Disable thumbnails Change to compact view I'd like switch by just clicking the icon view (see image 3) or compact view (see image 6) buttons in the toolbar so that I have to click only once instead of seven times. Q: Is there a way to enable thumbnails only in icon view? I already checked for hidden dconf settings but couldn't find any. Maybe there is a plugin for what I need or a simple way to write one. Possible workarounds which would also be acceptable: A toolbar button to toggle thumbnails on/off. Enable thumbnails only for icon sizes > ??px. I always use small icons in compact view and bigger icons/thumbnails in icon view. I'm not interested in showing thumbnails only in certain directories or for certain file types. using another file manger. This question is tagged as nautilus since Nemo is a fork of Nautilus. If there is a solution for Nautilus please post it. I may be able to use that solution for Nemo too.
Starting with Cinnamon 4.0, there is a new thumbnail setting and a new toolbar button. See new features in Linux Mint 19.1: You can configure Nemo to show thumbnails depending on the directory you are browsing. In this mode, a thumbnail toggle button appears in the toolbar and lets you decide whether or not show thumbnails for this particular directory. The new button shows enables/disables thumbnails only for the current directory, but it is built in and probably the simplest way to get something similar to what you want.
Display Thumbnails In Icon View But Not In Compact View
1,291,124,878,000
I use Nautilus 3.10.1 on Trisquel 7.0 GNU/Linux. In context menu, there is no such option like create new file/document. So, I want to add such an option (which may work like that of existing option: New folder). Is there any nautilus plug-in available? or I have Nautilus Action Configuration Tool installed. So, what command/script I can use for this purpose? Further I am also interested in featuring options like: New Writer Document, New Calc Document, etc.
Access Nautilushelp (click on Files on top bar then select Help) and then navigate to Tips and questions > Templates for commonly-used document types: There is something missing from the documentation: you have to add your Templates location to your xdg-user-dirs, e.g. if you set your templates dir as ~/Templates you'll have to add the following line XDG_TEMPLATES_DIR="$HOME/Templates" in ~/.config/user-dirs.dirs. You then follow the help instructions to create templates (e.g. after placing an empty text file named New Text Document and an empty writer document named New Writer Document in Templates you'll get a new context menu option named New Document which will expand to New Text Document and New Writer Document)
Nautilus context menu option to create new file
1,291,124,878,000
I haven't found any solution working so far :( What I've tried so far was follow steps from the manual. First I installed all required packages (at least I think so, naming isn't always the same) . List of packages: pygtk2 (2.24.0-9) python-configobj (4.7.2-7) pygobject2 (2.28.6-11) pygobject3 (3.8.2-6) python-simplejson (3.3.3-1) pysvn (1.7.6-10) subversion-python (1.8.11-1) subversion (1.8.11-1) Second i tried running setup.py install where I was getting error on line 165 when icon cache is deleted and recreated. I couldn't find gtk-update-icon-cache-3.0 executable on my distro so I just changed the executable name with gtk-update-icon-cache. Not sure if that is the right way or not. Note: No rabbitvcs binary was found after running setup.py install command. I think the setup.py script could be a little more verbose :) From there I followed nautilus-3 README. I couldn't find any nautilus-python package. Not sure how to deal with this problem, any hints? I did find this link, but I don't know what to do with it. I ignored the missing package and created /usr/share/nautilus-python/extensions manually and copied the RabbitVCS.py. Restarted nautilus without success :| It's a shame no one is dealing with this problem, since the damn Windows got me hooked with tortoisesvn and unfortunately I also had to switch from CentOS 6 to CentOS 7.
I too struggled for installing rabbitvcs+nautilus but I ended with rabbitvcs+Thunar. To get it working on CentOS 7 do following: Download following packages from here: rabbitvcs-cli-0.14.2.1-5.el7.centos.noarch rabbitvcs-core-0.14.2.1-5.el7.centos.noarch rabbitvcs-thunar-0.14.2.1-5.el7.centos.x86_64 thunarx-python-0.2.3-5.el7.centos.x86_64 Open terminal as root user and run following commands yum install thunar gtk-doc Thunar-devel yum install meld pysvn python-dulwich python-simplejson subversion rpm -ivh rabbitvcs-core-0.14.2.1-5.el7.centos.noarch.rpm rabbitvcs-cli-0.14.2.1-5.el7.centos.noarch.rpm thunarx-python-0.2.3-5.el7.centos.x86_64.rpm rabbitvcs-thunar-0.14.2.1-5.el7.centos.x86_64.rpm open thunar explorer and check context menu, rabbitvcs menu should be available to you to serve. Hope this serves the purpose you are looking for.
How to install RabbitVCS on CentOS 7 & nautlius 3?
1,291,124,878,000
I've mounted a networked filesystem in GNOME by clicking on the icon in the left of Nautilus. However, when I use the terminal, I can't figure out how to access that filesystem. Is it possible?
Nautilus uses GVFS to mount networked filesystems. Unlike its predecessor GnomeVFS, GVFS includes a FUSE bridge so that non GVFS-aware applications can still access GVFS data. That means that there are two ways to do this: using the FUSE bridge, or using the native GVFS tools. Using the FUSE bridge According to man gvfsd-fuse, the GVFS daemon will mount bridges either at $XDG_RUNTIME_DIR/gvfs or $HOME/.gvfs. You should first check in $HOME/.gvfs. $ ls ~/.gvfs If it's there, great. All your networked, Nautilus-mounted filesystems should be shown as subdirectories. However, on my system (Arch GNU/Linux, GNOME 3.10), that directory doesn't exist. Therefore, you need to look in $XDG_RUNTIME_DIR/gvfs. On my system, this ends up being /run/user/$UID/gvfs, where $UID is your user id. As above, your mounts will be a subdirectory of this directory. You can use ordinary tools, like ls, cat, $EDITOR, etc. to work with the contents of these subdirectories. Using the native GVFS tools GVFS provides the gvfs-* family of tools to natively interact with GVFS. For example, gvfs-cat is just like regular cat, but it is GVFS-aware. All network mounts are referenced in the special GVFS computer:/// location. We need to get what they reference. $ gvfs-tree computer:/// computer:/// |-- APPLE SD Card Reader.drive |-- HL-DT-STDVDRW GA32N.drive -> burn:/// |-- ST31000528AS.drive -> file:///run/media/alex/Macintosh%20HD |-- root.link -> file:/// `-- [email protected] -> davs://[email protected]/remote.php/webdav In this listing, you can see my SD card reader, my optical drive, a different partition on my internal drive (mounted), a representation of the filesystem root, and finally, the networked filesystem that we're interested in (an OwnCloud account). Notice that this command indicates links. Now that we have the address for the networked filesystem, we can use GVFS tools to look at it. For example, let's list the contents of my OwnCloud. $ gvfs-ls davs://[email protected]/remote.php/webdav Introduction to Arch Linux.odp Looks like I don't have too much there. Let's create a new file. Now, GVFS doesn't have a tool like touch, but it does have a tool to save files. We can just save an empty file. $ gvfs-save davs://[email protected]/remote.php/webdav/foobar.txt gvfs-save will wait for you to type something. Since we don't actually want anything to be in this file, hit Ctrl-D to save. Now we can open this file with the default handler for it. $ gvfs-open davs://[email protected]/remote.php/webdav/foobar.txt It's worth noting that if you don't give it a file extension, the file won't open. This is because gvfs-open will throw an error about not knowing which application should be used to handle the file. (If you made this mistake, fix it with gvfs-move.) You can list all the GVFS commandline tools with a simple ls. $ ls /usr/bin/gvfs-*
How can I access networked filesystems that I've mounted in Nautilus?
1,291,124,878,000
Funnily, my newly vfat-formatted USB stick is automatically mounted when I plug it in, nautilus sees it, I can access it, I can see the permissions in the nautilus right click dialog (755), I can create and delete files from command line: $ touch/run/mount/christian/XXXX-XXXX/anyfile.txt I can even move files (with Del key) into trash from within nautilus. But when I try to create a new directory,a new file, or copy a file to that stick using nautilus in Arch linux, I just get the error message (German): Fehler beim Kopieren nach »Datenträger 4,0 GB«. Das Ziel ist schreibgeschützt Which means: **Error copying to »Storage device 4,0 GB - Target is read-only« I don't get it. It can't be on OS layer. I can touch, delete, renamy, copy anything on the command line. It must be something GNOME restricts. Is it necessary to be in a group in Arch/GNOME to write to USB devices? And why can I delete files (Move to trash and delete is possible from within nautilus!) I am in the following groups: sys lp wheel network video audio storage power libvirt users
Maybe it is related with this nautilus bug Nautilus says the USB stick is read only when it is not. Restarting nautilus clears the issue (at least temporally): $ killall nautilus
USB stick read-only in GNOME/nautilus?
1,291,124,878,000
I've created and registered some shared-mime-info files for custom file types. For example, in ~/.local/share/mime/packages I've added files like x-myokit.xml containing a mime type description, for example <mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'> <mime-type type="text/x-myokit"> <comment xml:lang="en">Myokit model definition</comment> <glob pattern="*.mmt"/> </mime-type> </mime-info> Nautilus now recognises my files, but still displays the file type as "Unknown". How do I make it show something more useful in this column?
This was hardcoded in Nautilus as per the devs decision to only show basic type information in the Type column by default, so that sorting by type would group type families. The basic types are defined in nautilus-file.c based on generic (symbolic) icon names1: struct { const char *icon_name; const char *display_name; } mime_type_map[] = { { "application-x-executable", N_("Program") }, { "audio-x-generic", N_("Audio") }, { "font-x-generic", N_("Font") }, { "image-x-generic", N_("Image") }, { "package-x-generic", N_("Archive") }, { "text-html", N_("Markup") }, { "text-x-generic", N_("Text") }, { "text-x-generic-template", N_("Text") }, { "text-x-script", N_("Program") }, { "video-x-generic", N_("Video") }, { "x-office-address-book", N_("Contacts") }, { "x-office-calendar", N_("Calendar") }, { "x-office-document", N_("Document") }, { "x-office-presentation", N_("Presentation") }, { "x-office-spreadsheet", N_("Spreadsheet") }, }; Types that do not fall in the above categories are shown as Unknown: if (basic_type == NULL) { basic_type = g_strdup (_("Unknown")); As a result, a file with mime type application/x-myokit (with a corresponding symbolic icon name application-x-generic) will be listed as Unknown in the Type column while a file with mime type text/x-myokit (with a corresponding symbolic icon name text-x-generic) will be listed as Text in the Type column (see also various system files like *.so files under /usr/lib or *.mo files in /usr/share/locale - they're all listed as Unknown but if you select one of them and hit Alt+Enter you get detailed, accurate information). You can make Nautilus list something else if you use generic-icon name in your xml file. Though your options are limited to the above mentioned categories. So, e.g. if you wanted each of your *.mmt files to be listed as Program in the Type column you would edit your x-myokit.xml like this: <?xml version="1.0" encoding="UTF-8"?> <mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'> <mime-type type="application/x-myokit"> <comment>Myokit model definition</comment> <generic-icon name="text-x-script"/> <glob pattern="*.mmt"/> </mime-type> </mime-info> Don't forget to update the mime database with: update-mime-database ~/.local/share/mime If you need more useful informations you could enable/check the MIME type column in Nautilus preferences (or with dconf/gsettings: add mime_type to org.gnome.nautilus.list-view default-visible-columns). 1: run gio info -a standard::symbolic-icon file to see the corresponding symbolic icon names (on older setups replace gio info with gvfs-info)
Where does Nautilus get its file type description
1,291,124,878,000
I have mounted an encrypted disk by selecting it in Nemo (1.1.2), then typing a password. I can unmount the disk using Nemo, but now it can be remounted without requiring the password. Probably there was a "remember" option such as demonstrated in this question. Regardless of what I selected when I initially mounted, now I want Nemo to forget the password. Is there a way to do this aside from logging out? This question may also apply to Nautilus (Nemo is a fork).
If you really mean "forget the password" it probably already did within microseconds of you entering it. Persistence of authentication through the login session is maintained in Ubuntu-ish systems by ssh-agent and gnome-keyring-daemon. By their nature of operation (non-invertable hashing) it may be fundamentally impossible to selectively remove one authentication. As you note, logging out destroys the cached authentication, ssh_agent -k would kill the cache without logging out (but other things would fail to authenticate too). This looks like you can have single-sign-on ease or fine-grained authentication control, pick one.
Nemo: Forget encryption password
1,291,124,878,000
I'm opening a nautilus window from my bash script with nautilus --new-window . How can I keep reading the currently open directory (even after navigating somewhere)?
You could use dbus-monitor to watch for related events when you change the current folder in any tab of any nautilus window: dbus-monitor " type='signal', interface='org.freedesktop.DBus.Properties', path='/org/freedesktop/FileManager1', member='PropertiesChanged'" | awk -F '"' ' $2 ~ "^/org/gnome/Nautilus/window/[[:digit:]]+$" { window = $2 sub(".*/", "", window) tab = 0 next } window && /string / { print window"."++tab": "$2 next } tab {window = 0}' prints something like: 2.1: file:///export/home/stephane/Desktop/untitled%20folder 2.2: file:///export/home/stephane/Downloads 1.1: trash:/// (where 2.1 for instance means 2nd window, 1st tab) every time I change folder in any tab of any nautilus window.
Is there a way to get a current directory of a nautilus window?
1,291,124,878,000
When I open nautilus and right-click in a folder, there is an option "Open Terminal Here". Before updating to Debian 9, I had a Keyboard Shortcut set in the file ~/.config/nautilus/accels, where I uncommented the line (gtk_accel_path "<Actions>/ExtensionsMenuGroup/TerminalNautilus:OpenFolderLocal" "F12") After updating, it doesn't work. The menu item is still there on right-click in nautilus but the accel doesn't work anymore. Does anyone have a solution to this?
I'm an Ubuntu 18.04 user (with GNOME 3.28.3) and this have worked wonderfully for me. Hope it does for you too :) Since version 3.15.4 Nautilus doesn't load the accel file anymore (Source). Fortunatelly there's a better aproach in order to get what you want. Long explanation/useful resources can be found here and also here. In short: Create a script called Terminal (yes, without a extension) inside the folder ~/.local/share/nautilus/scripts with the following content: # !/bin/sh gnome-terminal Make it executable, then close any Nautilus instance: chmod +x Terminal nautilus -q Create (or edit) the ~/.config/nautilus/scripts-accels file adding these lines: F4 Terminal ; Commented lines must have a space after the semicolon ; Examples of other key combinations: ; <Control>F12 Terminal ; <Alt>F12 Terminal ; <Shift>F12 Terminal Test it! Open Nautilus, right click, and choose Scripts > Terminal. Or, use the keyboard shortcut that you've just configured :)
Nautilus Accels on Debian 9/Gnome 3.22.3
1,291,124,878,000
From Nautilus, when I select several PDF documents and press Enter, they are all opened, but in an apparently random order. What is determining the order in which these documents are being opened? Is there a way to open them in the order they appear in Nautilus? The filenames are enumerated 1 to 7, and the dates of last change also follow that order. But when they're all opened, the window on top might be file 4, file 5 next, then file 2, file 7, etc.
They're open in parallel. nautilus will spawn as many processes (the order doesn't really matter here) and each of those processes will execute your PDF viewer with one of the files as arguments. All those PDF viewers will work independently, load shared libraries, open their own PDF files, connect to the X server and at some point ask the X server to display a Window. Which one will do that first you have no control on. To guarantee the order, you'd need cooperation from the Windows manager. You'd need nautilus to ask the Window manager to tell it when the window for the first PDF viewer has popped up before running the next one. Doing that reliably for any application is not easy. nautilus only knows the pid of the process it spawned to execute the PDF viewer. Not all applications tell the Window manager their pid, and if they do, it may very well be the pid of a child of the process spawned by nautilus (like in the case of a shell script), or it may very well not create a window at all...
Order of opening of documents in Nautilus
1,291,124,878,000
Is this possible? For example, if I'm in ~/Folder1/Folder2, is there a way for me to copy to the clipboard the text string ~/Folder1/Folder2?
And if you are too lazy to perform all the steps Gilles outlined you could install the following Nautilus script to copy the path of the active directory with a hotkey: #!/bin/bash # Copy current directory to clipboard # Dependencies: xclip echo "$PWD" | xclip -selection c For installation instructions and a tutorial on how to set up a key binding for your script please check out my answer over at Ask Ubuntu.
Copying the Active Directory Address from a Nautilus Window
1,291,124,878,000
I've installed Fedora 18 (x64) minimum and I installed Enlightenment with Nautilus. But I see that there are icons missing in Nautilus, I have selected the gnome icon theme so I must be missing some package(s). Does anyone know which ones? screenshot
Potential solution #1 Try these 2 commands first: gtk-update-icon-cache /usr/share/icons/gnome gtk-update-icon-cache /usr/share/icons/hicolor Potential solution #2 If that doesn't resolve the issue try installing this RPM, alacarte. yum install alacarte Potential solution #3 yum install 'gnome-icon-theme*'
Missing icons in Nautilus