All Distros

Quickly setting your system IP

Provided that you already have an IP ready to use, lets issue a couple of commands to get it good to go in your system.

1 - Verify the interface name. Issue: # /sbin/ip link;
     Output example: enp0s1, tun0, virbr0, etc.
 
 2 - Set the IP adress: # /sbin/ip addr add <ip_address/24> dev <interface_name>;
     Command example: # ip addr add 192.168.122.30/24 dev enp0s1
 
 3 - Set the gateway: /sbin/ip route add default via <gateway_address>;
     Command example: # ip route add default via 192.168.122.1

 4 - Enable the interface: /sbin/ip link set <interface_name> up.
     Command example: # ip link set enp0s1 up

This is a temporary configuration.  It will be vanished as soon as you reboot your system. A way to make it “permanent” is adding all the steps into /etc/rc.local. For more info on rc.local, take a look here.

However, I’d rather use a script to make the network configuration permanent. I made it working for RHEL (along with Fedora and CentOS), SLES and Ubuntu (Trusty and Xenial).

The script is available on github. Download it.

NOTE: The script is under constant work in progress. It currently has some DNS, Gateway and Network interfaces hardcoded (as I first implemented it). Then consider changing it if you plan to use it.

Also, consider this information regarding network interfaces.

Thank you

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s