date int64 1,220B 1,719B | question_description stringlengths 28 29.9k | accepted_answer stringlengths 12 26.4k | question_title stringlengths 14 159 |
|---|---|---|---|
1,624,962,712,000 |
I am a novice to rsync and have a rather deep directory looking something like this:
source
|
+--foo
| |
| +--bar1
| | |
| | +--bla (more dirs down the line)
| +--bar2
| | |
| | +--...
| +--bar3
| |
| +--bla (more dirs down the line)
...
Now, I'd like to... |
This seems to do the trick:
rsync -avm --include='*/' --include='foo/*/bla/**.csv' --exclude='*' source/ .
or
rsync -avm --include={'*/','foo/*/bla/**.csv'} --exclude='*' source/ .
--exclude='*' exclude all files
--include='*/' include directories
--include='foo/*/bla/**.csv' include *.csv files in or below the bl... | rsync recursively copy files downstream of subdirectories matching pattern |
1,624,962,712,000 |
I have around 90 websites I need a plugin installed on (wordpress) and I was wondering if there's a way to copy the plugin folder to all of them in a single run (i.e., simultaneously / in parallel).
These are all on the same cPanel so same path, except for the domain name.
The paths look like this:
/home/user/site1/... |
If all destination folders are /wp-content/plugins/, then you could iterate using find command, for example like this (assuming you are using bash and directory names have no 'space'):
for dir in $(find /home/user -name wp-content); do
[ -d ${dir}/plugins ] && scp -r /path/to/local/dir ${dir}/plugins/
done
| Copy folder to multiple (similar) locations simultaneously |
1,624,962,712,000 |
Attempting to discover a command to copy files if the destination's (not source's) file has not been modified in the last hour.
|
I know of no command that will precisely match your requirement. Something like this should work (remove the --dry-run when you're sure you're happy with the result; replace the --verbose with --quiet if you want it to run more silently):
src=/path/to/source
dst=/path/to/target
comm -z -23 \
<(find "$src" -ty... | Copy files from one directory to another, ignoring files where the destination's file has been modified in the last hour? |
1,624,962,712,000 |
In a Mac Terminal, I want to find all directories that contain at least one file with the specified extension and copy them somewhere else. I found find . -iname '*.jpg' -exec dirname {} \; which seems to find all directories containing a *.jpg file, but I'm not sure how to copy them. I tried combining it with rsync b... |
Here's a bash friendly one liner that copies any folders that have a jpg in them into a folder called backup while maintaining directory structure
mkdir backup; for folder in $(find . -type f -name '*.jpg' | sed -r 's|/[^/]+$||' |sort |uniq); do cp -r --parents $folder backup; done
First it creates an empty backup fo... | Copy all folders that contain file(s) with the given extension |
1,624,962,712,000 |
I would like to create a script that can write up from a text file a LibreOfficeCalc or equivalent table with the same columns than the following those from the following lines from a text file :
[1] 119.0(0.0) 73.0(0.0)
[2] 40.0(0.0) 17.0(0.0)
[3] 574.0(0.0) 469.0(0.0)
[4] 46.0(0.0) 47.0(0.0)
[5] 1.0(0.0) 2.... |
I am not sure whether I understood your question properly,
If your objective is to read the text file with any spreadsheet software like LibreOffice, you can change the default delimiter from ',' to whitespace and read them as columns.
Solution Update:
To create a .csv out of a text file separated by whitespaces, use... | Copying a text file into a calculation sheet with a script |
1,624,962,712,000 |
I'm currently trying to organize several thousand files which are named according to what's in them, and the various "tags," if you will, are separated by spaces. So, for example:
foo_bar bar_foo.txt
I'm relatively new to Linux/Unix, and was wondering if there was a way to iterate through every file, create folders b... |
try this.. remove the echo.. if you are happy with the commands...
ls * | awk '{print $1}' | sort -u | while read a; do echo mkdir -p $a; echo mv ${a}*txt ${a}; done
modified answer
$ ls
a b c d.txt b a d.txt c d e.txt d a.txt
$ ls * | sed "s/.txt//;s/ /\n/g" | sort -u | while read file; do echo mkdir -p $file... | Create folders from space-delimited filenames and copy files into them |
1,624,962,712,000 |
I am using Linux on my Android phone via use of Linux deploy.
I have some files in /root/android/ - folder of that linux partition.
And I want one of those files to move to my /storage/sdcard1/ - folder of my android.
Now the thing is all data of that linux file is saved in linux.img in sdcard1.
I literally have no wa... |
I found the ans which is at number 3:::
1-by uploading-downloading
I went further to check if any online upload-download site supports use of command line, and came across
https://transfer.sh site. Using it I transfered my file by uploading and downloading.
First upload your file to that site using below command af... | Transfer files from linux (of linuxdeploy in android) to android (in which linuxdeploy is installed) |
1,434,824,170,000 |
I want to copy the / directory to another directory, i.e. /Diskless-OS/centos-7/. I have tried using cp -r command, but it is throwing an "Permission Denied" error.
I'm working on a project where I'm developing a Diskless Booting System. So here, the Diskless Booting Clients, boot using the /Diskless-OS/centos-7/ pa... |
As already mentioned by Kusalananda, there are some directories you should not copy.
Therefore, you need to create them manually after copying the ones you need.
If you use Bash as shell, the following two commands should do what you want:
sudo cp -a /{b,e,h,l,m,o,ro,sb,sr,tf,u,v}* /Diskless-OS/
sudo mkdir /Diskless-O... | Copying / directory to another directory [OS:Centos-7] |
1,434,824,170,000 |
Let's say I have a directory /data/something with the following subdirs:
/data/something/iowa
/data/something/wyoming
/data/something/burkinafaso
/data/something/slovenia
All four subdirs have content. burkinafaso and slovenia are mount points; iowa and wyoming are not. I want to copy the directory structure in such ... |
On a machine with the GNU Coreutils (most Linux distros), the cp command has -x.
From cp man page:
-x, --one-file-system
| Is there a variant of the "cp -a" command that avoids copying from other filesystems? |
1,434,824,170,000 |
First of all it isn't a homework. I just don't want to dig through a bunch of manuals and learn to program shell from A-Z to do this one thing.
I have a folder /mnt/hdd/files with lots of subfolders where i store files and would like to select and copy files randomly to let's say /mnt/hdd/temp/1
Is there a way to sele... |
One way to do it, assuming filenames don't have embedded newlines:
#! /bin/sh
dest=/mnt/hdd/temp/1
cd /mnt/hdd/files
find . -type f | \
shuf -n 1000 | \
while [ $(du -ks "$dest" | awk '{ print $1 }') -lt 10485760 ] && IFS= read -r fn; do
cp "$fn" "$dest"
done
This will copy random files from /mnt/... | How to copy random files to a directory |
1,434,824,170,000 |
I have thousands of directories, within each directory is a subdirectory with a file called file.jpg. Since each subdirectory has a file called file.jpg I cannot transfer all those files into the same folder or they just overwrite each other until the last (one) file.jpg remains.
Instead, I want to paste some commands... |
If adding numbers is not mandatory requirement you can put paths in your file names.
That way you will solve both of your "issues" (overwritting files and not being able to trace back).
for ef in $(find * -name file.jpg); do cp $ef /path/to/dest_dir/$(echo $ef | sed 's,/,--,g'); done
-find * - *to get rid of ./ at th... | REQUEST: Appending {number} to end of file upon transfer |
1,434,824,170,000 |
Here at work our machines are required to run off of old Sun Sparc5's (1995) all running a UFS architecture on the hard drives due to a Solaris 5.3ish base. The way they are configured it is not possible (that I have found) to hook up a second SCSI hard drive so that it can recognize it and allow me to do an internal ... |
It is not very clear what you want to accomplish, but the best way (I know) to make a backup copy of Solaris installation is to create flash archives:
Build new machine (with linux for example), export via NFS some filesystem, mount on Solaris machine, create flash archives
flarcreate -n flash_archive_root -c -R / -x ... | How to externally copy an old UFS hard drive? |
1,434,824,170,000 |
Fist of all I have the files but the old system is gone.
I took the folders in /var/lib/mysql/ and gave then the permissions the mysql folder that was in there had. user mysql group root only accessible my user.
Now when I want to access my localhost sites I get a mysql database error. But I think everything is as it ... |
Turns out that I not had copied the actual databases. I got this my looking into the folders all that in there are the .frm files with the table names and a 65 bite db.opt file, so I knew that cant be the actual database.
They are all inside the ibdata1 file in the root of /var/lib/mysql/ I guess, I thaught the databa... | Copyed mysql files from previous system now error while connect, what to do? |
1,434,824,170,000 |
I'm looking to copy a specific folder inside an other one, but I don't have the exact names, for example
/volume1/User/save/01/**-**** ?/GROUPES **-****/
**-**** is a number reference that changes everytime but always formated the same (eg : 75-1234) and ? are words (Lion Tiger Shark) --> /75-1234 Lion Tiger/ Shark)... |
As @Jonas noted, you need a ? to match one character and a * to match multiple characters. A space character needs to be escaped with a \.
With the first pattern **-**** ? changed to ??-????\ * and the escaped space characters, the command should be:
cp -r /volume1/User/save/01/??-????\ */GROUPES\ ??-????/ /volume1/Us... | find and copy usage using wildcards |
1,434,824,170,000 |
I want to copy positionXYZ into another directory's inside I want both of them.I put:
Tutorials myname $ cp -r positionXYZ Documents/Gerris\ Programs/Tutorials/tutorial6/
Then it says :
cp: directory Documents/Gerris Programs/Tutorials/tutorial6 does not exist
Tutorials is the positionXYZ's current parent directory... |
I assume you are already in
Documents/Gerris Programs/Tutorials/
so, all you need to do is:
cp -r positionXYZ tutorial6/
or if you want to use an absolute path (assuming that Documents is in your home directory ~):
cp -r positionXYZ ~/Documents/Gerris\ Programs/Tutorials/tutorial6/
| Copy a file into another directory's inside [closed] |
1,434,824,170,000 |
I want to copy directories from one variable to directories from another one but without loop.
from="fromdir1 fromdir2"
to="todir1 todir2"
I mean fromdir1 to todir1, fromdir2 to todir2.
I think it can be done with xargs but I don't know how.
|
You could use GNU parallel with linked arguments:
parallel --link cp {1} {2} ::: from1 from2 from3 ::: to1 to2 to3
If the from and to-files are in respectives text lists, use
parallel --link cp {1} {2} :::: fromlist :::: tolist
note the 4 colons vs. 3 colons previously. More info on GNU parallel on the website.
For ... | copy multiple directories in multiple directories without loop [duplicate] |
1,345,806,144,000 |
How do we allow certain set of Private IPs to enter through SSH login(RSA key pair) into Linux Server?
|
You can limit which hosts can connect by configuring TCP wrappers or filtering network traffic (firewalling) using iptables. If you want to use different authentication methods depending on the client IP address, configure SSH daemon instead (option 3).
Option 1: Filtering with IPTABLES
Iptables rules are evaluated in... | Limit SSH access to specific clients by IP address |
1,345,806,144,000 |
I am confused what's the actual difference between SNAT and Masquerade?
If I want to share my internet connection on local network, should I select SNAT or Masquerade?
|
The SNAT target requires you to give it an IP address to apply to all the outgoing packets. The MASQUERADE target lets you give it an interface, and whatever address is on that interface is the address that is applied to all the outgoing packets. In addition, with SNAT, the kernel's connection tracking keeps track of... | Difference between SNAT and Masquerade |
1,345,806,144,000 |
I run a VPS which I would like to secure using UFW, allowing connections only to port 80.
However, in order to be able to administer it remotely, I need to keep port 22 open and make it reachable from home.
I know that UFW can be configured to allow connections to a port only from specific IP address:
ufw allow proto ... |
I don't believe this is possible with ufw. ufw is just a frontend to iptables which also lacks this feature, so one approach would be to create a crontab entry which would periodically run and check if the IP address has changed. If it has then it will update it.
You might be tempted to do this:
$ iptables -A INPUT -p... | UFW: Allow traffic only from a domain with dynamic IP address |
1,345,806,144,000 |
I'm trying to connect to port 25 with netcat from one virtual machine to another but It's telling me no route to host although i can ping. I do have my firewall default policy set to drop but I have an exception to accept traffic for port 25 on that specific subnet. I can connect from VM 3 TO VM 2 on port 25 with nc b... |
Your no route to host while the machine is ping-able is the sign of a firewall that denies you access politely (i.e. with an ICMP message rather than just DROP-ping).
See your REJECT lines? They match the description (REJECT with ICMP xxx). The problem is that those seemingly (#) catch-all REJECT lines are in the midd... | No route to host with nc but can ping |
1,345,806,144,000 |
I have docker installed on CentOS 7 and I am running firewallD.
From inside my container, going to the host (default 172.17.42.1)
With firewall on
container# nc -v 172.17.42.1 4243
nc: connect to 172.17.42.1 port 4243 (tcp) failed: No route to host
with firewall shutdown
container# nc -v 172.17.42.1 4243
Connecti... |
Maybe better than earlier answer;
firewall-cmd --permanent --zone=trusted --change-interface=docker0
firewall-cmd --permanent --zone=trusted --add-port=4243/tcp
firewall-cmd --reload
| How to configure Centos 7 firewallD to allow docker containers free access to the host's network ports? |
1,345,806,144,000 |
I have a system that came with a firewall already in place. The firewall consists of over 1000 iptables rules. One of these rule is dropping packets I don't want dropped. (I know this because I did iptables-save followed by iptables -F and the application started working.) There are way too many rules to sort through ... |
You could add a TRACE rule early in the chain to log every rule that the packet traverses.
I would consider using iptables -L -v -n | less to let you search the rules. I would look port; address; and interface rules that apply. Given that you have so many rules you are likely running a mostly closed firewall, and ar... | Is there a way to find which iptables rule was responsible for dropping a packet? |
1,345,806,144,000 |
I want to set up CentOS 7 firewall such that, all the incoming requests will be blocked except from the originating IP addresses that I whitelist. And for the Whitelist IP addresses all the ports should be accessible.
I'm able to find few solutions (not sure whether they will work) for iptables but CentOS 7 uses firew... |
I'd accomplish this by adding sources to a zone. First checkout which sources there are for your zone:
firewall-cmd --permanent --zone=public --list-sources
If there are none, you can start to add them, this is your "whitelist"
firewall-cmd --permanent --zone=public --add-source=192.168.100.0/24
firewall-cmd --perman... | Whitelist source IP addresses in CentOS 7 |
1,345,806,144,000 |
There's an example of iptables rules on archlinux wiki:
# Generated by iptables-save v1.4.18 on Sun Mar 17 14:21:12 2013
*filter
:INPUT DROP [0:0]
:FORWARD DROP [0:0]
:OUTPUT ACCEPT [0:0]
:TCP - [0:0]
:UDP - [0:0]
-A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m conntr... |
What do the three rules do?
Those 3 rules seem pretty self-explanatory:
Reject incoming UDP packets with an ICMP message "port unreachable"
Reject incoming TCP packets with "tcp reset"
Reject incoming packets (of any other protocol) with ICMP message "protocol unreachable"
If you're looking for more detail (about ... | Is it better to set -j REJECT or -j DROP in iptables? |
1,345,806,144,000 |
Do you need to run any of these commands:
sudo ufw reload
sudo ufw disable
sudo ufw enable
after adding a rule via sudo ufw allow?
|
No. It's enough to just add it. But if you add rules in the files, you need to execute commit.
You can check user rules, as they're called with:
ufw status
You can also add verbose for some details:
ufw status verbose
Or numbered to know which rule to remove with delete. The syntax for this one is this:
ufw delete <... | Do you need to reload after adding a rule in ufw? |
1,345,806,144,000 |
I know linux has 3 built-in tables and each of them has its own chains as follow:
FILTER: PREROUTING, FORWARD, POSTROUTING
NAT: PREROUTING, INPUT, OUTPUT, POSTROUTING
MANGLE: PREROUTING, INPUT, FORWARD, OUTPUT, POSTROUTING
But I can't understand how they are traversed, in which order, if there is.
For example, how are... |
Wikipedia has a great diagram to show the processing order.
For more details you can also look at the iptables documentation, specifically the traversing of tables and chains chapter. Which also includes a flow diagram.
The order changes dependent on how netfilter is being used (as a bridge or network filter and wheth... | How iptables tables and chains are traversed |
1,345,806,144,000 |
How do I set up the firewall on a system in a LAN so that some ports are only open to connections from the local area network, and not from the outside world?
For example, I have a box running Scientific Linux 6.1 (a RHEL based distro), and I want its SSH server to only accept connections from localhost or LAN. How do... |
With the kernel's iptables completely empty (iptables -F), this will do what you ask:
# iptables -A INPUT -p tcp --dport 22 -s 192.168.0.0/24 -j ACCEPT
# iptables -A INPUT -p tcp --dport 22 -s 127.0.0.0/8 -j ACCEPT
# iptables -A INPUT -p tcp --dport 22 -j DROP
This says that all LAN addresses are allowed to talk to T... | Set some firewall ports to only accept local network connections? |
1,345,806,144,000 |
In a CentOS 7 server, I type in firewall-cmd --list-all, and it gives me the following:
public (default, active)
interfaces: enp3s0
sources:
services: dhcpv6-client https ssh
ports:
masquerade: no
forward-ports:
icmp-blocks:
rich rules:
What is the dhcpv6-client service? What does it do? And w... |
This is needed if you are using DHCP v6 due to the slightly different way that DHCP works in v4 and v6.
In DHCP v4 the client establishes the connection with the server and because of the default rules to allow 'established' connections back through the firewall, the returning DHCP response is allowed through.
However... | what is dhcpv6-client service in firewalld, and can i safely remove it? |
1,345,806,144,000 |
My router sends out multicast packets in regular intervals that are blocked by UFW's standard policies. These events are harmless but spam my syslogs and ufwlogs. I can't change the router's behaviour as that would require installing a modified firmware and thus void the warranty.
So my question is: Is there any way I... |
Base on this answer from ServerFault,
ufw supports per rule logging. By default, no logging is performed when a packet matches a rule.
All you have to do is create a UFW deny rule to match those multicast packets.
| How can I disable UFW logging for a specific event? |
1,345,806,144,000 |
I set up some iptables rules so it logs and drops the packets that are INVALID (--state INVALID). Reading the logs how can I understand why the packet was considered invalid? For example, the following:
Nov 29 22:59:13 htpc-router kernel: [6550193.790402] ::IPT::DROP:: IN=ppp0 OUT= MAC= SRC=31.13.72.7 DST=136.169.151... |
Packets can be in various states when using stateful packet inspection.
New: The packet is not part of any known flow or socket and the TCP flags have the SYN bit on.
Established: The packet matches a flow or socket tracked by CONNTRACK and has any TCP flags. After the initial TCP handshake is completed the SYN bit m... | How to understand why the packet was considered INVALID by the `iptables`? |
1,345,806,144,000 |
I want to stop internet on my system using iptables so what should I do?
iptables -A INPUT -p tcp --sport 80 -j DROP
or
iptables -A INPUT -p tcp --dport 80 -j DROP ?
|
Reality is you're asking 2 different questions.
--sport is short for --source-port
--dport is short for --destination-port
also the internet is not simply the HTTP protocol which is what typically runs on port 80. I Suspect you're asking how to block HTTP requests. to do this you need to block 80 on the outbound cha... | What is sport and dport? |
1,345,806,144,000 |
When I try to telnet to a port on a server, and if there is no program listening on that port telnet dies with a "Unable to connect ... " error. I understand that. But, why do we need a firewall if there is no program listening on any ports?
|
There may not be a service running right now, but how about tomorrow? You have them all turned off, but what about your users? Anyone on a unix/windows/mac system can open a port > 1024 on any machine they have access to. What about malware? What about a virus? They can also open up ports and start serving infor... | Why do we need a firewall if no programs are running on your ports? |
1,345,806,144,000 |
I have a Quake 3 server. And it's launched successfully.
The problem is that no one can connect to that server.
I am running: nmap -sU -p 27960 hostname and it's showing me that it's state open|filtered
if I am running that command right from the server it is open.
Also, I am making sure that it's binding to the right... |
Getting different nmap results from local machine and remote machines means there is some kind of firewall(whether running locally or some remote machine) which is blocking. According to the nmap documentation,
open|filtered
Nmap places ports in this state when it is unable to determine whether
a port is open or fi... | nmap shows me that one service is "open|filtered" while locally it's "open", how to open? |
1,345,806,144,000 |
I have a firewall (csf) that lets you to separately allow incoming and outgoing TCP ports. My question is, why would anyone want to have any outgoing ports closed?
I understand that by default you might want to have all ports closed for incoming connections. From there, if you are running an HTTP server you might want... |
There can be many reasons why someone might want to have outgoing ports closed. Here are some that I have applied to various servers at various times
The machine is in a corporate environment where only outbound web traffic is permitted, and that via a proxy. All other ports are closed because they are not needed.
Th... | What's the point of firewalling outgoing connections? |
1,345,806,144,000 |
I want to open the following ports in my CentOS 7 firewall:
UDP 137 (NetBIOS Name Service)
UDP 138 (NetBIOS Datagram Service)
TCP 139 (NetBIOS Session Service)
TCP 445 (SMB)
I can guess that the services names include samba includes TCP 445 but I don't know if the other ports have a service name preconfigured.
I can ... |
You can find the xml files this information is stored in in /usr/lib/firewalld/services/ (for distro-managed services) and/or /etc/firewalld/services/ for your own user-defined services.
For example, samba.xml reads (on my centos7):
<?xml version="1.0" encoding="utf-8"?>
<service>
<short>Samba</short>
<description... | How do I get a list of the ports which belong to preconfigured firewall-cmd services? |
1,345,806,144,000 |
I'm trying to restrict access to a particular port for a particular user on my Debian.
Let's say user's id is 1000 and port I would like to block is 5000.
I tried using iptables with the following command :
iptables -I OUTPUT -o lo -p tcp --dport 5000 --match owner --uid-owner 1000 -j DROP
It works if the user does c... |
Do the same for IPv6 ... localhost resolves to both an IPv4 and IPv6 address, and v6 is preferred.
Edit 1:
ip6tables -I OUTPUT -o lo -p tcp --dport 5000 --match owner --uid-owner 1000 -j DROP
| Restrict local port access to a specific user |
1,345,806,144,000 |
I have just set up a DNS server for my own network, and many guides online suggest to make sure that port forwarding on port 53 is not enabled.
The thing that is not clear to me is this: should I configure this at the router level or at the firewall level? If I should do this on the firewall, how would I go about doin... |
This should be configured on whatever equipment you have between the DNS server and the outside world. AFAIK port forwarding is disabled by default on pretty much everything so you shouldn't worry too much about it. If you're using residential network gear, there should be port forwarding configuration options in th... | How to check if port forwarding is enabled? |
1,345,806,144,000 |
When configuring a chain in nftables, one has to provide a priority value. Almost all online examples set a piority of 0; sometimes, a value of 100 gets used with certain hooks (output, postrouting).
The nftables wiki has to say:
The priority can be used to order the chains or to put them before or after some Netfilt... |
UPDATE: iptables-nft (rather than iptables-legacy) is using the nftables kernel API and in addition a compatibility layer to reuse xtables kernel modules (those described in iptables-extensions) when there's no native nftables translation available. It should be treated as nftables in most regards, except for this que... | When and how to use chain priorities in nftables |
1,345,806,144,000 |
I set up a bridge br0 "attached" to two interfaces:
eth0, my physical interface connected to the real LAN,
vnet0, a KVM virtual interface (connected to a Windows VM).
And I have this single firewall rule in the forward chain:
iptables -A FORWARD -j REJECT
Now, the only ping that is working is from the VM to the... |
The comment from Stéphane Chazelas provides the hint to the answer.
According to Bridge-nf Frequently Asked Questions bridge-nf enables iptables, ip6tables or arptables to see bridged traffic.
As of kernel version 2.6.1, there are five sysctl entries for bridge-nf behavioral control:
bridge-nf-call-arptables - pass b... | Why does my firewall (iptables) interfere in my bridge (brctl)? |
1,345,806,144,000 |
I've recently decided to do some security maintenance. I saw my logs, and there were some tries against my SSH server. At first, I moved away the SSH port from the default 22. After it, I read something about Fail2ban, BlockHosts and DenyHosts.
I took a look at the first: it is simple to configure, everything is under... |
I found the problem, what I did, before installing fail2ban. Sorry for your time.
For security reason, I moved away my sshd from port 22 to an other. The reference in iptables refers to port 22 only. I thought, that it is a variable, what always refers to the current sshd port. But NOT.
The exact solution (if you move... | Fail2ban block with IPtables doesn't work on Debian Lenny. [moved ssh port] |
1,345,806,144,000 |
I have a CentOS 8 guest running on a Fedora 31 host. The guest is attached to a bridge network, virbr0, and has address 192.168.122.217. I can log into the guest via ssh at that address.
If I start a service on the guest listening on port 80, all connections from the host to the guest fail like this:
$ curl 192.168.12... |
Well, I figured it out. And it's a doozy.
CentOS 8 uses nftables, which by itself isn't surprising. It ships with the nft version of the iptables commands, which means when you use the iptables command it actually maintains a set of compatibility tables in nftables.
However...
Firewalld -- which is installed by defau... | Why are my network connections being rejected? |
1,345,806,144,000 |
I currently have a NAS box running under port 80. To access the NAS from the outside, I mapped the port 8080 to port 80 on the NAS as follow:
iptables -t nat -A PREROUTING -p tcp --dport 8080 -j DNAT --to-destination 10.32.25.2:80
This is working like a charm. However, this is working only if I am accessing the websit... |
I finally found how-to. First, I had to add -i eth1 to my "outside" rule (eth1 is my WAN connection). I also needed to add two others rules. Here in the end what I came with :
iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 8080 -j DNAT --to 10.32.25.2:80
iptables -t nat -A PREROUTING -p tcp --dport 8080 -j DNAT ... | IPTables - Port to another ip & port (from the inside) |
1,345,806,144,000 |
How can i do this in a single line?
tcp dport 53 counter accept comment "accept DNS"
udp dport 53 counter accept comment "accept DNS"
|
With a recent enough nftables, you can just write:
meta l4proto {tcp, udp} th dport 53 counter accept comment "accept DNS"
Actually, you can do even better:
set okports {
type inet_proto . inet_service
counter
elements = {
tcp . 22, # SSH
tcp . 53, # DNS (TCP)
udp . 53 # DNS (UDP)
}
And then:
... | How to match both UDP and TCP for given ports in one line with nftables |
1,345,806,144,000 |
The help information doesn't seem to be very informative:
--list -L [chain [rulenum]]
List the rules in a chain or all chains
--list-rules -S [chain [rulenum]]
Print the rules in a chain or all chains
The only difference is in the choice of word: "list" vs. "print".
THe manual is a bit more detailed bu... |
The difference is the output format. The -S option produces in the the fashion of iptables-save. And this can be reused with iptables-apply,iptables-restore. (Check their man pages entries for details.) So you can think of the difference as:
-L is for reference, to get a clue of what's there
-S is for reusable output... | What is the difference between iptables -S and iptables -L |
1,345,806,144,000 |
How can I permanently block any ipaddress who accesses known vulnerable pages such as /phpMyadmin/?
I am running a Debian server and I often see bots, or hackers scanning my server trying to find vulnerabilities.
73.199.136.112 - - [16/Oct/2017:05:18:05 -0700] "HEAD /phpMyadmin/ HTTP/1.0" 404 182 "-" "Mozilla/5.0 Jo... |
This may be more heavy weight than you're looking for, but you might consider using fail2ban (https://www.fail2ban.org). That's a tool that can monitor your log files and automatically ban addresses that generate logs that match a set of customizable patterns.
| How to block clients by IP address from accessing certain URLs on my web server? |
1,345,806,144,000 |
I'm reading iptables' man page at https://linux.die.net/man/8/iptables, and I've got a question regarding the use of user-defined chains:
In the Targets section, it says
If the end of a built-in chain is reached or a rule in a built-in chain with target RETURN is matched, the target specified by the chain policy dete... |
If none of the rules in a user-defined chain match, the default behavior is effectively RETURN: processing will continue at the next rule in the parent chain.
When a packet matches a rule whose target is a user-defined chain, the packet begins traversing the rules in that user-defined chain. If that chain doesn't dec... | iptables - default action at the end of user-defined chain |
1,345,806,144,000 |
Booting from a kernel which I recompiled with a custom .config, I got the the following kmsg(ie. dmesg) message:
systemd[1]: File /usr/lib/systemd/system/systemd-journald.service:35 configures an IP firewall (IPAddressDeny=any), but the local system does not support BPF/cgroup based firewalling.
systemd[1]: Proceedi... |
First enable CONFIG_BPF_SYSCALL=y
┌── Enable bpf() system call ─────────────────────────────────┐
│ │
│ CONFIG_BPF_SYSCALL: │
│ │
│ Enable the bpf() system ca... | How to fix "File" *.service "configures an IP firewall (IPAddressDeny=any), but the local system does not support BPF/cgroup based firewalling"? |
1,345,806,144,000 |
i have a server (debian 7) setup in my university with public ip.
when I ssh into the system (from outside the campus), I get a weird delay of 5-10 seconds before I get the password prompt. Why is that?
I run ssh -v to get verbose output:
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
de... |
As indicated in the comments, this is likely being caused by the UseDNS yes setting in the sshd_config on the server.
The UseDNS setting is a common culprit for this very issue. Basically what happens is that your IP netblock either has a defective, or missing DNS server. So sshd is trying to do a reverse lookup on yo... | delay to get password prompt when ssh'ing to a public server |
1,345,806,144,000 |
I got an external Debian server. The problem is that my university campus doesn't allow connections to go outside when the port is different than TCP port 22, 80, 443, or UDP port 123. I tested them manually. On my Debian server I would like to listen to all my UDP and TCP ports so I can clearly figure out which TCP a... |
tcpdump usually comes as standard on Linux distros. It will log all packets visible at the server note that
you probably want to set it running with a filter for your client IP to cut down on the noise
I think this includes packets not accepted by iptables on the local machine - but you might want to test this
e.g... | How to listen to all ports (UDP and TCP) or make them all appear open in Debian |
1,345,806,144,000 |
I've been on CentOS 7 for a long time and was used to building my custom iptables configurations on a variety of both personal and business boxes.
I've recently started working with CentOS 8 and learned of the move from iptables to nftables and so I was able to rewrite my rulesets and got everything up and running. ... |
I think the answer is fairly straightforward. First, you have done exactly the right thing...
Firewalld is a pure frontend. It's not an independent firewall by itself. It only operates by taking instructions, then turning them into nftables rules (formerly iptables), and the nftables rules ARE the firewall. So you hav... | CentOS 8 firewalld + nftables or just nftables |
1,460,817,305,000 |
Let's say as the example that I have a firewall that blocks ALL ports from all sources/destinations.
What ports would I need to open to be able to successfully run:
ping google.com
...and are there any other ports I would have to open to be able to browse google.com via a browser?
I've tried opening port 53(dns) 80(h... |
For DNS, you need to allow UDP packets between any port on an IP address inside the firewall, and port 53 on an IP address outside the firewall.
For HTTPS, you need to allow TCP packets between any port on an IP address inside the firewall, and port 443 outside the firewall, or more rarely any port outside the firewal... | What ports need to be open on a firewall to access the internet? |
1,460,817,305,000 |
Is there a way to set a keepalive in the command-line MySQL client on Linux?
Our network recently moved to a VLAN setup, and our systems department no longer has control of the firewall. The powers-that-be decided to set a rule in their firewall to kill all connections after 30 minutes if no data has passed through (s... |
You can set generic TCP keepalives, I think there is a kernel setting for that. But they're usually much less frequent (hours). There is a TCP Keepalive HOWTO which appears to have details.
Alternatively, why not just tunnel the MySQL connection over SSH, then you can use SSH keepalives?
$ ssh -L1234:127.0.0.1:3306 -o... | MySQL Linux Client Timeout/Keepalive |
1,460,817,305,000 |
I think there is no iptables/pf solution to only allow an XY application on e.g.: outbound tcp port 80, eth0. So if I have a userid: "500" then how could I block any other communications then the mentioned on port 80/outbound/tcp/eth0? (e.g.: just privoxy is using port 80 on eth0)
Extra: virtualbox uses port 80 too? ... |
here's the iptables command to allow for a certain uid through a certain port.
iptables -A OUTPUT -p tcp -m tcp --dport 80 -m owner --uid-owner username -j ACCEPT
from the man page
[!] --uid-owner userid[-userid]
Matches if the packet socket’s file structure (if it has one) is owned by the giv... | iptables/pf rule to only allow XY application/user? |
1,460,817,305,000 |
Platform: RHEL 5.10
netcat Version: 1.84-10.fc6
I was trying to figure out if my inability to ssh was TCP-level and usually I use nc for this. This time, however, I got something unexpected.
[bratchley@ditirlns01 ~]$ nc -vz dixxxldv02.xxx.xxx 22 -w 15
nc: connect to dixxxldv02.xxx.xxx port 22 (tcp) timed out: Operatio... |
Shortly after posting, I found the problem:
[bratchley@ditirlns01 ~]$ host ditirldv02.ncat.edu
ditirldv02.ncat.edu has address 152.8.143.20
ditirldv02.ncat.edu has address 152.8.143.5
[bratchley@ditirlns01 ~]$
So it appears that nc will cycle through all A records for a given host and test each one individually. The ... | nc both fails and succeeds |
1,460,817,305,000 |
I have two interfaces on my VPS: eth0 and eth0:0. I want to block incoming packets on port 80 on eth0:0 using iptables. I tried this, but it doesn't work:
iptables -A INPUT -i "eth0:0" -p tcp --destination-port 80 -j DROP
If I change eth0:0 to eth0 it works correctly. What is the problem?
|
The short story: the way you did that is correct (as per your comment to the question).
The long story: on Linux, a network ‘device’ called foo:bar is an alias of ‘foo’ used when we need to assign multiple network settings to the ‘foo’ interface, e.g. to have it respond on multiple subnets on the same wire.
This is a ... | Why doesn't my iptables rule work? |
1,460,817,305,000 |
I am using iptables with ipset on an Ubuntu server firewall. I am wondering if there is a command for importing a file containg a list of ip's to ipset. To populate an ipset, right now, I am adding each ip with this command:
ipset add manual-blacklist x.x.x.x
It would be very helpfull if I can add multiple ip's with ... |
You can use ipset save/restore commands.
ipset save manual-blacklist
You can run above command and see how you need to create your save file.
Example output:
create manual-blacklist hash:net family inet hashsize 1024 maxelem 65536
add manual-blacklist 10.0.0.1
add manual-blacklist 10.0.0.2
And restore it with bel... | How to import multiple ip's to Ipset? |
1,460,817,305,000 |
Sometimes I upload an application to a server that doesn't have external internet access.
I would like to create the same environment in my machine for testing some features in the application and avoid bugs (like reading a rss from an external source).
I thought about just unplugging my ethernet cable to simulate, bu... |
Deleting the default route should do this. You can show the routing table with /sbin/route, and delete the default with:
sudo /sbin/route del default
That'll leave your system connected to the local net, but with no idea where to send packets destined for beyond. This probably simulates the "no external access" situa... | Is it possible to simulate "no external access" from a Linux machine when developing? |
1,460,817,305,000 |
I am doing some research to figure out what distro's of linux contain kernel packet filtering and are compatible with BPF.
http://kernelnewbies.org/Linux_3.0
http://lwn.net/Articles/437981/
These two articles lead me to believe there is a package somewhere taht includes the libraries, and binaries?
I am specifically ... |
I think you have mixed two different things:
The OpenBSD packet filter facilities (sometimes called pf, and mostly controlled by pfctl). These are the basis of OpenBSD firewalling, the Linux equivalent is netfilter, mostly controlled by the iptables command. Comparable, but not compatible (and most say that OpenBSD... | Is berkeley packet filter ported to linux? |
1,460,817,305,000 |
We have a problem with doing SSH connections through remote port forwarding.
The scenario is an enterprise network, where a server on the internal network (let's call it "origin") must log in via SSH to a server in the DMZ ("target"). Since the target server in the DMZ is locked down for connections from the internal ... |
It looks like you should be using local port-forwarding instead of remote port-forwarding. You may want to refer to the following helpful blog post by Dirk Loss:
SSH port forwarding visualized
It includes the following illustrative diagram:
In order to read the diagram you need to know that it describes the relatio... | SSH session through jumphost via remote port forwarding |
1,460,817,305,000 |
I have been reading for a while now.
What I understood is:
nftables is the modern Linux kernel packet classification framework. nftables is the successor to iptables. It replaces the existing iptables, ip6tables, arptables, and ebtables framework.
x_tables is the name of the kernel module carrying the shared code por... |
My view is that iptables, ip6tables, ebtables and arptable is a frontend tool-set to Netfilter.
They are a user-space tool-set that format and compile the rules to load them in the core Netfilter that runs in the kernel. You can find all the kernel parts of Netfilter in your modules directory ls /lib/modules/$(uname -... | What is the relationship or difference among iptables, xtables, iptables-nft, xtables-nft, nf_tables, nftables |
1,460,817,305,000 |
I am using fail2ban with ipfw on FreeBSD. Is there a way to ignore a specific ip address, making sure that fail2ban never blocks or reports it?
|
See whitelisting on the fail2ban website:
# This will ignore connection coming from common private networks.
# Note that local connections can come from other than just 127.0.0.1, so
# this needs CIDR range too.
ignoreip = 127.0.0.0/8 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16
Another reference here:
First, find ignore... | Ignore a specific ip for fail2ban |
1,460,817,305,000 |
I have a CentOS release 5.4 linux box on Amazon EC2 that I'm trying to set up to be monitored via Nagios. The machine is in the same security group as the nagios server, but it seems to be unresponsive to pings or NRPE checks, although apparently port 22 is open.
The CentOS box can ping itself using it's internal IP a... |
I dont' think that it's related to ping problem, but if you want to put selinux temporary off, you have this option:
setenforce 0
it put selinux from enforcing to permissive mode, to check its condition run
sestatus
to diable selinux permanently you can use system-config-securitylevel or edit with nano or vi /etc/se... | What prevents a machine from responding to pings? |
1,460,817,305,000 |
I'd like to receive a RTSP stream via VLC, but when I try to run
sudo -u non_root_user cvlc -vvv -I dummy rtsp://ip:port/x.sdp
I get:
Unable to determine our source address: This computer has an invalid IP address: 0x0
I think that the ports might be closed, because when I disabled firewall, I was able to recei... |
You've run into an ugly hack in Live555, the library VLC uses to provide the RTSP client feature. (VLC's RTSP server code is VLC-specific.) The hack attempts to figure out which IP your machine appears to use on the LAN. (Ugly as the hack is, I don't know a better way for Live555 to do this.)
You have to open UDP port... | Enable RTSP in iptables |
1,460,817,305,000 |
Netfilter connection tracking is designed to identify some packets as "RELATED" to a conntrack entry.
I'm looking to find the full details of TCP and UDP conntrack entries, with respect to ICMP and ICMPv6 error packets.
Specific to IPv6 firewalling, RFC 4890 clearly describes the ICMPv6 packets that shouldn't be dropp... |
I don't know the answer, but you can find out yourself.
Use these rules (creates an empty chain "NOOP" for accounting purposes):
*filter
...
:NOOP - [0:0]
...
-A INPUT -i wanif -p icmpv6 --icmpv6-type destination-unreachable -j NOOP
-A INPUT -i wanif -p icmpv6 --icmpv6-type packet-too-big -j NOOP
-A INPUT -i wanif -p ... | netfilter TCP/UDP conntrack RELATED state with ICMP / ICMPv6 |
1,460,817,305,000 |
I am a student and I keep most of my files on my home computer. Unfortunately, i can't use ssh or scp from my laptop which I use at school because of the firewall. I was thinking about trying to use port 443 because that might be open.
My question is: I have multiple computers in my house and so I am using a router. W... |
It should work fine, it's not more secure than using a different port for ssh (or less secure for that matter). And no, outbound TCP sockets are not the same as inbound TCP sockets - so it should not interfere with your outbound network traffic.
| Is it bad to port forward port 443 for ssh? |
1,460,817,305,000 |
I have a (non production) machine where external supporters have shell-access (non-root). I want to prevent them from going further on into our network from that machine using iptables.
The "normal" firewall-gui only blocks incoming traffic. How can I set up rules like "accept all incoming traffic (plus response), but... |
There are two ways to drop all outgoing traffic except what you explicitly define as ACCEPT. The first is to set the default policy for the OUTPUT chain to drop.
iptables -P OUTPUT DROP
The downside to this method is that when the chain is flushed (all rules removed), all outbound traffic will be dropped. The other w... | Blocking outgoing connects with iptables |
1,460,817,305,000 |
I'm trying to set up a firewall on my own desktop (currently I'm tinkering with a Fedora 29 virtual machine). I would like to have it on the "deny-everything-by-default" basis. Almost immediately I decided to disable and mask the firewalld.service, since firewalld had no way to drop the outgoing packets, except by usi... |
For the question per se, these are the last two questions from the original post:
How can I reliably use nft without iptables rules interference?
Or should I simply use iptables and remove nft?
this is what the nftables wiki says:
What happens when you mix Iptables and Nftables?
How do they interact?
nft Empt... | How to prevent iptables and nftables rules from running simultaneously? |
1,460,817,305,000 |
I have a standard installation of Ubuntu 10.04, and have installed the LAMP stack so I can do some web development locally. On my router I have opened port 80 so I can develop with external services like paypal and facebook, as they need to see the website for them to work.
How unsecure has my development machine bec... |
Of course any services you have open will increase your vulnerable attack surface. What runs behind those services will determine how secure and insecure you become. If you write insecure PHP scripts and host them in your newly accessible Apache site, the world will be able to (and will!) exploit them. You should seri... | Opening port 80 but remain secure |
1,460,817,305,000 |
I have one single ipset added to my iptables on a CentOS 6.x box and this rule is lost when the machine reboots.
I've found this answer showing how to make a Ubuntu system reload the iptables rules after a reboot but this directory is not present on CentOS.
How do I make this CentOS box load the firewall rules after ... |
You lost rules because:
After adding rules you have to do save before restart service or server. because when you add rule, they are in memory but after saving they will save in file and restore from that file at start-up.
So first You need to save added rules using:
$ /etc/init.d/iptables save
This will save all ... | iptables rules not reloading on CentOS 6.x |
1,460,817,305,000 |
Is it possible to configured UFW to allow UPNP between computers in the home network?
Everything works if I turn off the firewall. I can see in syslog the firewall is blocking me. I've tried all sorts of tips out there like open 1900, 1901, 5353, these all seemed like random attempts. I know the issue is UPNP reque... |
You seem to be close to the answer. The easiest thing to do is to temporarily turn off the firewall let your media boxes run for a couple of minutes and then check the output from lsof
lsof -i :1025-9999 +c 15
The -i lists "files" corresponding to an open port, use -i4 to restrict to IPv4 only. The number list restri... | Uncomplicated Firewall (UFW) and UPNP |
1,460,817,305,000 |
I have two servers
Server1 -> Static IP1
Server2 -> Static IP2
Server2's firewall allows access only from Static IP1
I can connect to Server1 via ssh from anywhere.
How can I connect to Server2 from my PC which is behind a dynamic IP via ssh in one step instead of connecting via ssh to Server1 and then doing anoth... |
If you have OpenSSH 7.3p1 or later, you can tell it to use server1 as a jump host in a single command:
ssh -J server1 server2
See fcbsd’s answer for older versions.
| can I access ssh server by using another ssh server as intermediary [duplicate] |
1,460,817,305,000 |
I installed Webmin, and then set up the firewall like this:
INPUT
SSH port ALLOWED
Webmin port ALLOWED
HTTP port (80) ALLOWED
DROP EVERYTHING ELSE
FORWARDING
no rules
OUTPUT
no rules
If I remove DROP EVERYTHING ELSE from INPUT, everything works.
However, when that rule is added, apt-get doesn't work, and I can't pin... |
Make sure you accept also connection originated from inside. With iptables:
iptables -A INPUT -m state --state ESTABLISHED -j ACCEPT
With Webmin, allow
Connection states EQUALS Existing Connection
| Which ports should I open for apt-get to work? |
1,460,817,305,000 |
Running iptables -L -n gives me the following info:
Chain IN_ZONE_work_allow (1 references)
target prot opt source destination
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:22 ctstate NEW
ACCEPT udp -- 0.0.0.0/0 224.0.0.251 udp dpt:5353 ctsta... |
It means you are allowed to receive multicast dns packets (dpt = destination port, 5353 = multicast dns), udp is the protocol, 224.0.0.251 is a destination multicast address, 0.0.0.0/0 means from anywhere. ctstate new means if the connection is new (packets related to "not new", ie, established, connections would be a... | What does this firewall record mean? |
1,460,817,305,000 |
On Debian 10 buster I am having problems with docker containers unable to ping the docker host or even docker bridge interface, but able to reach the internet.
Allowing access as in related questions here, doesn't fix it in my case.
Seems iptables/nftables related, and I can probably figure out what to do, if I could ... |
You can use nftrace to trace packet flows. It's very verbose but doesn't go to kernel logs but instead is distributed over multicast netlink socket (ie if nothing listens to them, traces just go to "/dev/null").
If you really want to trace everything, trace from prerouting and output at a low priority. Better use a se... | How to properly log and view nftables activity? |
1,460,817,305,000 |
The L7-filter project appears to be 15 years old, requires kernel patches with no support for kernels past version 2.6, and most of the pattern files it has appear to have been written in 2003.
Usually when there's a project that is that old, and that popular, there are new projects to replace it, but I can't find any... |
You must be talking of (the former) project Application Layer Packet Classifier for Linux, which was implemented as patches, for the 2.4 and the 2.6 kernels.
The major problem with this project, is that the technology which it proposed to control, quickly outpaced the usefulness and efficacy of the implementation.
Th... | Is there a way to do layer 7 filtering in Linux? |
1,460,817,305,000 |
We are using iptables firewall. It is logging and dropping various packages depending on its defined rules.
Iptables log file entries look like:
2017-08-08T19:42:38.237311-07:00 compute-nodeXXXXX kernel: [1291564.163235] drop-message : IN=vlanXXXX OUT=cali95ada065ccc MAC=24:6e:96:37:b9:f0:44:4c:XX:XX:XX:XX:XX:XX SRC... |
There are counters for each rule in iptables which can be shown with the -v option. Add -x to avoid the counters being abbreviated when they are very large (eg 1104K). For example,
$ sudo iptables -L -n -v -x
Chain INPUT (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
39 2... | How to get metrics about dropped traffic via iptables? |
1,460,817,305,000 |
I am going to use iptables for port forwarding to listen on requests from my LAN on port 8080 and answer with container at port 80, like this:
iptables -t nat -A PREROUTING -p tcp -d 192.168.1.15 --dport 8080 -j DNAT --to 10.0.3.103:80
I am not sure if the rule is right (feel free to correct it), but the question is:... |
There is a comment module for iptables which should do what you need. When adding a rule, one can add a comment like this:
iptables -A INPUT -p icmp -j ACCEPT -m comment --comment "Allow incoming ICMP"
| How to tag IPTABLES rules? |
1,460,817,305,000 |
We have two apps running (on top of linux) and both communicates through port 42605. I wanted to quickly verify if this is the only port that's been used for communication between them. I tried below rule, but it doesn't seems to work. So, just wanted to get this clarified, if I am doing it wrong.
Following is the seq... |
We can make INPUT policy drop to block everything and allow specific ports only
# allow established sessions to receive traffic
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
# allow your application port
iptables -I INPUT -p tcp --dport 42605 -j ACCEPT
# allow SSH
iptables -I INPUT -p tcp --dport ... | Iptables rule to allow only one port and block others |
1,460,817,305,000 |
If we use firewall-cmd to open a port before starting the firewalld service, it will fail saying "firewalld is not running".
If I start firewalld I'm getting disconnected from the remote server, I'm running SSH on a different port than 22.
How am I supposed to configure a remote server without losing connection to it?... |
firewall-offline-cmd is an offline command line client of the
firewalld daemon. It should be used only if the firewalld service is
not running. For example to migrate from system-config-firewall/lokkit
or in the install environment to configure firewall settings with
kickstart.
A few basic examples:
# firewall-offli... | Set up firewalld on CentOS before starting it |
1,460,817,305,000 |
Many people don't clear the conntrack table when they want to reload their firewall rules. When you have some ESTABLISHED connections, all the sessions won't be affected when you add a rule that blocks some of the connections in question (in the NEW state). The only way to make sure that this isn't going to happen is ... |
OpenWRT maintains several specific kernel patches. Amont them, there is the specific patch providing the feature you complain is lacking in Debian. It is actually available only in OpenWRT.
Choosing a git history near the asked question's timeline, for kernel 4.4.
600-netfilter_conntrack_flush.patch:
static const str... | Why "echo f" in the case of clearing conntrack table doesn't work on debian? |
1,298,910,509,000 |
I'm having a friend behind a firewall, with a windows computer. I'm having a Linux machine at home which is not behind a firewall.
I want to have an rdesktop connection to his machine, without using any intermediate service such as LogMeIn.
My plan is:
Have him SSH to my machine (SSH is allowed by the firewall), and ... |
I would prefer to setup a vpn (openvpn for example) with server on your machine and client on your friend's machine. When he wants you to connect, he opens the vpn (no login involved on your machine) and you open your remote desktop client to his machine's IP (at least with openvpn, you can assign a "fixed" IP to his ... | tunneling VNC/rdesktop over ssh |
1,298,910,509,000 |
I am trying to open some ports in CentOS 7.
I am able to open a port with the following command:
firewall-cmd --direct --add-rule ipv4 filter IN_public_allow 0 -m tcp -p tcp --dport 7199 -j ACCEPT
By inspecting via iptables -L -n, I get the confirmation that the setting was successful:
Chain IN_public_allow (1 refere... |
--direct commands cannot be made permanent. Use equivalent zone command:
sudo firewall-cmd --zone=public --add-port=7199/tcp --permanent
sudo firewall-cmd --reload
and to check the result:
sudo firewall-cmd --zone=public --list-all
| how to make firewall changes permanent via firewall-cmd? |
1,298,910,509,000 |
I want to create a dynamic blacklist with nftables. Under version 0.8.3 on the embedded device I create a ruleset looks like this with nft list ruleset:
table inet filter {
set blackhole {
type ipv4_addr
size 65536
flags timeout
}
chain input {
type filter hook input priority 0; policy drop;
ct st... |
The hydra tool connects concurrently multiple times to the SSH server. In OP's case (comment: hydra -l <username> -P </path/to/passwordlist.txt> -I -t 6 ssh://<ip-address>) it will use 6 concurrent threads connecting.
Depending on server settings, one connection could typically try 5 or 6 passwords and taking about 1... | Create dynamic blacklist with nftables |
1,298,910,509,000 |
Deployment:
VM -- (eth0)RPI(wlan0) -- Router -- ISP
^ ^ ^ ^
DHCP Static DHCP GW
NOTE: RPI hostname: gateway
• The goal was to make VMs accessible from the outside the network. Accomplished, according to the tutorial https://www.youtube.com/watch?v=IAa4tI4JrgI, via the Port Forwarding ... |
Question 1.) Sorry, it looks like you've misunderstood a few things.
dhcpcd is a DHCP client daemon, which is normally started by NetworkManager or ifupdown, not directly by systemd. It is what will be handling the IP address assignment for your wlan0.
You can use dhcpcd as started by systemd if you wish, however tha... | "Not running dhcpcd because /etc/network/interfaces defines some interfaces that will use a DHCP client or static address" |
1,298,910,509,000 |
I have two network interfaces: eth0, and p2p1. My default zone is set to public. I would like to permanently set p2p1 to be trusted.
In order the achieve this I run:
sudo firewall-cmd --permanent --change-zone=p2p1 --zone=trusted
after that I get this:
The interface is under control of NetworkManager, setting zone t... |
I figured it out -- finally.
I added a script file zone-for-p2p1 inside the directory /etc/network/if-up.d.
zone-for-p2p1 script file content:
#!/bin/sh
#
# sets zone for p2p1 adapter to "trusted"
# to find out adapter name run "nmcli con show | grep p2p1"
#
nmcli con mod "netplan-p2p1" connection.zone trusted
Then... | setting firewall-cmd --permanent is not sticking after reboot |
1,298,910,509,000 |
Can someone give me a hint on how to setup a basic deny rule whenever any TCP request is sent to a specific IP address? I am using the PF packet filter. Any help?
|
The most basic form would look like this, in your /etc/pf.conf config:
block from any to 192.0.2.2
# which is equivalent to:
block drop from any to 192.0.2.2
By default this block action will drop packets silently on all interfaces, from any source IP, in both directions. Because a client is unaware it is being bloc... | Block outgoing connections to certain IP using PF |
1,298,910,509,000 |
I have an embedded Linux on some network device. Because this device is pretty important I have to make many network tests (I have a separate device for that). These tests include flooding my device with ARP packets (normal packets, malformed packets, packets with different size etc.)
I read about different xx-tables ... |
What xx-tables is the best to filter (limit, not drop) ARP packets?
iptables
iptables starts from IP layer: it's already too late to handle ARP.
arptables
While specialized in ARP, arptables lacks the necessary matches and/or targets to limit rather than just drop ARP packets. It can't be used for your purpose.
ebta... | Best way to filter/limit ARP packets on embedded Linux |
1,298,910,509,000 |
Without SSL, FTP works fine over a stateful Firewall, like netfilter (iptables) + the nf_conntrack_ftp kernel module like this:
# modprobe nf_conntrack_ftp
# iptables -A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
# iptables -A INPUT -p tcp --dport 21 -j ACCEPT
The problem is that, when SSL is used, t... |
There are several modes with SSL and FTP:
Implicit SSL, that is SSL from start (usually port 990) and never plain text. In this case you get no clear text information at the firewall about the dynamic data ports and thus cannot restrict communication to only these ports.
Explicit SSL with "AUTH TLS" command before lo... | Proper way to handle FTP over SSL with restrictive firewall rules? |
1,298,910,509,000 |
In iptables-extensions(8) the set module is described and it is discussed that it is possible to react to the presence or absence of an IP or more generally a match against an IP set.
However, it does not seem that there is a way to append items to an IP set on the fly using an iptables rule.
The idea being that if I ... |
Turns out it is possible, using the SET target described in iptables-extensions(8).
SET
This module adds and/or deletes entries from IP sets which can be defined by ipset(8).
--add-set setname flag[,flag...]
add the address(es)/port(s) of the packet to the set
--del-set setname flag[,flag...]
... | Can iptables rules manipulate IP sets? |
1,298,910,509,000 |
I have an OpenWRT gateway (self-built 19.07, kernel 4.14.156) that sits on a public IP address in front of my private network. I am using nftables (not iptables).
I would like to expose a non-standard port on the public address, and forward it to a standard port on a machine behind the gateway. I think this used to ... |
You are not translating the port number. When the external connection is to port 1234, this is not a problem. But when it is to 4321, the dnat passes through to port 4321 on the internal server, not port 1234. Try
tcp dport { 1234, 4321 } log prefix "nat-pre " dnat 172.23.32.200:1234;
You do not need to translate ... | Port forwarding & NAT with nftables |
1,298,910,509,000 |
On my desktop, I want to configure iptables pretty strictly. I see no reason why I need to allow anything except for internet traffic that I initiated. And maybe even that could be limited to only a few ports. What are the basic rules that can close off my desktop? I only need:
To browse the internet
Download email
... |
The following rules will allow all outgoing connections, but block any incoming connections. The INPUT and FORWARD chains are set to reject packets by default, the OUTPUT chain is set to accept packets by default, and the last rule allows incoming packets which are part of existing connections (which in this case can ... | What is a solid iptables configuration for my desktop? |
1,298,910,509,000 |
I'm planning to add the following rules to iptables to stop ssh brute force attack which are common these days.
-A INPUT -i eth0.103 -p tcp -m tcp --dport 4522 -m state --state NEW -m recent --set --name SSH --rsource
-A INPUT -i eth0.103 -p tcp -m tcp --dport 4522 -m recent --rcheck --seconds 30 --hitcount 4 --r... |
Question #1: When the documentation says "log it to the system log once, then immediately reject it and forget about it" what do they mean by forget about it?
Means that the message will show up in the logs, but only once, so your log won't get polluted with a continuous stream of messages every time the rule is tri... | How to Block SSH Brute Force via Iptables and How does it work? |
1,298,910,509,000 |
I am trying to establish a whitelist of clients that have successfully logged into the system, using ipset. What options do I have to let an entry age so that I can later discard it based on its age?
Is there a better method than the idea outlined below?
I have not found anything provided by ipset directly, so I am tr... |
Turns out the man page describes what I was looking for. It's aptly called timeout and can be specified when adding entries to an IP set. I missed it due to a search for wrong terms.
A default timeout value can be given when creating a set and later for each entry added - if it is desired to override the set default.
... | How can I let ipset entries "age"? |
1,298,910,509,000 |
I made a very simple bash script (echo at start, runs commands, echos at end) to add approx 7300 rules to iptables blocking much of China and Russia, however it gets through adding approximately 400 rules before giving the following error for every subsequent attempt to add a rule to that chain:
iptables: Unknown erro... |
OK, I figured it out.
I should have mentioned that I had a Virtuozzo container for my VPS. http://kb.parallels.com/en/746 mentions the following:
Also it might be required to increase numiptent barrier value to be
able to add more iptables rules:
~# vzctl set 101 --save --numiptent 400
FYI: The container has to b... | Can't add large number of rules to iptables |
1,298,910,509,000 |
I'm using Ubuntu 18.04 on embedded system and I need to choose a firewall app between the followings: ufw, nftables, iptables.
Can you recommend one of them and why its better than the others?
Thanks
|
There are essentially two separate firewall stacks in the kernel: the older iptables-based stack, and the newer nftables-based stack. However, because some programs are designed to work with one and some with the other, and mixing and matching tends to cause lots of hard-to-troubleshoot breakage, on most modern syste... | choosing firewall: ufw vs nftables vs iptables |
1,298,910,509,000 |
There's this nice saying from Ubuntu: no open ports on the default install. Other Linux OS's look similar, including Fedora. Configuring firewall policies can be a pain in the neck, so this is a great default to have.
Ubuntu specifically exempt the DHCP client (essential) and mDNS. (Without firewall zones to distin... |
On 23/11/12 12:50, Gene Czarcinski wrote:
Libvirt is in the process of changing for using bind-interface to using
bind-dynamic to fix a security related issue where dnsmasq was
responding to port 53 queries which did not occur on an address on the
virtual network interface that instance of dnsmasq was supportin... | Is libvirt dnsmasq exposed to the network, if I run Fedora without a firewall? |
1,298,910,509,000 |
One of the most common recommendations that I read for users that recently installed Linux Mint is to enable their firewall, which is pretty simple to do. But why is the firewall off by default in the first place? Is there any reason for this?
|
Link Mint is an Ubuntu-based distribution intended for desktop systems. One of its chief priorities is "ease of use" so a firewall just puts into play something that could break things for users. It's easier if the firewall only gets turned on if the operator is someone who knows what such a thing even is versus a nov... | Why is the firewall off by default with Linux Mint? |
1,298,910,509,000 |
Suppose I am logged into a server via ssh. While in the session, I change the firewall config to block all traffic.
When I tried this previously with FreeBSD and pf, the current connection was broken. When I try it now, the current connection remains active but ping (and new connections) doesn't work. I am not sure if... |
"Should changing firewall settings to block all interrupt ongoing ssh session"
The answer is, maybe. It depends on the precise rules, where the block all appears, and whether existing SSH connections are managed under keep state (or modulate state). set optimization is also relevant; a firewall set to aggressively p... | Should changing firewall settings to block all interrupt ongoing ssh session |
1,298,910,509,000 |
On a RHEL 7 server, /etc/hosts.allow has a number of IP addresses with full access. The firewall (confirmed with firewall-cmd), there are no specific sources defined, and the default zone allows certain ports and services.
Which takes precedence? Or for a specific example, if an IP address listed in /etc/hosts.allow... |
The answer is no.
Neither between the TCP Wrapper system and the firewall settings takes precedence; rather, they work as layers.
/etc/hosts.allow and /etc/hosts.deny are the host access control files used by the TCP Wrapper system. Each file contains zero or more daemon:client lines. The first matching line is consid... | Which takes precedence: /etc/hosts.allow or firewalld? |
1,298,910,509,000 |
Consider these two sets of rules:
Set A
-A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
-A INPUT -j REJECT
-A OUTPUT -j ACCEPT
Set B
-A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
-A INPUT -j REJECT
-A OUTPUT -m conntrack --ctstate NEW,ESTABLISHED,RELATED -j ACCEPT
Previously I was under... |
[I unfortunately had to remove references from the below due to the disappearance of iptables.info so you may have to trust me on a couple of points.]
Without the NEW rules nothing is laced into the db and thus ESTABLISHED,RELATED will never match anything.
This is false.
There are five userland states (there are m... | How does iptables recognize packet state? |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.