You are not logged in.

#1 2014-01-16 20:00:49

karabaja4
Member
From: Croatia
Registered: 2008-09-14
Posts: 1,001
Website

Forwarding DNS using iptables

Hello,

I have this configuration:

WLAN <---wireless---> PC1 <---ethernet---> PC2

on PC1 I am using iptables as shown below to route the connection to PC2:

# WLAN
iwconfig wlp0s11 essid myessid
iwconfig wlp0s11 key s:mypassword

ip link set dev wlp0s11 up
ip addr add 192.168.5.123/24 broadcast 192.168.5.255 dev wlp0s11
ip route add default via 192.168.5.1

# LAN
ip link set up dev enp0s1f1
ip addr add 10.0.0.1/24 broadcast 10.0.0.255 dev enp0s1f1

iptables -t nat -I POSTROUTING -o wlp0s11 -j MASQUERADE
iptables -I FORWARD -i enp0s1f1 -o wlp0s11 -j ACCEPT
iptables -I FORWARD -i wlp0s11 -o enp0s1f1 -j ACCEPT

echo 1 > /proc/sys/net/ipv4/ip_forward

The problem is I cannot get DNS forwarding to work on PC2.

I have this (DNS server/router):

nameserver 192.168.5.1

in /etc/resolv.conf on PC1

and this:

nameserver 10.0.0.1

in /etc.resolv.conf on PC2.

If I use Google DNS or DNS server directly in resolv.conf on PC2, everything works.

But... I don't want to do that, I want to forward DNS requests using NAT through 10.0.0.1.

Any help is appreciated.

Cheers!

Offline

Board footer

Powered by FluxBB