How Do I run firewall script as soon as eth0 interface brings up?
At home I connect to Internet via ADSL modem.
As soon as my eth0 comes up I would like to have my firewall script get executed and setup IPTABLE for me
Earlier I used to type command /root/fs.dsl.start via sudo. However while reading man page of interface file I came across post-up option. Following step demonstrates usage of post-up option:
1) Copy firewall script to /etc/network/if-up.d/ directory:
# mv /root/fw.dsl.start /etc/network/if-up.d/
2) Open Debian networking configuration file /etc/network/interfaces:
# vi /etc/network/interfaces
3) Setup post-up option, append following line to eth0 configuration section:
# post-up /etc/network/if-up.d/fw.dsl.start
Where,
- post-up command : Run command after bringing the interface up.
Here is my /etc/network/interfaces after modification:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
name Ethernet LAN card
address 192.168.1.1
netmask 255.255.255.0
broadcast 192.168.1.255
network 192.168.1.0
gateway 192.168.1.254
post-up /etc/network/if-up.d/fw.dsl.start
4) Save file and restart networking:
# /etc/init.d/networking restart
5)Verify that iptables rules are loaded:
# iptables -L -n
Tip if you are new to Ethernet (LAN network) configuration under Debian Linux use following etherconf package to configure or reconfigure network. If etherconf is not installed use apt-get to install it:
a) Install etherconf:
# apt-get install etherconf
b) Configure network under Debian Linux:
# dpkg-reconfigure etherconf
E-mail this to a friend
Printable version
You may also be interested in other helpful articles:
- How do I build a Simple Linux Firewall for DSL/Dial-up connection?
- Howto Setup Linux as router for ppp dial up (PSTN/ISDN) connections
- Iptables allow CIPE connection request
- Linux Identifying ~ Which NIC Is Which - Which NIC is eth0?
- How to setup Linux as a router for DSL, T1 line etc
Discussion on This Article:
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!


How do I do this on Fedora?
Jevin,
Use /etc/eth0/ip-up.local
file.
HTH
How do i use it in Ubuntu? why isn’t working when it is a Debian based….
In section 3) hash mark should be removed from line
# post-up /etc/network/if-up.d/fw.dsl.start