Skip to content

Instantly share code, notes, and snippets.

@kahidna
Last active May 23, 2025 00:42
Show Gist options
  • Select an option

  • Save kahidna/8c5c1aecb2ec9937b1d24818129d2c61 to your computer and use it in GitHub Desktop.

Select an option

Save kahidna/8c5c1aecb2ec9937b1d24818129d2c61 to your computer and use it in GitHub Desktop.
command line in linux to assign IP, gateway and DNS server

assign temporal IP using commandline instead config file

Make sure your Linux have ifconfig binary commands first.
Define the IP and the netmask. for example

ifconfig eth0 192.168.104.158 netmask 255.255.255.0

Find your gateway of your network, and then add the gateway IP

route add default gw 192.168.103.254

And then add the dns server (make sure the resolv.conf file backed up or its safe to be written)

echo nameserver 8.8.8.8 > /etc/resolv.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment