Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Server \ Linux firewall settings -DNS server articles     - Compile Android libwebcore.so error occurs when solving (Programming)

- Analysis of MySQL Dockerfile 5.6 (Database)

- Ubuntu users install the Download Manager software Xdman 5.0 (Linux)

- MySQL Tutorial: Using tpcc-mysql pressure measurement (Database)

- Talk about Java EE Learning (Programming)

- Terminal fun: 6 interesting Linux command-line tools (Linux)

- CentOS Linux firewall configuration and Close (Linux)

- Static member variable modified (Programming)

- Detailed installation of CentOS 6.x (Linux)

- Installation on the way to the root source Ubuntu Server 14.04 LTS version Odoo8.0 (Server)

- Print Linux system error codes (Linux)

- How to extend / remove swap partitions (Linux)

- Ubuntu 14.04 Configuring cuda-convnet (Linux)

- Configuring Haproxy log support (syslog logging support) (Server)

- Thinking in Java study notes - Generics (Programming)

- Linux performance optimization tools perf top (Linux)

- Unity Greeter Badges: the lost session icon back to the login screen Ubuntu (Linux)

- Linux server dual-card dual-IP and single-card dual-IP configuration method (ReHat / CentOS) (Server)

- Grep, Ack, Ag searches Efficiency Comparison (Linux)

- State and Linux nf_conntrack TCP disconnect time (Programming)

 
         
  Linux firewall settings -DNS server articles
     
  Add Date : 2018-11-21      
         
         
         
  Just set up a DNS server, you need to open the firewall but do not know how to set up a friend, you can refer to the following, or directly use my script given below.

If the server is a DNS server used for the vast majority of cases, in order to turn on the firewall while normally provide related services, general settings are as follows:

[1] The first step: clear the default firewall rules

iptables -F
iptables -X
iptables -Z
Parameter Description:

-F: Clear all the rules that have been developed

-X: Clear all user-defined chain (it should be said that the tables)

(Extension: table - iptables Linux firewall default, there are three tables, Filter, NAT and Mangle, of course, the custom Filter which is the default form, chain-- chain, such as filter there is INPUT, OUTPUT, FORWARD three chains)

-Z: All the chain counts and cleared traffic statistics

Set reasons:

filter of three chains, the default policies are ACCEPT, apparently for INPUT, this is very dangerous, you can use the command iptables -L -n to view the default settings, or use the iptables-save command (listed in more detail firewall configuration information).

[2] The second step: setting policy

iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
Set reasons:

DROP to drop, From 1, INPUT DROP strategy formulation is only relatively safe.

 

[3] The third step: the development of the rules according to the required service

 

(1) Set the machine as a trusted device

iptables -A INPUT -i lo -j ACCEPT
(2) the development of a remote ssh connection rules

iptables -A (add) INPUT (link) -p (specify the protocol) tcp (specified as the TCP protocol) --dport (specify the destination port number) 22 (specify the destination port number is 22) -j (designated operation) ACCEPT ( specify the action to accept)
(3) develop dns service rules

iptables -A INPUT -p tcp --dport 53 -j ACCEPT
iptables -A INPUT -p udp --dport 53 -j ACCEPT
iptables -A INPUT -p tcp --sport 53 -j ACCEPT
iptables -A INPUT -p udp --sport 53 -j ACCEPT
Description:

It allows new dns requests, while allowing to nslookup way to query to the server that is the source port 53 to query dns information.

(4) the development of other rules

iptables -A INPUT -p icmp -j ACCEPT
Description:

Can not, but in order to facilitate the detection server network connectivity, they still add.

 

[4] write firewall profiles

/etc/init.d/iptables save
Description:

To save, otherwise the above configuration will be made after the failure to restart the server.

Full implementation of the script is as follows:

#! / Bin / bash
PATH = / sbin: / bin: / usr / sbin: / usr / bin; export PATH
iptables -F
iptables -X
iptables -Z

iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -p tcp --dport 53 -j ACCEPT
iptables -A INPUT -p udp --dport 53 -j ACCEPT
iptables -A INPUT -p tcp --sport 53 -j ACCEPT
iptables -A INPUT -p udp --sport 53 -j ACCEPT
iptables -A INPUT -p icmp -j ACCEPT

/etc/init.d/iptables save
Save as .sh file with administrator privileges can execute.

Other commonly used commands:

View firewall configuration summary

iptables -L -n
See detailed firewall configuration

iptables-save
Important note:

    The firewall configuration must be careful, especially when done in the remote configuration, if not carefully defined rules clear, again the default rule is set to INPUT DROP, then there is no way to connect remotely, and with particular attention to this point .
     
         
         
         
  More:      
 
- How to use awk command in Linux (Linux)
- Linux regex sed detailing (Linux)
- Under Ubuntu on how to use iptables firewall (Linux)
- SQLite database commonly used sentences and visualization tools on MAC MeasSQLlite use (Database)
- Linux Detailed instructions alias settings (Linux)
- VMware Workstation virtual machine Ubuntu achieve shared with the host (Linux)
- CentOS 7 - use cgroups limit process resource (Linux)
- WebLogic 12c Configuration Node Manager Managed Server (Database)
- Install the Red Hat Container Development Kit on OSX (Server)
- SQL Server 2012 failover looksalive check and is alive check (Database)
- Spark read more HBase tables a RDD (Server)
- MariaDB 10.1 and MySQL 5.7 in general performance on commodity hardware (Database)
- Text editing and viewing text Linux command (Linux)
- Linux kernel boot to retain large memory method summary (Linux)
- Tomcat itself through simple movement separation (Server)
- Ubuntu dual-card system configuration method (Server)
- Use Observium to monitor your network and servers (Server)
- The traffic monitoring system: cacti (Linux)
- Ubuntu 10.04 to Ubuntu 10.10 Upgrade (Linux)
- CentOS6.5 installation Docker (Linux)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.