Ubuntu Server Guide
Download 1.23 Mb. Pdf ko'rish
|
ubuntu-server-guide (1)
Firewall
Introduction The Linux kernel includes the Netfilter subsystem, which is used to manipulate or decide the fate of network traffic headed into or through your server. All modern Linux firewall solutions use this system for packet filtering. The kernel’s packet filtering system would be of little use to administrators without a userspace interface to manage it. This is the purpose of iptables: When a packet reaches your server, it will be handed off to the Netfilter subsystem for acceptance, manipulation, or rejection based on the rules supplied to it from userspace via iptables. Thus, iptables is all you need to manage your firewall, if you’re familiar with it, but many frontends are available to simplify the task. ufw - Uncomplicated Firewall The default firewall configuration tool for Ubuntu is ufw. Developed to ease iptables firewall configuration, ufw provides a user-friendly way to create an IPv4 or IPv6 host-based firewall. ufw by default is initially disabled. From the ufw man page: “ufw is not intended to provide complete firewall functionality via its command interface, but instead provides an easy way to add or remove simple rules. It is currently mainly used for host-based firewalls.” The following are some examples of how to use ufw: • First, ufw needs to be enabled. From a terminal prompt enter: sudo ufw e n a b l e • To open a port (SSH in this example): sudo ufw a l l o w 22 • Rules can also be added using a numbered format: sudo ufw i n s e r t 1 a l l o w 80 • Similarly, to close an opened port: sudo ufw deny 22 • To remove a rule, use delete followed by the rule: 86 sudo ufw d e l e t e deny 22 • It is also possible to allow access from specific hosts or networks to a port. The following example allows SSH access from host 192.168.0.2 to any IP address on this host: sudo ufw a l l o w p r o t o t c p from 1 9 2 . 1 6 8 . 0 . 2 t o any p o r t 22 Replace 192.168.0.2 with 192.168.0.0/24 to allow SSH access from the entire subnet. • Adding the –dry-run option to a ufw command will output the resulting rules, but not apply them. For example, the following is what would be applied if opening the HTTP port: sudo ufw −−dry−run a l l o w h t t p * f i l t e r : ufw−u s e r −i n p u t − [ 0 : 0 ] : ufw−u s e r −output − [ 0 : 0 ] : ufw−u s e r −f o r w a r d − [ 0 : 0 ] : ufw−u s e r −l i m i t − [ 0 : 0 ] : ufw−u s e r −l i m i t −a c c e p t − [ 0 : 0 ] ### RULES ### ### t u p l e ### a l l o w t c p 80 0 . 0 . 0 . 0 / 0 any 0 . 0 . 0 . 0 / 0 −A ufw−u s e r −i n p u t −p t c p −−d p o r t 80 −j ACCEPT ### END RULES ### −A ufw−u s e r −i n p u t −j RETURN −A ufw−u s e r −output −j RETURN −A ufw−u s e r −f o r w a r d −j RETURN −A ufw−u s e r −l i m i t −m l i m i t −−l i m i t 3/ minute −j LOG −−l o g −p r e f i x ” [UFW LIMIT ] : ” −A ufw−u s e r −l i m i t −j REJECT −A ufw−u s e r −l i m i t −a c c e p t −j ACCEPT COMMIT Rules updated • ufw can be disabled by: sudo ufw d i s a b l e • To see the firewall status, enter: sudo ufw s t a t u s • And for more verbose status information use: sudo ufw s t a t u s v e r b o s e • To view the numbered format: sudo ufw s t a t u s numbered Note If the port you want to open or close is defined in /etc/ services , you can use the port name instead of the number. In the above examples, replace 22 with ssh. This is a quick introduction to using ufw. Please refer to the ufw man page for more information. 87 |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling