LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 12-02-2023, 06:34 PM   #1
prodego
LQ Newbie
 
Registered: Dec 2023
Posts: 1

Rep: Reputation: 0
Unhappy Network namespace has no DNS resolution


I have a post-up script for my NIC that creates a network namespace with internet access but I can't resolve domains from inside the namespace. Here is the configuration.

Code:
ego@ubuntu:~$ cat /usr/local/bin/wrgrd.sh
#!/bin/bash

#Create VPN namespace
ip netns add wireguard

#Create vswitch and veth
ip l add vsw0 type bridge
ip l add veth0 type veth peer name veth1

#Attach veth to vswitch and namespace
ip l set veth0 master vsw0
ip l set veth1 netns wireguard

#Assign IPs and raise interfaces
ip a add 192.168.1.1/24 dev vsw0
ip l set dev vsw0 up
ip l set dev veth0 up
ip netns exec wireguard ip l set dev lo up
ip netns exec wireguard ip a add 192.168.1.2/24 dev veth1
ip netns exec wireguard ip l set dev veth1 up

#Add local network route to namespace
ip netns exec wireguard ip r add 192.168.0.0/24 via 192.168.1.1

#Add IP table rule
iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -j MASQUERADE

#Add default route to namespace
ip netns exec wireguard ip r add default via 192.168.1.1

ego@ubuntu:~$ sudo ip netns exec wireguard ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=55 time=26.1 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=55 time=20.8 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=55 time=17.2 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=55 time=13.0 ms
64 bytes from 8.8.8.8: icmp_seq=5 ttl=55 time=11.3 ms
--- 8.8.8.8 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4005ms
rtt min/avg/max/mdev = 11.267/17.665/26.098/5.363 ms

ego@ubuntu:~$ sudo ip netns exec wireguard ping google.com
ping: google.com: Temporary failure in name resolution
 
Old 12-15-2023, 04:53 PM   #2
GlennsPref
Senior Member
 
Registered: Apr 2004
Location: Brisbane, Australia
Distribution: Devuan
Posts: 3,657
Blog Entries: 33

Rep: Reputation: 283Reputation: 283Reputation: 283
Hi, Welcome to LQ!

I saw this reference to nat and firewalling.

You may require "port forwarding".

I have these ipv4 and ipv6 forwarding lines in...
/etc/sysctl.conf
Code:
...
# Uncomment the next line to enable packet forwarding for IPv4
net.ipv4.ip_forward=1  # Enable forwarding (gateway)

# Uncomment the next line to enable packet forwarding for IPv6
#  Enabling this option disables Stateless Address Autoconfiguration
#  based on Router Advertisements for this host
net.ipv6.conf.all.forwarding=0 #off for nordvpn
...
I'm no expert, just saw a common element, a firewall & a vpn.
 
Old 12-20-2023, 10:00 PM   #3
elgrandeperro
Member
 
Registered: Apr 2021
Posts: 415
Blog Entries: 2

Rep: Reputation: Disabled
What is your DNS in /etc/resolv.conf and how did it get there? What exactly is a namespace? We don't use that term in networking.

You can use 8.8.8.8 but it must be in /etc/resolv.conf. Most firewall will pass DNS traffic out and in without a problem.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Network Namespaces - how to connect namespace to physical network circumventing VPN cricketbat Linux - Networking 1 01-03-2016 07:06 AM
brctl doesn't seem to be fully communicating internally from network namespace d.custer91 Linux - Networking 1 05-27-2015 02:11 PM
Network namespace a.cohen Linux - Networking 0 03-12-2014 04:44 PM
Local network DNS resolution fails, but DNS resolution to internet is OK farge Linux - Networking 6 05-28-2008 11:49 PM
Win2k3 DNS + PFsense DNS Forwarder = No internal DNS resolution Panopticon Linux - Networking 1 11-19-2007 09:59 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 02:23 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration