# iptables says nat table doesn't exist though proper kernel

## lightning

Whether I try to flush nat table iptables responds:

```
# iptables -t nat -F

FATAL: Module ip_tables not found.

iptables v1.4.0: can't initialize iptables table `nat': Table does not exist (do you need to insmod?)

Perhaps iptables or your kernel needs to be upgraded.
```

netfilter and stuff like this are enabled in kernel, here's kern. config:

```

#

# Networking

#

CONFIG_NET=y

#

# Networking options

#

CONFIG_PACKET=y

# CONFIG_PACKET_MMAP is not set

CONFIG_UNIX=y

CONFIG_XFRM=y

# CONFIG_XFRM_USER is not set

# CONFIG_XFRM_SUB_POLICY is not set

# CONFIG_XFRM_MIGRATE is not set

# CONFIG_XFRM_STATISTICS is not set

# CONFIG_NET_KEY is not set

CONFIG_INET=y

CONFIG_IP_MULTICAST=y

CONFIG_IP_ADVANCED_ROUTER=y

CONFIG_ASK_IP_FIB_HASH=y

# CONFIG_IP_FIB_TRIE is not set

CONFIG_IP_FIB_HASH=y

# CONFIG_IP_MULTIPLE_TABLES is not set

# CONFIG_IP_ROUTE_MULTIPATH is not set

# CONFIG_IP_ROUTE_VERBOSE is not set

CONFIG_IP_PNP=y

CONFIG_IP_PNP_DHCP=y

CONFIG_IP_PNP_BOOTP=y

# CONFIG_IP_PNP_RARP is not set

# CONFIG_NET_IPIP is not set

# CONFIG_NET_IPGRE is not set

# CONFIG_IP_MROUTE is not set

# CONFIG_ARPD is not set

# CONFIG_SYN_COOKIES is not set

# CONFIG_INET_AH is not set

# CONFIG_INET_ESP is not set

# CONFIG_INET_IPCOMP is not set

# CONFIG_INET_XFRM_TUNNEL is not set

CONFIG_INET_TUNNEL=m

CONFIG_INET_XFRM_MODE_TRANSPORT=y

CONFIG_INET_XFRM_MODE_TUNNEL=y

# CONFIG_INET_XFRM_MODE_BEET is not set

# CONFIG_INET_LRO is not set

CONFIG_INET_DIAG=y

CONFIG_INET_TCP_DIAG=y

# CONFIG_TCP_CONG_ADVANCED is not set

CONFIG_TCP_CONG_CUBIC=y

CONFIG_DEFAULT_TCP_CONG="cubic"

# CONFIG_TCP_MD5SIG is not set

# CONFIG_IP_VS is not set

CONFIG_IPV6=m

# CONFIG_IPV6_PRIVACY is not set

# CONFIG_IPV6_ROUTER_PREF is not set

# CONFIG_IPV6_OPTIMISTIC_DAD is not set

# CONFIG_INET6_AH is not set

# CONFIG_INET6_ESP is not set

# CONFIG_INET6_IPCOMP is not set

# CONFIG_IPV6_MIP6 is not set

# CONFIG_INET6_XFRM_TUNNEL is not set

# CONFIG_INET6_TUNNEL is not set

CONFIG_INET6_XFRM_MODE_TRANSPORT=m

CONFIG_INET6_XFRM_MODE_TUNNEL=m

# CONFIG_INET6_XFRM_MODE_BEET is not set

# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set

CONFIG_IPV6_SIT=m

CONFIG_IPV6_NDISC_NODETYPE=y

# CONFIG_IPV6_TUNNEL is not set

# CONFIG_IPV6_MULTIPLE_TABLES is not set

# CONFIG_IPV6_MROUTE is not set

# CONFIG_NETWORK_SECMARK is not set

CONFIG_NETFILTER=y

# CONFIG_NETFILTER_DEBUG is not set

CONFIG_NETFILTER_ADVANCED=y

#

# Core Netfilter Configuration

#

# CONFIG_NETFILTER_NETLINK_QUEUE is not set

# CONFIG_NETFILTER_NETLINK_LOG is not set

# CONFIG_NF_CONNTRACK is not set

CONFIG_NETFILTER_XTABLES=y

# CONFIG_NETFILTER_XT_TARGET_CLASSIFY is not set

# CONFIG_NETFILTER_XT_TARGET_MARK is not set

# CONFIG_NETFILTER_XT_TARGET_NFQUEUE is not set

# CONFIG_NETFILTER_XT_TARGET_NFLOG is not set

# CONFIG_NETFILTER_XT_TARGET_RATEEST is not set

# CONFIG_NETFILTER_XT_TARGET_TCPMSS is not set

# CONFIG_NETFILTER_XT_MATCH_COMMENT is not set

# CONFIG_NETFILTER_XT_MATCH_DCCP is not set

# CONFIG_NETFILTER_XT_MATCH_DSCP is not set

# CONFIG_NETFILTER_XT_MATCH_ESP is not set

# CONFIG_NETFILTER_XT_MATCH_IPRANGE is not set

# CONFIG_NETFILTER_XT_MATCH_LENGTH is not set

# CONFIG_NETFILTER_XT_MATCH_LIMIT is not set

# CONFIG_NETFILTER_XT_MATCH_MAC is not set

# CONFIG_NETFILTER_XT_MATCH_MARK is not set

# CONFIG_NETFILTER_XT_MATCH_OWNER is not set

# CONFIG_NETFILTER_XT_MATCH_POLICY is not set

# CONFIG_NETFILTER_XT_MATCH_MULTIPORT is not set

# CONFIG_NETFILTER_XT_MATCH_PKTTYPE is not set

# CONFIG_NETFILTER_XT_MATCH_QUOTA is not set

# CONFIG_NETFILTER_XT_MATCH_RATEEST is not set

# CONFIG_NETFILTER_XT_MATCH_REALM is not set

# CONFIG_NETFILTER_XT_MATCH_SCTP is not set

# CONFIG_NETFILTER_XT_MATCH_STATISTIC is not set

# CONFIG_NETFILTER_XT_MATCH_STRING is not set

# CONFIG_NETFILTER_XT_MATCH_TCPMSS is not set

# CONFIG_NETFILTER_XT_MATCH_TIME is not set

# CONFIG_NETFILTER_XT_MATCH_U32 is not set

# CONFIG_NETFILTER_XT_MATCH_HASHLIMIT is not set

#

# IP: Netfilter Configuration

#

# CONFIG_IP_NF_QUEUE is not set

CONFIG_IP_NF_IPTABLES=y

# CONFIG_IP_NF_MATCH_RECENT is not set

# CONFIG_IP_NF_MATCH_ECN is not set

# CONFIG_IP_NF_MATCH_AH is not set

# CONFIG_IP_NF_MATCH_TTL is not set

CONFIG_IP_NF_MATCH_ADDRTYPE=y

CONFIG_IP_NF_FILTER=y

CONFIG_IP_NF_TARGET_REJECT=y

# CONFIG_IP_NF_TARGET_LOG is not set

# CONFIG_IP_NF_TARGET_ULOG is not set

# CONFIG_IP_NF_MANGLE is not set

# CONFIG_IP_NF_RAW is not set

# CONFIG_IP_NF_ARPTABLES is not set

#

# IPv6: Netfilter Configuration

#

# CONFIG_IP6_NF_QUEUE is not set

# CONFIG_IP6_NF_IPTABLES is not set

# CONFIG_IP_DCCP is not set

# CONFIG_IP_SCTP is not set

# CONFIG_TIPC is not set

# CONFIG_ATM is not set

# CONFIG_BRIDGE is not set

# CONFIG_VLAN_8021Q is not set

# CONFIG_DECNET is not set

# CONFIG_LLC2 is not set

# CONFIG_IPX is not set

# CONFIG_ATALK is not set

# CONFIG_X25 is not set

# CONFIG_LAPB is not set

# CONFIG_ECONET is not set

CONFIG_WAN_ROUTER=y

CONFIG_NET_SCHED=y

#

# Queueing/Scheduling

#

CONFIG_NET_SCH_CBQ=m

CONFIG_NET_SCH_HTB=m

CONFIG_NET_SCH_HFSC=m

CONFIG_NET_SCH_PRIO=m

CONFIG_NET_SCH_RED=m

# CONFIG_NET_SCH_SFQ is not set

# CONFIG_NET_SCH_TEQL is not set

# CONFIG_NET_SCH_TBF is not set

# CONFIG_NET_SCH_GRED is not set

# CONFIG_NET_SCH_DSMARK is not set

# CONFIG_NET_SCH_NETEM is not set

#

# Classification

#

CONFIG_NET_CLS=y

# CONFIG_NET_CLS_BASIC is not set

# CONFIG_NET_CLS_TCINDEX is not set

CONFIG_NET_CLS_ROUTE4=m

CONFIG_NET_CLS_ROUTE=y

# CONFIG_NET_CLS_FW is not set

# CONFIG_NET_CLS_U32 is not set

# CONFIG_NET_CLS_RSVP is not set

# CONFIG_NET_CLS_RSVP6 is not set

# CONFIG_NET_CLS_FLOW is not set

# CONFIG_NET_EMATCH is not set

# CONFIG_NET_CLS_ACT is not set

CONFIG_NET_SCH_FIFO=y

#

# Network testing

#

# CONFIG_NET_PKTGEN is not set

# CONFIG_NET_TCPPROBE is not set

# CONFIG_HAMRADIO is not set

# CONFIG_CAN is not set

# CONFIG_IRDA is not set

# CONFIG_BT is not set

# CONFIG_AF_RXRPC is not set

```

Any idea what else supposed to be enabled to get iptables working? Just for sure its the latest stable release from portage tree (v1.4.0) and the kernel 2.6.26-gentoo-r3

Thank's in advance

----------

## massimo

Just in case: sometimes it helps to rebuild the kernel ;)

----------

## lightning

Kernel is quite fresh, built couple of minutes before try of iptables use

----------

## bartlm

What Im missing is CONFIG_NF_NAT and CONFIG_NF_CONNTRACK_IPV4.

This can be enabled in menuconfig -> Network packet filtering framework (Netfilter) -> IP: Netfilter Configuration.

Hope this helps a bit.

----------

## lightning

 *Quote:*   

> What Im missing is CONFIG_NF_NAT and CONFIG_NF_CONNTRACK_IPV4

 

Actually,

 *Quote:*   

> 
> 
> ```
> ...
> 
> ...

 

is enabled and it is described in menuconfig that is for Ipetables/Masq/Nat, and the options you have mentioned are not in the place you have pointed to, so I think they have been deprecated and are no more in use in kernel I use. The config is generated by menuconfig so (correct me if I wrong) all the possible options are listed. The innactive are commented, am I right? The fragment I posted is a raw cut from .config generated by menuconfig, I can't see any of the options you suggest to use.

----------

## drescherjm

I am having the same problem today with openvz-2.6.26. 

```
gw1 ~ # iptables -A POSTROUTING -t nat -o eth1 -j MASQUERADE

iptables v1.4.2: can't initialize iptables table `nat': Table does not exist (do you need to insmod?)

```

```

# iptables -t nat -F

iptables v1.4.2: can't initialize iptables table `nat': Table does not exist (do you need to insmod?)

Perhaps iptables or your kernel needs to be upgraded.

```

----------

## drescherjm

I think I have it. Had to enable CONFIG_NF_CONNTRACK first then find CONFIG_NF_CONNTRACK_IPV4 then CONFIG_NF_NAT

[EDIT]Yes that worked. [/EDIT]

----------

## lightning

That's right. Helped me as well. I would like to just suggest to don't forget about CONFIG_IP_NF_TARGET_MASQUERADE=y for masquerade as it's neccessary. Problem solved.

----------

## mikegpitt

Just was fooling around and ran into this error today... looks like i forgot NF_NAT from my .config.

----------

