LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 01-06-2021, 12:48 AM   #1
inukaze
Member
 
Registered: Feb 2011
Location: Venezuela - Caracas
Distribution: Slackware64 14.2, Slackware 14.2, Gentoo, Devuan, gNewSense, GoboLinux, Leeenux, Porteus
Posts: 270

Rep: Reputation: 26
Question Slackware(64) 14.2 - Iptables Rules


Hi there again, yestarday i am trying to open and test some ports on my Slackware, on my Router the ports are open.

Short version :
I want to Open & Test the ports :
Code:
RDP       : 3389
VNC       : 5900-5910
Kaillera  : 27888
IceCast1? : 8000
IceCast2? : 27950-27965
SMP/VLC   : 5298-5353
RetroArch : 55435
Mumble    : 64738
Torrents  : 6881-6891
SSH       : 22
FTP       : 20-21
Telnet    : 23
Well the thing was yesterday make trying to make that, testing with commands
iptables, nc, netstat

i delete the rules at all, the disaster was i don't have access to data traffic on my eth0, incluse the ethtool show me "Link detected: no", well i know that can be solve re-connecting the physical cable again xD.

After hours trying solutions i watch on internet, and not one work for me, i think i had an Slackware 14.2 of 32 Bits installed on another partition with the same configuration.

my dunno is "Which is the right way to apply with iptable the rules like" :
Code:
*mangle
:PREROUTING ACCEPT [988:95064]
:INPUT ACCEPT [988:95064]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [1868:149163]
:POSTROUTING ACCEPT [1868:149163]

*nat
:PREROUTING ACCEPT [28:6181]
:INPUT ACCEPT [28:6181]
:OUTPUT ACCEPT [501:33485]
:POSTROUTING ACCEPT [501:33485]

*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [535:43223]
=============================================================
Extended Version :

i make a backup of that iptables rules and import to my Slackware64 14.2, the file had the follow content :
Code:
# Generated by iptables-save v1.6.0 on Wed Jan  6 01:45:02 2021
*mangle
:PREROUTING ACCEPT [988:95064]
:INPUT ACCEPT [988:95064]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [1868:149163]
:POSTROUTING ACCEPT [1868:149163]
COMMIT
# Completed on Wed Jan  6 01:45:03 2021
# Generated by iptables-save v1.6.0 on Wed Jan  6 01:45:03 2021
*nat
:PREROUTING ACCEPT [28:6181]
:INPUT ACCEPT [28:6181]
:OUTPUT ACCEPT [501:33485]
:POSTROUTING ACCEPT [501:33485]
COMMIT
# Completed on Wed Jan  6 01:45:03 2021
# Generated by iptables-save v1.6.0 on Wed Jan  6 01:45:03 2021
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [535:43223]
-A INPUT -i lo -j ACCEPT
-A INPUT -i eth0 -j ACCEPT
-A INPUT -i eth1 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 53 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 443 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 8000 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 8080 -j ACCEPT
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m tcp --tcp-flags FIN,SYN,RST,ACK SYN -j ACCEPT
-A INPUT -p icmp -m icmp --icmp-type 8 -j REJECT --reject-with icmp-host-unreachable
-A INPUT -p udp -m udp --dport 123 -j ACCEPT
COMMIT
# Completed on Wed Jan  6 01:45:04 2021
Someone can sayme each command with iptables to apply exactaly that same configuration manually ?

my dunno is "Which is the right way to apply with iptable the rules like" :
Code:
*mangle
:PREROUTING ACCEPT [988:95064]
:INPUT ACCEPT [988:95064]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [1868:149163]
:POSTROUTING ACCEPT [1868:149163]

*nat
:PREROUTING ACCEPT [28:6181]
:INPUT ACCEPT [28:6181]
:OUTPUT ACCEPT [501:33485]
:POSTROUTING ACCEPT [501:33485]

*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [535:43223]
i know the "-A INPUT . . ." just need to be precceded by iptables command like :
Code:
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -i eth0 -j ACCEPT
iptables -A INPUT -i eth1 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 53 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 443 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 8000 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 8080 -j ACCEPT
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A INPUT -p tcp -m tcp --tcp-flags FIN,SYN,RST,ACK SYN -j ACCEPT
iptables -A INPUT -p icmp -m icmp --icmp-type 8 -j REJECT --reject-with icmp-host-unreachable
iptables -A INPUT -p udp -m udp --dport 123 -j ACCEPT
I use the chroot environment for make the backup of iptables rules from my another distro :

Code:
TARGET=/media/Slack32 ; \
mount --rbind /proc $TARGET/proc ; \
mount --make-rslave $TARGET/proc ; \
mount --rbind /sys $TARGET/sys ; \
mount --make-rslave $TARGET/sys ; \
mount --rbind /dev $TARGET/dev ; \
mount --make-rslave $TARGET/dev ; \
mount --bind /etc/fstab $TARGET/etc/fstab ; \
mount --bind /etc/resolv.conf $TARGET/etc/resolv.conf ; \
linux32 chroot $TARGET /bin/bash -l
Inside the chroot environment i make a backup of the iptables rules with
Code:
iptables-save > iptables-slack32.iptables
i exit and remount the devices on my Slackware64 14.2
Code:
exit ; umount -l $TARGET ; mount -a
i go the the mountpoint of Slackware 14.2 and use iptables-restore for read the another configuration file to import
[CODE]cd /media/Slack32 ; su -c "iptables-restore < ./iptables-slack32.iptables ; iptables-save ; ldconfig" root

The final thing i do was :
Code:
/etc/rc.d/rc.NetworkManager stop
/etc/rc.d/rc.inet1 stop
/etc/rc.d/rc.inet2 stop
/etc/rc.d/rc.inetd stop

/etc/rc.d/rc.inet1 start
/etc/rc.d/rc.inet2 start
/etc/rc.d/rc.inetd start
/etc/rc.d/rc.NetworkManager start

ip link set eth0 down
ip link set eth0 up
And i got internet again.

Last edited by inukaze; 01-06-2021 at 12:49 AM.
 
Old 01-12-2021, 02:51 PM   #2
ludist
Member
 
Registered: Nov 2005
Location: Greece
Distribution: Slackware
Posts: 172

Rep: Reputation: 21
To my understanding, you don't have a firewall. No rejects in iptables, so you don't need to open anything on iptables. Everything is open by default.

I don't understand what you are trying to accomplish.

Those are my iptables -L -n
Code:
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     all  --  192.168.178.0/24     0.0.0.0/0           
DROP       tcp  --  0.0.0.0/0            0.0.0.0/0            state NEW tcp dpt:22 recent: UPDATE seconds: 15 name: DEFAULT side: source mask: 255.255.255.255
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0            state NEW tcp dpt:22 recent: SET name: DEFAULT side: source mask: 255.255.255.255
DROP       tcp  --  0.0.0.0/0            0.0.0.0/0            state NEW tcp dpt:22 recent: UPDATE seconds: 15 name: DEFAULT side: source mask: 255.255.255.255
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0            state NEW tcp dpt:22 recent: SET name: DEFAULT side: source mask: 255.255.255.255
DROP       tcp  --  0.0.0.0/0            0.0.0.0/0            state NEW tcp dpt:110 recent: UPDATE seconds: 15 name: DEFAULT side: source mask: 255.255.255.255
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0            state NEW tcp dpt:110 recent: SET name: DEFAULT side: source mask: 255.255.255.255

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
This is the iptables-save
Code:
# Generated by iptables-save v1.6.0 on Tue Jan 12 22:44:53 2021
*mangle
:PREROUTING ACCEPT [595904:773015717]
:INPUT ACCEPT [593812:772744457]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [380833:33706959]
:POSTROUTING ACCEPT [380833:33706959]
COMMIT
# Completed on Tue Jan 12 22:44:53 2021
# Generated by iptables-save v1.6.0 on Tue Jan 12 22:44:53 2021
*filter
:INPUT ACCEPT [593791:772742861]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [380803:33704820]
-A INPUT -s 192.168.178.0/24 -j ACCEPT
-A INPUT -i eth1 -p tcp -m state --state NEW -m tcp --dport 22 -m recent --update --seconds 15 --name DEFAULT --mask 255.255.255.255 --rsource -j DROP
-A INPUT -i eth1 -p tcp -m state --state NEW -m tcp --dport 22 -m recent --set --name DEFAULT --mask 255.255.255.255 --rsource -j ACCEPT
-A INPUT -i wlan0 -p tcp -m state --state NEW -m tcp --dport 22 -m recent --update --seconds 15 --name DEFAULT --mask 255.255.255.255 --rsource -j DROP
-A INPUT -i wlan0 -p tcp -m state --state NEW -m tcp --dport 22 -m recent --set --name DEFAULT --mask 255.255.255.255 --rsource -j ACCEPT
-A INPUT -i eth1 -p tcp -m state --state NEW -m tcp --dport 110 -m recent --update --seconds 15 --name DEFAULT --mask 255.255.255.255 --rsource -j DROP
-A INPUT -i eth1 -p tcp -m state --state NEW -m tcp --dport 110 -m recent --set --name DEFAULT --mask 255.255.255.255 --rsource -j ACCEPT
COMMIT
# Completed on Tue Jan 12 22:44:53 2021
 
1 members found this post helpful.
  


Reply

Tags
iptables, slackware 14.2/x86_64



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] /etc/udev/rules.d/40-libsane.rules and /etc/udev/rules.d/S99-2000S1.rules missing LABEL=libsane_rules_end mumahendras3 Slackware 6 03-09-2020 02:27 AM
auditctl -l not showing any rules even though i have rules written in audit.rules alphaguy Linux - Security 1 02-07-2014 05:28 PM
iptables 1.27a still loading rules after installing iptables 1.3.0 yawe_frek Linux - Software 1 06-07-2007 09:50 PM
iptables v1.2.9: Unknown arg `/sbin/iptables' Try `iptables -h' or 'iptables --help' Niceman2005 Linux - Security 4 12-29-2005 08:20 PM
IPTABLES - rules in /etc/sysconfig/iptables The_JinJ Linux - Newbie 6 11-20-2004 01:40 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 02:48 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration