SlideShare a Scribd company logo
Linux Firewalls (Ubuntu IPTables)
Introduction
Linux Firewalls is the way to make our Linux OS more secure and safe because it enables you to
control your connection ports and your inbound and outbound traffic. To control this inbound and
outbound traffic, Linux OS uses a software called iptables. IPTables is actually a net filter software
which is integrated with the kernel implementation, it also provides filtering features that can filter
the inbound and outbound in routed traffics to our computer system.
IPTables Organization
The iptables organizes its information in tables, each tables consists of number of chains and each
chain consists of many rules, these rules are responsible for controlling the system traffic. Each
Chain has a default taken action called chain default policy and it used when there is no rule created
for a specified service or traffic.
Main IPTabels
1. filter table is the default table.
2. nat table is used to tell the kernel what connections to change and how to change them.
3. mangle table is mainly used for mangling packets.
IPTables Useful Commands
$dpkg-query -l iptables used for listing the packages that matches iptables.
$dpkg-query -s iptables used for recognizing the status of the iptable packages.
$dpkg-query -L iptables used for listing the files and libraries that related to the iptables.
$iptables -h used for getting the iptables help.
$iptables -L used for listing the table chains and the rules of each chain, to specify a
certain table use -t followed by the name of the table.
$iptable -A used to Append a rule to a certain chain.
$iptables -I used for Inserting a rule in a location not only adding it to the
tail of the chain of rules.
$iptable -D used for deleting a rule from a chain in a table.
$iptable -F used for flushing all rules of a chain.
$iptable-save used for saving all current rules and chains of the system in a file.
$iptable-restore used for restoring saved rules from a file.
To open the console in Ubuntu just click as shown
http://en.wikipedia.org/wiki/Dpkg
dpkg is the software at the base of the Debian package management system. dpkg is used to install,
remove, and provide information about .deb packages. dpkg itself is a low level tool; higher level
tools, such as APT, are used to fetch packages from remote locations or deal with complex package
relations. The Debian package "dpkg" provides the dpkg program, as well as several other programs
necessary for run-time functioning of the packaging system.
http://man.he.net/man1/dpkg-query
dpkg-query is a tool to show information about packages listed in the dpkg database.
Options 1
-l, --list package-name-pattern
List packages matching given pattern.
Here we choose the package iptables.
Options 2
-s, --status package-name
Report status of specified package.
Here we choose the package iptables.
Options 3
-L, --listfiles package-name
List files installed to your system from package-name.
Here we choose the package iptables.
http://man.he.net/?topic=iptables&section=all
iptables is used to set up, maintain, and inspect the tables of IP packet filter rules in the
Linux kernel. Each rule can match a set of packets and specify what to do with a packet that
matches.
Options 1
-h, --help
To receive command help.
Options 2
-L, --list -t table-name
List all chains in the selected table. If no table is selected, like every other iptables
command, it applies to the specified table (filter is the default).
Scenario
We will use the VirtualBox as our virtual machine to create two guest machines (Ubuntu and
PCLinux) both of them with network card configured with the virtual LAN that installed by the
VirtualBox.
while Ubuntu machine has another network card configured with NATing to be certain that it will
have an Internet connection from the host machine.
We have to be certain all the three machines are in the same LAN
PCLinux Machine with one Network Card Named eth0 for Virtual LAN
Ubuntu Machine with Network Card called eth0 for NATing
and another Network Card called eth1 for Virtual LAN
Host Machine with a lot of Network Cards
One is called Virtual Box Host-Only Adapter for Virtual LAN
Filter Table (INPUT & OUTPUT Chains)
Example#1
Write a firewall rule to prevent pinging the Ubuntu machine from the PCLinux machine.
Now PCLinux Machine can ping Ubuntu Machine
Now if we just write the shown command, it will prevent the PCLinux Machine from pinging the
Ubuntu Machine
$sudo iptables -A INPUT -p icmp --icmp-type echo-request -s 192.168.56.103 -d 0/0 -j DROP
sudo To take the root privilege.
iptables To start using the iptables.
-A INPUT To add a rule to a specified chain, here we specify the INPUT chain.
(as no table specified we deal with the default table which is the filter table).
-p icmp To specify the used protocol, here we specify the ICMP Protocol
--icmp-type
echo-request
To specify the ICMP type, here we choose the ping (echo-request).
This is option can be used only if we choose icmp as our protocol.
-s 192.168.56.103 To specify the source, here we specify the PCLinux IP
-d 0/0 To specify the destination, here we choose 0/0 which mean all hosts IPs.
-j DROP To specify the Target Action, here we choose DROP Action.
Now as shown the PCLinux Machine ping but no answer
While the host machine can ping both no problem
Example#2
Write a firewall rule to prevent the Ubuntu Machine from pinging any other computer on the
network.
$sudo iptables -A OUTPUT -p icmp --icmp-type echo-request -s 0/0 -d 0/0 -j DROP
Example#3
Write a firewall rule to prevent the Ubuntu Machine from opening the facebook
$sude iptables -A OUTPUT -p tcp -s 0/0 -d www.facebook.com --dport 80 -j DROP
After adding the rule, the Ubuntu Machine can't access the facebook website while other websites
are aavailable like google.com.
Example#4
Delete the firewall rule that we used in Example#1
$sudo iptables -D INPUT -p icmp --icmp-type echo-request -s 192.168.56.103 -d 0/0 -j DROP
It is the same like adding except using -D instead of -A
Exercise#1
Write a firewall rule to prevent the Ubuntu Machine from opening any website.
Exercise#2
Write firewall rules to prevent any client except the PCLinux Machine from accessing the web
server on the Ubuntu Machine.

More Related Content

What's hot

Introduction to firewalls through Iptables
Introduction to firewalls through IptablesIntroduction to firewalls through Iptables
Introduction to firewalls through Iptables
Bud Siddhisena
 
Linux Basic Networking Command
Linux Basic Networking CommandLinux Basic Networking Command
Linux Basic Networking Command
Akhil Nadh PC
 
Networking in linux
Networking in linuxNetworking in linux
Networking in linux
Varnnit Jain
 
Sniffing in a Switched Network
Sniffing in a Switched NetworkSniffing in a Switched Network
Sniffing in a Switched Network
amiable_indian
 
Fosscon 2012 firewall workshop
Fosscon 2012 firewall workshopFosscon 2012 firewall workshop
Fosscon 2012 firewall workshopjvehent
 
Linuxnetworkingcommands
LinuxnetworkingcommandsLinuxnetworkingcommands
Linuxnetworkingcommands
Manikanta Pushadapu
 
Network configuration
Network configurationNetwork configuration
Network configuration
engshemachi
 
Computer networks
Computer networksComputer networks
Computer networks
AshaniPerera5
 
Linuxtutorial
LinuxtutorialLinuxtutorial
Linuxtutorial
Manikanta Pushadapu
 
Router Commands Overview
Router Commands OverviewRouter Commands Overview
Router Commands OverviewMuhammed Niyas
 
TinyOS installation Guide And Manual
TinyOS installation Guide And ManualTinyOS installation Guide And Manual
TinyOS installation Guide And Manual
Ankit Singh
 
Linux Networking Commands
Linux Networking CommandsLinux Networking Commands
Linux Networking Commands
tmavroidis
 
Mote Mote Radio Communication
Mote Mote Radio CommunicationMote Mote Radio Communication
Mote Mote Radio CommunicationAnkit Singh
 
Trace route
Trace routeTrace route
Trace route
NetProtocol Xpert
 
Routing
RoutingRouting
Lession3 Routing
Lession3 RoutingLession3 Routing
Lession3 Routingleminhvuong
 

What's hot (18)

Introduction to firewalls through Iptables
Introduction to firewalls through IptablesIntroduction to firewalls through Iptables
Introduction to firewalls through Iptables
 
Linux Basic Networking Command
Linux Basic Networking CommandLinux Basic Networking Command
Linux Basic Networking Command
 
Networking in linux
Networking in linuxNetworking in linux
Networking in linux
 
Sniffing in a Switched Network
Sniffing in a Switched NetworkSniffing in a Switched Network
Sniffing in a Switched Network
 
Fosscon 2012 firewall workshop
Fosscon 2012 firewall workshopFosscon 2012 firewall workshop
Fosscon 2012 firewall workshop
 
IPTables Primer - Part 2
IPTables Primer - Part 2IPTables Primer - Part 2
IPTables Primer - Part 2
 
Linuxnetworkingcommands
LinuxnetworkingcommandsLinuxnetworkingcommands
Linuxnetworkingcommands
 
Network configuration
Network configurationNetwork configuration
Network configuration
 
Computer networks
Computer networksComputer networks
Computer networks
 
Linuxtutorial
LinuxtutorialLinuxtutorial
Linuxtutorial
 
Router Commands Overview
Router Commands OverviewRouter Commands Overview
Router Commands Overview
 
TinyOS installation Guide And Manual
TinyOS installation Guide And ManualTinyOS installation Guide And Manual
TinyOS installation Guide And Manual
 
Linux Networking Commands
Linux Networking CommandsLinux Networking Commands
Linux Networking Commands
 
Mote Mote Radio Communication
Mote Mote Radio CommunicationMote Mote Radio Communication
Mote Mote Radio Communication
 
Trace route
Trace routeTrace route
Trace route
 
IP Tables Primer - Part 1
IP Tables Primer - Part 1IP Tables Primer - Part 1
IP Tables Primer - Part 1
 
Routing
RoutingRouting
Routing
 
Lession3 Routing
Lession3 RoutingLession3 Routing
Lession3 Routing
 

Similar to 03 linuxfirewall1

IP Tables And Filtering
IP Tables And FilteringIP Tables And Filtering
IP Tables And Filtering
SuperstarRr
 
Iptables presentation
Iptables presentationIptables presentation
Iptables presentation
Emin Abdul Azeez
 
IPTABLES
IPTABLESIPTABLES
IPTABLES
Tan Huynh Cong
 
Linux Commands
Linux CommandsLinux Commands
Linux Commands
lucita cabral
 
Firewalls rules using iptables in linux
Firewalls rules using iptables in linuxFirewalls rules using iptables in linux
Firewalls rules using iptables in linux
aamir lucky
 
Firewall
FirewallFirewall
Creating a firewall in UBUNTU
Creating a firewall in UBUNTUCreating a firewall in UBUNTU
Creating a firewall in UBUNTU
Mumbai University
 
Managing the system and network connection Linux
Managing the system and network connection LinuxManaging the system and network connection Linux
Managing the system and network connection Linux
Shriharsh Shendre
 
Linux internet server security and configuration tutorial
Linux internet server security and configuration tutorialLinux internet server security and configuration tutorial
Linux internet server security and configuration tutorial
annik147
 
IP tables and Filtering
IP tables and FilteringIP tables and Filtering
IP tables and Filtering
Aisha Talat
 
Linux System Monitoring basic commands
Linux System Monitoring basic commandsLinux System Monitoring basic commands
Linux System Monitoring basic commands
Mohammad Rafiee
 
iptables 101- bottom-up
iptables 101- bottom-upiptables 101- bottom-up
iptables 101- bottom-up
HungWei Chiu
 
CN 1.docx
CN 1.docxCN 1.docx
nwlab-ex1.pdf
nwlab-ex1.pdfnwlab-ex1.pdf
nwlab-ex1.pdf
Jayaprasanna4
 
IPTABLES_linux_Firewall_Administration (1).pdf
IPTABLES_linux_Firewall_Administration (1).pdfIPTABLES_linux_Firewall_Administration (1).pdf
IPTABLES_linux_Firewall_Administration (1).pdf
mpassword
 
The ifconfig Command
The ifconfig CommandThe ifconfig Command
The ifconfig Command
Kevin OBrien
 
an_introduction_to_network_analyzers_new.ppt
an_introduction_to_network_analyzers_new.pptan_introduction_to_network_analyzers_new.ppt
an_introduction_to_network_analyzers_new.ppt
Iwan89629
 
In depth understanding network security
In depth understanding network securityIn depth understanding network security
In depth understanding network securityThanawan Tuamyim
 

Similar to 03 linuxfirewall1 (20)

IP Tables And Filtering
IP Tables And FilteringIP Tables And Filtering
IP Tables And Filtering
 
Iptables presentation
Iptables presentationIptables presentation
Iptables presentation
 
IPTABLES
IPTABLESIPTABLES
IPTABLES
 
Linux Commands
Linux CommandsLinux Commands
Linux Commands
 
Firewalls rules using iptables in linux
Firewalls rules using iptables in linuxFirewalls rules using iptables in linux
Firewalls rules using iptables in linux
 
Firewall
FirewallFirewall
Firewall
 
Creating a firewall in UBUNTU
Creating a firewall in UBUNTUCreating a firewall in UBUNTU
Creating a firewall in UBUNTU
 
Managing the system and network connection Linux
Managing the system and network connection LinuxManaging the system and network connection Linux
Managing the system and network connection Linux
 
I ptable
I ptableI ptable
I ptable
 
Linux internet server security and configuration tutorial
Linux internet server security and configuration tutorialLinux internet server security and configuration tutorial
Linux internet server security and configuration tutorial
 
IP tables and Filtering
IP tables and FilteringIP tables and Filtering
IP tables and Filtering
 
Linux System Monitoring basic commands
Linux System Monitoring basic commandsLinux System Monitoring basic commands
Linux System Monitoring basic commands
 
iptables 101- bottom-up
iptables 101- bottom-upiptables 101- bottom-up
iptables 101- bottom-up
 
CN 1.docx
CN 1.docxCN 1.docx
CN 1.docx
 
nwlab-ex1.pdf
nwlab-ex1.pdfnwlab-ex1.pdf
nwlab-ex1.pdf
 
IPTABLES_linux_Firewall_Administration (1).pdf
IPTABLES_linux_Firewall_Administration (1).pdfIPTABLES_linux_Firewall_Administration (1).pdf
IPTABLES_linux_Firewall_Administration (1).pdf
 
The ifconfig Command
The ifconfig CommandThe ifconfig Command
The ifconfig Command
 
Linux
LinuxLinux
Linux
 
an_introduction_to_network_analyzers_new.ppt
an_introduction_to_network_analyzers_new.pptan_introduction_to_network_analyzers_new.ppt
an_introduction_to_network_analyzers_new.ppt
 
In depth understanding network security
In depth understanding network securityIn depth understanding network security
In depth understanding network security
 

Recently uploaded

假文凭国外(Adelaide毕业证)澳大利亚国立大学毕业证成绩单办理
假文凭国外(Adelaide毕业证)澳大利亚国立大学毕业证成绩单办理假文凭国外(Adelaide毕业证)澳大利亚国立大学毕业证成绩单办理
假文凭国外(Adelaide毕业证)澳大利亚国立大学毕业证成绩单办理
cuobya
 
国外证书(Lincoln毕业证)新西兰林肯大学毕业证成绩单不能毕业办理
国外证书(Lincoln毕业证)新西兰林肯大学毕业证成绩单不能毕业办理国外证书(Lincoln毕业证)新西兰林肯大学毕业证成绩单不能毕业办理
国外证书(Lincoln毕业证)新西兰林肯大学毕业证成绩单不能毕业办理
zoowe
 
1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...
JeyaPerumal1
 
可查真实(Monash毕业证)西澳大学毕业证成绩单退学买
可查真实(Monash毕业证)西澳大学毕业证成绩单退学买可查真实(Monash毕业证)西澳大学毕业证成绩单退学买
可查真实(Monash毕业证)西澳大学毕业证成绩单退学买
cuobya
 
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
ufdana
 
guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...
Rogerio Filho
 
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
eutxy
 
Italy Agriculture Equipment Market Outlook to 2027
Italy Agriculture Equipment Market Outlook to 2027Italy Agriculture Equipment Market Outlook to 2027
Italy Agriculture Equipment Market Outlook to 2027
harveenkaur52
 
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
3ipehhoa
 
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
3ipehhoa
 
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
3ipehhoa
 
Internet of Things in Manufacturing: Revolutionizing Efficiency & Quality | C...
Internet of Things in Manufacturing: Revolutionizing Efficiency & Quality | C...Internet of Things in Manufacturing: Revolutionizing Efficiency & Quality | C...
Internet of Things in Manufacturing: Revolutionizing Efficiency & Quality | C...
CIOWomenMagazine
 
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
keoku
 
[HUN][hackersuli] Red Teaming alapok 2024
[HUN][hackersuli] Red Teaming alapok 2024[HUN][hackersuli] Red Teaming alapok 2024
[HUN][hackersuli] Red Teaming alapok 2024
hackersuli
 
Explore-Insanony: Watch Instagram Stories Secretly
Explore-Insanony: Watch Instagram Stories SecretlyExplore-Insanony: Watch Instagram Stories Secretly
Explore-Insanony: Watch Instagram Stories Secretly
Trending Blogers
 
Understanding User Behavior with Google Analytics.pdf
Understanding User Behavior with Google Analytics.pdfUnderstanding User Behavior with Google Analytics.pdf
Understanding User Behavior with Google Analytics.pdf
SEO Article Boost
 
Meet up Milano 14 _ Axpo Italia_ Migration from Mule3 (On-prem) to.pdf
Meet up Milano 14 _ Axpo Italia_ Migration from Mule3 (On-prem) to.pdfMeet up Milano 14 _ Axpo Italia_ Migration from Mule3 (On-prem) to.pdf
Meet up Milano 14 _ Axpo Italia_ Migration from Mule3 (On-prem) to.pdf
Florence Consulting
 
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptxBridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
Brad Spiegel Macon GA
 
学位认证网(DU毕业证)迪肯大学毕业证成绩单一比一原版制作
学位认证网(DU毕业证)迪肯大学毕业证成绩单一比一原版制作学位认证网(DU毕业证)迪肯大学毕业证成绩单一比一原版制作
学位认证网(DU毕业证)迪肯大学毕业证成绩单一比一原版制作
zyfovom
 
7 Best Cloud Hosting Services to Try Out in 2024
7 Best Cloud Hosting Services to Try Out in 20247 Best Cloud Hosting Services to Try Out in 2024
7 Best Cloud Hosting Services to Try Out in 2024
Danica Gill
 

Recently uploaded (20)

假文凭国外(Adelaide毕业证)澳大利亚国立大学毕业证成绩单办理
假文凭国外(Adelaide毕业证)澳大利亚国立大学毕业证成绩单办理假文凭国外(Adelaide毕业证)澳大利亚国立大学毕业证成绩单办理
假文凭国外(Adelaide毕业证)澳大利亚国立大学毕业证成绩单办理
 
国外证书(Lincoln毕业证)新西兰林肯大学毕业证成绩单不能毕业办理
国外证书(Lincoln毕业证)新西兰林肯大学毕业证成绩单不能毕业办理国外证书(Lincoln毕业证)新西兰林肯大学毕业证成绩单不能毕业办理
国外证书(Lincoln毕业证)新西兰林肯大学毕业证成绩单不能毕业办理
 
1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...
 
可查真实(Monash毕业证)西澳大学毕业证成绩单退学买
可查真实(Monash毕业证)西澳大学毕业证成绩单退学买可查真实(Monash毕业证)西澳大学毕业证成绩单退学买
可查真实(Monash毕业证)西澳大学毕业证成绩单退学买
 
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
 
guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...
 
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
 
Italy Agriculture Equipment Market Outlook to 2027
Italy Agriculture Equipment Market Outlook to 2027Italy Agriculture Equipment Market Outlook to 2027
Italy Agriculture Equipment Market Outlook to 2027
 
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
 
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
 
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
 
Internet of Things in Manufacturing: Revolutionizing Efficiency & Quality | C...
Internet of Things in Manufacturing: Revolutionizing Efficiency & Quality | C...Internet of Things in Manufacturing: Revolutionizing Efficiency & Quality | C...
Internet of Things in Manufacturing: Revolutionizing Efficiency & Quality | C...
 
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
 
[HUN][hackersuli] Red Teaming alapok 2024
[HUN][hackersuli] Red Teaming alapok 2024[HUN][hackersuli] Red Teaming alapok 2024
[HUN][hackersuli] Red Teaming alapok 2024
 
Explore-Insanony: Watch Instagram Stories Secretly
Explore-Insanony: Watch Instagram Stories SecretlyExplore-Insanony: Watch Instagram Stories Secretly
Explore-Insanony: Watch Instagram Stories Secretly
 
Understanding User Behavior with Google Analytics.pdf
Understanding User Behavior with Google Analytics.pdfUnderstanding User Behavior with Google Analytics.pdf
Understanding User Behavior with Google Analytics.pdf
 
Meet up Milano 14 _ Axpo Italia_ Migration from Mule3 (On-prem) to.pdf
Meet up Milano 14 _ Axpo Italia_ Migration from Mule3 (On-prem) to.pdfMeet up Milano 14 _ Axpo Italia_ Migration from Mule3 (On-prem) to.pdf
Meet up Milano 14 _ Axpo Italia_ Migration from Mule3 (On-prem) to.pdf
 
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptxBridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
 
学位认证网(DU毕业证)迪肯大学毕业证成绩单一比一原版制作
学位认证网(DU毕业证)迪肯大学毕业证成绩单一比一原版制作学位认证网(DU毕业证)迪肯大学毕业证成绩单一比一原版制作
学位认证网(DU毕业证)迪肯大学毕业证成绩单一比一原版制作
 
7 Best Cloud Hosting Services to Try Out in 2024
7 Best Cloud Hosting Services to Try Out in 20247 Best Cloud Hosting Services to Try Out in 2024
7 Best Cloud Hosting Services to Try Out in 2024
 

03 linuxfirewall1

  • 1. Linux Firewalls (Ubuntu IPTables) Introduction Linux Firewalls is the way to make our Linux OS more secure and safe because it enables you to control your connection ports and your inbound and outbound traffic. To control this inbound and outbound traffic, Linux OS uses a software called iptables. IPTables is actually a net filter software which is integrated with the kernel implementation, it also provides filtering features that can filter the inbound and outbound in routed traffics to our computer system. IPTables Organization The iptables organizes its information in tables, each tables consists of number of chains and each chain consists of many rules, these rules are responsible for controlling the system traffic. Each Chain has a default taken action called chain default policy and it used when there is no rule created for a specified service or traffic. Main IPTabels 1. filter table is the default table. 2. nat table is used to tell the kernel what connections to change and how to change them. 3. mangle table is mainly used for mangling packets.
  • 2. IPTables Useful Commands $dpkg-query -l iptables used for listing the packages that matches iptables. $dpkg-query -s iptables used for recognizing the status of the iptable packages. $dpkg-query -L iptables used for listing the files and libraries that related to the iptables. $iptables -h used for getting the iptables help. $iptables -L used for listing the table chains and the rules of each chain, to specify a certain table use -t followed by the name of the table. $iptable -A used to Append a rule to a certain chain. $iptables -I used for Inserting a rule in a location not only adding it to the tail of the chain of rules. $iptable -D used for deleting a rule from a chain in a table. $iptable -F used for flushing all rules of a chain. $iptable-save used for saving all current rules and chains of the system in a file. $iptable-restore used for restoring saved rules from a file. To open the console in Ubuntu just click as shown
  • 3. http://en.wikipedia.org/wiki/Dpkg dpkg is the software at the base of the Debian package management system. dpkg is used to install, remove, and provide information about .deb packages. dpkg itself is a low level tool; higher level tools, such as APT, are used to fetch packages from remote locations or deal with complex package relations. The Debian package "dpkg" provides the dpkg program, as well as several other programs necessary for run-time functioning of the packaging system. http://man.he.net/man1/dpkg-query dpkg-query is a tool to show information about packages listed in the dpkg database. Options 1 -l, --list package-name-pattern List packages matching given pattern. Here we choose the package iptables.
  • 4. Options 2 -s, --status package-name Report status of specified package. Here we choose the package iptables.
  • 5. Options 3 -L, --listfiles package-name List files installed to your system from package-name. Here we choose the package iptables.
  • 6. http://man.he.net/?topic=iptables&section=all iptables is used to set up, maintain, and inspect the tables of IP packet filter rules in the Linux kernel. Each rule can match a set of packets and specify what to do with a packet that matches. Options 1 -h, --help To receive command help.
  • 7. Options 2 -L, --list -t table-name List all chains in the selected table. If no table is selected, like every other iptables command, it applies to the specified table (filter is the default).
  • 8. Scenario We will use the VirtualBox as our virtual machine to create two guest machines (Ubuntu and PCLinux) both of them with network card configured with the virtual LAN that installed by the VirtualBox.
  • 9. while Ubuntu machine has another network card configured with NATing to be certain that it will have an Internet connection from the host machine.
  • 10. We have to be certain all the three machines are in the same LAN PCLinux Machine with one Network Card Named eth0 for Virtual LAN
  • 11. Ubuntu Machine with Network Card called eth0 for NATing and another Network Card called eth1 for Virtual LAN
  • 12. Host Machine with a lot of Network Cards One is called Virtual Box Host-Only Adapter for Virtual LAN
  • 13. Filter Table (INPUT & OUTPUT Chains) Example#1 Write a firewall rule to prevent pinging the Ubuntu machine from the PCLinux machine. Now PCLinux Machine can ping Ubuntu Machine
  • 14. Now if we just write the shown command, it will prevent the PCLinux Machine from pinging the Ubuntu Machine $sudo iptables -A INPUT -p icmp --icmp-type echo-request -s 192.168.56.103 -d 0/0 -j DROP sudo To take the root privilege. iptables To start using the iptables. -A INPUT To add a rule to a specified chain, here we specify the INPUT chain. (as no table specified we deal with the default table which is the filter table). -p icmp To specify the used protocol, here we specify the ICMP Protocol --icmp-type echo-request To specify the ICMP type, here we choose the ping (echo-request). This is option can be used only if we choose icmp as our protocol. -s 192.168.56.103 To specify the source, here we specify the PCLinux IP -d 0/0 To specify the destination, here we choose 0/0 which mean all hosts IPs. -j DROP To specify the Target Action, here we choose DROP Action.
  • 15. Now as shown the PCLinux Machine ping but no answer
  • 16. While the host machine can ping both no problem
  • 17. Example#2 Write a firewall rule to prevent the Ubuntu Machine from pinging any other computer on the network. $sudo iptables -A OUTPUT -p icmp --icmp-type echo-request -s 0/0 -d 0/0 -j DROP
  • 18. Example#3 Write a firewall rule to prevent the Ubuntu Machine from opening the facebook $sude iptables -A OUTPUT -p tcp -s 0/0 -d www.facebook.com --dport 80 -j DROP
  • 19. After adding the rule, the Ubuntu Machine can't access the facebook website while other websites are aavailable like google.com.
  • 20. Example#4 Delete the firewall rule that we used in Example#1 $sudo iptables -D INPUT -p icmp --icmp-type echo-request -s 192.168.56.103 -d 0/0 -j DROP It is the same like adding except using -D instead of -A
  • 21. Exercise#1 Write a firewall rule to prevent the Ubuntu Machine from opening any website. Exercise#2 Write firewall rules to prevent any client except the PCLinux Machine from accessing the web server on the Ubuntu Machine.