Skip to content

USFAkbari/Set_Shekan_DNS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

15 Commits
Β 
Β 
Β 
Β 

Repository files navigation

DNS Manager v2.0 - DNS Configuration Tool

A powerful bash utility for managing DNS settings on Linux systems. Features a two-step interactive menu (choose DNS β†’ choose method), a dedicated System Management submenu with 11 granular operations, and real-time multi-source DNS status display.

✨ Features

  • 🌍 Multiple DNS Providers: Iranian (Shekan, Arvan) & International (Google, Cloudflare, Quad9, OpenDNS, AdGuard)
  • πŸ”§ Custom DNS: Enter your own DNS IPs with IPv4 validation
  • πŸš€ Two-Step Flow: Choose DNS provider β†’ Choose apply method (NetPlan or resolv.conf)
  • βš™οΈ System Management Submenu: 11 operations β€” view, edit, disable, delete, rollback for both NetPlan and resolv.conf, plus full reset
  • πŸ“Š Multi-Source Status: Shows NetPlan config, resolv.conf, and resolvectl status simultaneously with provider identification
  • πŸ§ͺ Connectivity Test: Verifies DNS is working after applying (nslookup/dig)
  • πŸ’Ύ Automatic Backup: Saves original settings before changes
  • ↩️ Rollback & Disable: Non-destructive disable (keeps file) or full rollback from backup
  • 🎨 Modern UI: Clean, color-coded terminal interface with status indicators

πŸ“‹ Requirements

  • Linux: Ubuntu 17.10+ or any system with NetPlan (optional) or systemd-resolved
  • Privileges: Root/sudo access required
  • Shell: Bash
  • Utilities: ip, grep, awk, sed (pre-installed on most systems)

πŸš€ Installation

Option 1: System-wide (Recommended)

git clone https://github.com/USFAkbari/Set_Shekan_DNS.git
cd Set_Shekan_DNS
sudo cp dnsManager /usr/local/bin/dnsManager
sudo chmod +x /usr/local/bin/dnsManager

Run from anywhere:

sudo dnsManager

Option 2: One-Liner

sudo curl -sSL https://raw.githubusercontent.com/USFAkbari/Set_Shekan_DNS/main/dnsManager -o /usr/local/bin/dnsManager && sudo chmod +x /usr/local/bin/dnsManager

Option 3: Run Without Installing

git clone https://github.com/USFAkbari/Set_Shekan_DNS.git
cd Set_Shekan_DNS
sudo ./dnsManager

πŸ“– How It Works

Configuration Flow

Step 1: Select DNS Provider (1-8) or Custom DNS (C)
                    ↓
Step 2: Choose Apply Method
        β”œβ”€β”€ 1) NetPlan      β†’ /etc/netplan/99-dns-manager.yaml
        └── 2) resolv.conf  β†’ /etc/systemd/resolved.conf
                    ↓
Step 3: Apply β†’ Test Connectivity β†’ Show Result β†’ Exit

πŸ“– Menu Overview

Main Menu

╔══════════════════════════════════════════════════════════════╗
β•‘           🌐  DNS Manager  v2.0.0                           β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

β”Œβ”€β”€ Current DNS Status ────────────────────────────────────────┐
β”‚ Interface: eth0                                              β”‚
β”‚                                                              β”‚
β”‚ NetPlan (/etc/netplan/99-dns-manager.yaml):                  β”‚
β”‚   DNS: 1.1.1.1, 1.0.0.1  (Cloudflare)                       β”‚
β”‚                                                              β”‚
β”‚ resolv.conf (/etc/resolv.conf):                              β”‚
β”‚   nameserver 127.0.0.53  (systemd-stub)                      β”‚
β”‚                                                              β”‚
β”‚ Resolvectl Status:                                           β”‚
β”‚   1.1.1.1  (Cloudflare)                                      β”‚
β”‚                                                              β”‚
β”‚ systemd-resolved: ● Active                                   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

 ── Iranian DNS ────────────    ── International DNS ───────────
  1) Shekan Pro                 5) Cloudflare
  2) Shekan Free                6) Quad9 (Malware Block)
  3) Arvan Cloud                7) OpenDNS
  4) Google DNS                 8) AdGuard (Ad Block)

  C) Custom DNS (enter your own)

 ── System Management ──────────────────────────────────────────
  S) System Management (view, edit, disable, delete, rollback)
  0) Exit

System Management Submenu (S)

╔══════════════════════════════════════════════════════════════╗
β•‘              βš™  System Management                           β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

 ── NetPlan (/etc/netplan/99-dns-manager.yaml) [● active]
   1) View     β€” Show current NetPlan DNS config
   2) Edit     β€” Modify DNS addresses in NetPlan
   3) Disable  β€” Suspend config without deleting
   4) Delete   β€” Remove NetPlan config permanently
   5) Rollback β€” Re-enable disabled config

 ── resolv.conf / systemd-resolved [● custom DNS set]
   6) View     β€” Show resolved.conf & resolv.conf
   7) Edit     β€” Modify DNS in resolved.conf
   8) Disable  β€” Remove custom DNS, use DHCP defaults
   9) Delete   β€” Remove custom DNS entries & backup
  10) Rollback β€” Restore resolved.conf from backup

 ── Full System ────────────────────────────────────────────────
  11) Reset All β€” Remove ALL DNS Manager configurations

   0) ← Back to main menu

πŸ“‘ Supported DNS Servers

Iranian DNS Services

Provider Primary Secondary Notes
Shekan Pro 178.22.122.101 185.51.200.1 Premium anti-censorship
Shekan Free 178.22.122.100 185.51.200.2 Free tier
Arvan Cloud 217.218.127.127 217.218.155.155 Iranian CDN provider

International DNS Services

Provider Primary Secondary Features
Google 8.8.8.8 8.8.4.4 Fast, reliable
Cloudflare 1.1.1.1 1.0.0.1 Privacy-focused, fastest
Quad9 9.9.9.9 149.112.112.112 Malware blocking
OpenDNS 208.67.222.222 208.67.220.220 Family filter options
AdGuard 94.140.14.14 94.140.15.15 Ad & tracker blocking

βš™οΈ Apply Methods

NetPlan (Option 1)

  1. Detects active network interface (e.g., eth0)
  2. Creates config at /etc/netplan/99-dns-manager.yaml
  3. Validates with netplan generate, applies with netplan apply
  4. Overrides DHCP DNS settings

Note: Wi-Fi interfaces automatically fall back to systemd-resolved due to NetPlan limitations.

systemd-resolved (Option 2)

  1. Backs up /etc/systemd/resolved.conf
  2. Modifies DNS and FallbackDNS settings
  3. Restarts systemd-resolved service

πŸ”§ System Management Operations

# Target Operation Description
1 NetPlan View Display YAML config file and parsed DNS addresses
2 NetPlan Edit Enter new DNS IPs β†’ rewrite config β†’ validate β†’ apply
3 NetPlan Disable Rename to .disabled (preserves config, stops applying)
4 NetPlan Delete Permanently remove config file (requires confirmation)
5 NetPlan Rollback Re-enable a previously disabled config
6 Resolved View Show resolved.conf, resolv.conf, resolvectl, backup status
7 Resolved Edit Enter new DNS IPs β†’ update resolved.conf β†’ restart
8 Resolved Disable Remove custom DNS entries β†’ revert to DHCP defaults
9 Resolved Delete Remove custom entries + delete backup (requires confirmation)
10 Resolved Rollback Restore resolved.conf from backup file
11 Both Reset All Remove all DNS Manager configs and restore system defaults

πŸ” Troubleshooting

Permission Denied

sudo dnsManager

Verify Current DNS

resolvectl status
cat /etc/netplan/99-dns-manager.yaml
cat /etc/resolv.conf

Manual Removal

NetPlan:

sudo rm /etc/netplan/99-dns-manager.yaml
sudo netplan apply

systemd-resolved:

sudo cp /etc/systemd/resolved.conf.backup /etc/systemd/resolved.conf
sudo systemctl restart systemd-resolved

πŸ“„ License

This script is provided as-is for free use.

🀝 Contributing

Contributions, issues, and feature requests are welcome!

⚠️ Disclaimer

Use this script at your own risk. Always ensure you have backups of important system configurations before making changes.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages