Ubuntuiptables setting_ubuntuiptables configuration details

Source: Internet
Author: User
Ubuntuiptablessave, ubunturestartiptables, ubuntuiptablesdisable, effectuserveriptables, and ubuntuiptablesstop are familiar to you? If you are not familiar with it, refer to the following explanation.

Root @ qustdjx-K42JZ:/home/qustdjx # iptables-L-n
Chain INPUT (policy ACCEPT)
Target prot opt source destination

Chain FORWARD (policy ACCEPT)
Target prot opt source destination

Chain OUTPUT (policy ACCEPT)

Target prot opt source destination

Enable and disable iptables in ubuntu

The/etc/init. d/iptales file does not exist in ubuntu, so the service cannot be used.CommandTo start iptables, you need to use modprobeCommand.

Start iptables

Modprobe ip_tables

Disable iptables (the command to close is more complex than to start)

Iptalbes-F

Iptables-X

Iptables-Z

Iptables-P INPUT ACCEPT

Iptables-P OUTPUT ACCEPT

Iptables-P FORWARD ACCEPT

Modprobe-r ip_tables

Run the preceding commands in sequence to disable iptables. Otherwise, the system prompts FATAL: Module ip_tables is in use when modproble-r ip_tables is executed.

 

I have been using ubuntu for two weeks, so I suddenly found that I have not installed a firewall. I have to go to some documents to see it. The following shows my iptables settings, for the reference of new siblings like me, the level is limited. (For firewall settings, there are two policies: one is that all communication ports are allowed, but some ports that we know are not secure or easy to use are blocked; in addition, all communication ports are blocked first, but only the communication ports we need to use are allowed. The second principle is used here. If you need to enable its port, please refer to the computer communication port description and add it by yourself .)

Code:# Delete existing rules in iptables
Iptables-F
Iptables-X

# Discard all data packets that do not comply with the three chain rules
Iptables-P INPUT DROP
Iptables-P OUTPUT DROP
Iptables-P FORWARD DROP

# Setting: Local process lo The INPUT and OUTPUT links of eth1.
Iptables-a input-I lo-j ACCEPT
Iptables-a input-I eth1-m state -- state ESTABLISHED, RELATED-jACCEPT
Iptables-a input-I eth1-m state -- state NEW, INVALID-j LOG
Iptables-a output-o lo-j ACCEPT

# OUTPUT settings for other major permitted ports:
# DNS
Iptables-a output-o eth1-p TCP -- sport 1024: 65535 -- dport 53-jACCEPT
Iptables-a output-o eth1-p UDP -- sport 1024: 65535 -- dport 53-jACCEPT

# HTTP
Iptables-a output-o eth1-p TCP -- sport 1024: 65535 -- dport 80-jACCEPT

# HTTPS
Iptables-a output-o eth1-p TCP -- sport 1024: 65535 -- dport 443-jACCEPT

# Email receiving and sending
Iptables-a output-o eth1-p TCP -- sport 1024: 65535 -- dport 110-jACCEPT
Iptables-a output-o eth1-p TCP -- sport 1024: 65535 -- dport 25-jACCEPT

# FTP data and control
Iptables-a output-o eth1-p TCP -- sport 1024: 65535 -- dport 20-jACCEPT
Iptables-a output-o eth1-p TCP -- sport 1024: 65535 -- dport 21-jACCEPT

# DHCP
Iptables-a output-o eth1-p TCP -- sport 1024: 65535 -- dport 68-jACCEPT
Iptables-a output-o eth1-p UDP -- sport 1024: 65535 -- dport 68-jACCEPT

# Secure receipt of POP3S Email
Iptables-a output-o eth1-p TCP -- sport 1024: 65535 -- dport 995-jACCEPT

# NTP
Iptables-a output-o eth1-p TCP -- sport 1024: 65535 -- dport 123-jACCEPT

# Reject eth1 OTHER REMAINING
Iptables-a output-o eth1 -- match state -- state NEW, INVALID-jLOG



Finally, there is a command for iptables storage:

Code:Iptables-save>/etc/iptables. up. rule # Where you want to save

 

Code:Iptables-restore

Because iptables needs to be input or called again after each machine restart, in order to facilitate the operation, use

Code:Sudo gedit/etc/network/interfaces


In

Code:Auto ath0
        Iface ath0 inet dhcp

Add

Code:Pre-up iptables-restore 

Code:Post-down iptables-save>/etc/iptables. up. rule # store the current iptables

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.