Skip to main content

Command Palette

Search for a command to run...

Temporary Network Configuration Guideline (Linux)

Step-by-Step Guide to Linux Temporary Network Setup

Updated
6 min read
Temporary Network Configuration Guideline (Linux)

This guideline describes how to set up a temporary network configuration on a Linux server using ip commands. These changes will only persist until the next reboot.


1. Identify Your Network Interface

Check available network interfaces and note the one you want to configure (e.g., ens3).

ip link show

2. Flush Existing IP Addresses

Remove all current IP addresses from your interface to avoid conflicts.

sudo ip addr flush dev ens3

Replace ens3 with your actual interface name.


3. Assign a New IP Address

Set the desired IP address and subnet mask.

sudo ip addr add 51.1.1.51/24 dev ens3
  • 51.1.1.51 is the new IP.

  • /24 is the subnet mask (255.255.255.0).


4. Bring the Interface Up

Activate the interface if it is down.

sudo ip link set ens3 up

5. Set Up Routing

a. Add a Static Route (Optional)

If you need to reach a specific host directly:

sudo ip route add 15.2.2.15 dev ens3

b. Set the Default Gateway

Direct all traffic through the gateway:

sudo ip route add default via 15.2.2.15

6. Configure DNS

Set a DNS server to resolve domain names.

echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf

This replaces your /etc/resolv.conf with Google’s DNS.
Note: Changes to /etc/resolv.conf are also temporary and may be overwritten by network managers.


7. Automatic Setup Script

You can use the following shell script to automate this temporary network setup.
This script will prompt you for the required details and apply the configuration.

#!/bin/bash

# Temporary Linux Network Configuration (Interactive Script)

echo "=== Temporary Network Configuration ==="

# Prompt for network interface
read -p "Enter the network interface name (e.g., ens3): " IFACE

# Prompt for new IP address (with CIDR)
read -p "Enter the new IP address with CIDR (e.g., 192.168.1.100/24): " IPADDR

# Prompt for Gateway
read -p "Enter the gateway IP address (e.g., 192.168.1.1): " GATEWAY

# Prompt for DNS
read -p "Enter the DNS server IP (e.g., 8.8.8.8): " DNS

echo ""
echo "Applying network changes..."

# Flush existing IP addresses
sudo ip addr flush dev "$IFACE"

# Assign new IP address
sudo ip addr add "\(IPADDR" dev "\)IFACE"

# Bring the interface up
sudo ip link set "$IFACE" up

# Add default gateway
sudo ip route add default via "$GATEWAY"

# Set DNS server
echo "nameserver $DNS" | sudo tee /etc/resolv.conf

echo ""
echo "Network configuration applied (temporarily, until reboot)."
echo "Current network status:"
ip addr show "$IFACE"
ip route

echo ""
echo "Test connectivity (ping DNS server):"
ping -c 4 "$DNS"

echo ""
echo "Done."

Usage:

  1. Save as network_setup_prompt.sh.

  2. Make executable: chmod +x network_setup_prompt.sh

  3. Run: ./network_setup_prompt.sh

  4. Follow prompts to input interface, IP address, gateway, and DNS.

Note:
This configuration is temporary and will be lost after a reboot. For permanent changes, edit your network configuration files.


8. Verify Configuration

a. Check IP Address

ip a

b. Check Routing Table

ip route

c. Test Connectivity

  • Ping gateway or external IP:

    ping -c 4 8.8.8.8
    
  • Test DNS:

    ping -c 4 google.com
    

9. (Optional) Install Open vSwitch

If you need Open vSwitch for virtual networking:

sudo apt update
sudo apt install openvswitch-switch

10. Notes

  • Temporary: These changes will be lost after a reboot. For permanent changes, edit your network configuration files (e.g., /etc/network/interfaces, Netplan, or NetworkManager settings).

  • Permissions: All commands require root privileges (sudo).

  • Interface Name: Replace ens3 with your actual interface name.


11. Troubleshooting

  • If network is not working, check:

    • IP address assignment: ip a

    • Routing table: ip route

    • DNS settings: cat /etc/resolv.conf

    • Interface status: ip link show ens3

  • Re-run commands if you made a mistake or want to reset.

CONTACT:

I’m Kumar Bishojit Paul, the Founder and CEO of BIKIRAN. If you need further assistance, please leave a comment. I’m interested in helping you.


🏢 About Bikiran

Bikiran is a software development and cloud infrastructure company founded in 2012, headquartered in Khulna, Bangladesh. With 15,000+ clients and over a decade of experience, Bikiran builds and operates a suite of products spanning domain services, cloud hosting, app deployment, workflow automation, and developer tools.

SL Topic Product Description
1 Website Bikiran Main platform — Domain, hosting & cloud services
2 Website Edusoft Education management software for institutions
3 Website n8n Clouds Managed n8n workflow automation hosting
4 Website Timestamp Zone Unix timestamp converter & timezone tool
5 Website PDFpi Online PDF processing & manipulation tool
6 Website Blog Technical articles, guides & tutorials
7 Website Support 24/7 customer support portal
8 Website Probackup Automated database backup for SQL, PostgreSQL & MongoDB
9 Service Domain Domain registration, transfer & DNS management
10 Service Hosting Web, app & email hosting on NVMe SSD
11 Service Email & SMS Bulk email & SMS notification service
12 npm Chronopick Date & time picker React component
13 npm Rich Editor WYSIWYG rich text editor for React
14 npm Button Reusable React button component library
15 npm Electron Boilerplate CLI to scaffold Electron.js project templates
16 NuGet Bkash bKash payment gateway integration for .NET
17 NuGet Bikiran Engine Core .NET engine library for Bikiran services
18 Open Source PDFpi PDF processing tool — open source
19 Open Source Bikiran Engine Core .NET engine — open source
20 Open Source Drive CLI CLI tool to manage Google Drive from terminal
21 Docker Pgsql Docker setup for PostgreSQL
22 Docker n8n Docker setup for n8n automation
23 Docker Pgadmin Docker setup for pgAdmin
24 Social Media LinkedIn Bikiran on LinkedIn
25 Social Media Facebook Bikiran on Facebook
26 Social Media YouTube Bikiran on YouTube
27 Social Media FB n8nClouds n8n Clouds on Facebook