Skip to content

Commit

Permalink
Use -n when running iptables -L
Browse files Browse the repository at this point in the history
By default iptables will try to resolve all IP addresses in rules, this
can cause performance issues.
  • Loading branch information
devplayer0 authored and ssup2 committed Jul 9, 2021
1 parent 3ab4a5a commit a4c7975
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/iptables/iptables.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func isExistChain(iptablesCmd string, table Table, chain string) bool {
defer lock.Unlock()

// Check chain
_, err := runIptables(iptablesCmd, table, "-L", chain)
_, err := runIptables(iptablesCmd, table, "-nL", chain)
if err != nil {
return false
}
Expand All @@ -71,7 +71,7 @@ func createChain(iptablesCmd string, table Table, chain string) (string, error)
defer lock.Unlock()

// Check chain
out, err := runIptables(iptablesCmd, table, "-L", chain)
out, err := runIptables(iptablesCmd, table, "-nL", chain)
if err == nil {
// If already exists, return success
return string(out), nil
Expand Down Expand Up @@ -101,7 +101,7 @@ func deleteChain(iptablesCmd string, table Table, chain string) (string, error)
defer lock.Unlock()

// Check chain
out, err := runIptables(iptablesCmd, table, "-L", chain)
out, err := runIptables(iptablesCmd, table, "-nL", chain)
if err != nil {
// If chain isn't exist, return success
return string(out), nil
Expand Down

0 comments on commit a4c7975

Please sign in to comment.