42.4. nftables 스크립트 작성 및 실행


nftables 프레임워크를 사용할 때의 주요 이점은 스크립트 실행이 atomic이라는 것입니다. 즉, 시스템이 전체 스크립트를 적용하거나 오류가 발생하면 실행을 방지합니다. 이렇게 하면 방화벽이 항상 일관된 상태로 유지됩니다.

또한 nftables 스크립트 환경을 사용하면 다음을 수행할 수 있습니다.

  • 댓글 추가
  • 변수 정의
  • 기타 규칙 세트 파일 포함

nftables 패키지를 설치하면 Red Hat Enterprise Linux가 /etc/nftables/ 디렉터리에 *.nft 스크립트가 자동으로 생성됩니다. 이러한 스크립트에는 서로 다른 용도로 테이블 및 빈 체인을 만드는 명령이 포함되어 있습니다.

42.4.1. 지원되는 nftables 스크립트 형식

nftables 프레임워크는 다른 형식의 스크립트를 지원합니다.

다음 형식을 사용할 수 있습니다.

  • nft list ruleset 명령과 동일한 형식은 규칙 세트를 표시합니다.

    #!/usr/sbin/nft -f
    
    # Flush the rule set
    flush ruleset
    
    table inet example_table {
      chain example_chain {
        # Chain for incoming packets that drops all packets that
        # are not explicitly allowed by any rule in this chain
        type filter hook input priority 0; policy drop;
    
        # Accept connections to port 22 (ssh)
        tcp dport ssh accept
      }
    }
  • nft 명령과 동일한 구문:

    #!/usr/sbin/nft -f
    
    # Flush the rule set
    flush ruleset
    
    # Create a table
    add table inet example_table
    
    # Create a chain for incoming packets that drops all packets
    # that are not explicitly allowed by any rule in this chain
    add chain inet example_table example_chain { type filter hook input priority 0 ; policy drop ; }
    
    # Add a rule that accepts connections to port 22 (ssh)
    add rule inet example_table example_chain tcp dport ssh accept
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 문서 정보

Legal Notice

Theme

© 2026 Red Hat
맨 위로 이동