Assign IPtables rules to three different Ethernet Interfaces on same Server
Linux - SecurityThis forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: RHEL, Fedora,Ubuntu, Centos, Windows XP & Windows 7
Posts: 44
Rep:
Assign IPtables rules to three different Ethernet Interfaces on same Server
HI,
Please help / suggest on my iptables issue. i having a server Centos 6.5 which ip is "10.0.0.2". server is in NIC bonding using eth0 & eth1. i am able to successfully implement iptables rule using below mentioned script on bond0.
##########################################
#!/bin/bash
/sbin/iptables -F
/sbin/iptables -A INPUT -i lo -j ACCEPT
### For Established connections
/sbin/iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
### Drop All connections
/sbin/iptables --policy INPUT DROP
### Accept only Related and established connections
/sbin/iptables -A FORWARD -i bond0 -m state --state RELATED,ESTABLISHED -j ACCEPT
/sbin/iptables -A OUTPUT -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
/sbin/iptables --policy OUTPUT ACCEPT
/sbin/iptables-save
##########################################
But now we wanted to assign two more ip's on the same server by creating interface alias. i successfully created & assigned ip to newly created bond0:1 (IP 10.0.0.3) & bond0:2 (IP 10.0.0.4)
But i face the issue that after running above mentioned script using command "sh iptables.sh 10.0.0.2" i am not able to connect ip's which assigned to bond0:1 & bond0:2 interface. i am confused that even after mentioning interface name in script iptables applying its rule to all interface & rejecting incoming request for other interface IP's (eg. bond0:1 & bond0:2).
Please advice how can implement three different iptables rules for three different Ethernet interfaces. i also tried using below mentioned script but still unsuccessful.
Please guide what i am missing or my mistake.
######################################
#!/bin/bash
/sbin/iptables -F
/sbin/iptables -A INPUT -i lo -j ACCEPT
### For Established connections
/sbin/iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
### Drop All connections
/sbin/iptables --policy INPUT DROP
### Accept only Related and established connections
/sbin/iptables -A FORWARD -i bond0 -m state --state RELATED,ESTABLISHED -j ACCEPT
/sbin/iptables -A FORWARD -i bond0:1 -m state --state RELATED,ESTABLISHED -j ACCEPT
/sbin/iptables -A FORWARD -i bond0:2 -m state --state RELATED,ESTABLISHED -j ACCEPT
/sbin/iptables -A OUTPUT -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
/sbin/iptables --policy OUTPUT ACCEPT
/sbin/iptables-save
######################################
But now we wanted to assign two more ip's on the same server by creating interface alias. i successfully created & assigned ip to newly created bond0:1 (IP 10.0.0.3) & bond0:2 (IP 10.0.0.4)
But i face the issue that after running above mentioned script using command "sh iptables.sh 10.0.0.2" i am not able to connect ip's which assigned to bond0:1 & bond0:2 interface. i am confused that even after mentioning interface name in script iptables applying its rule to all interface & rejecting incoming request for other interface IP's (eg. bond0:1 & bond0:2).
You only have one interface it is bond0
Any documentation your looking at that uses the int:alias notation is over a decade out of date and I don't think it ever applied to iptables.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.