Skip to content

Instantly share code, notes, and snippets.

@kurtis318
Created March 30, 2017 15:10
Show Gist options
  • Save kurtis318/8673622165e9f18dd2a7621f1c001b8e to your computer and use it in GitHub Desktop.
Save kurtis318/8673622165e9f18dd2a7621f1c001b8e to your computer and use it in GitHub Desktop.
Manually add and remove an IP to a Linux server vi ip command
I am constantly needing to set an IP on a server for some reason. Most of the time the reason is to verify connectivity. Here is the commands I use to add and remove the IP.
ip address add 192.168.122.22/24 dev enP1p1s0f0
ip address del 192.168.122.22/24 dev enP1p1s0f0
Here are a couple of things to keep in mind about these commands:
1. If you do note specify the prefix (/24 in this case) to the IP address the default is /32.
2. The interface is brought up automatically. There is no need to run ifup
3. I believe ifup and ifdown assume there config files (/etc/sysconf/network-scripts/ifcfg-* for RPM based systems).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment