LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to add a rule in user define chain. (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-add-a-rule-in-user-define-chain-847398/)

gardenair 11-30-2010 02:40 AM

How to add a rule in user define chain.
 
Hi,

I have created a new user define chain

# iptanles -N blacklist

Normally when we add a new rule it automatically insert in the default iptable but when we create a user define chain then how can I add my rules in this chain ?

2- How can i execute the user define chain ?

thanks in advance
garden

unSpawn 11-30-2010 09:51 AM

Basically you give the name of the chain as first argument with -A, -I and -R after that the rule contents you want to add, insert or replace. See 'man iptables'.

gardenair 12-01-2010 01:30 AM

Thanks unSpawn for the reply. well if you kindly write a simple example then it will be clear for me to understand. According to my understand i did as following

Code:

# iptables -t blacklist -A INPUT -s 192.168.1.10 -j drop
but this does't accept by the kernel.I know that it is wronge but what will be the valid rule ?
please guide me ,
thanks in advance.

unSpawn 12-01-2010 10:30 AM

If you read 'man iptables' like I suggested then you'd see "-t" is for tables (see `cat /proc/net/ip_tables_names`) and usually that'll be "filter". In the "filter" table "INPUT" refers to one of the default chains. So you rule would become 'iptables -t filter -A blacklist -s 192.168.1.10 -j DROP'.


All times are GMT -5. The time now is 09:45 AM.