Score:0

firewall-cmd block outgoing connection to an ip list

in flag

I have searched a lot about this, this is possible to have many of these commands one for each ip:

/usr/bin/firewall-cmd --direct --add-rule ipv4 filter OUTPUT 0 -d ::FFFF:85.185.0.0/112 -j REJECT
/usr/bin/firewall-cmd --direct --add-rule ipv4 filter OUTPUT 0 -d ::FFFF:85.198.0.0/115 -j REJECT
/usr/bin/firewall-cmd --direct --add-rule ipv4 filter OUTPUT 0 -d ::FFFF:85.198.48.0/116 -j REJECT
...

But since I have more than 3 thousand of these it takes for ever to add these after each reboot and it's a real pain, also my server froze completely and I had to reboot it by force!

So that's not a great idea!

Searching more I found that I can use --add-entries-from-file but still couldn't find a way to do that for only outgoing not also incoming!

firewall-cmd --permanent --ipset=blacklist --add-entries-from-file=./cn.zone
firewall-cmd --permanent --zone=drop --add-source=ipset:blacklist
firewall-cmd --reload

I want my ip list to be only blocked for outgoing not incoming, also I have a list of ipv6 as well as ipv4 which I'd like to block as well.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.