Difference between revisions of "Ip"
(Created page with "<yambe:breadcrumb>System_administration_tools|System Administration Tools</yambe:breadcrumb> =ip= In newer versions of Operating Systems such as Fedora 20 or CentOS 7, older ...") |
m |
||
Line 90: | Line 90: | ||
Similalry to make interface down without removing IP address use: | Similalry to make interface down without removing IP address use: | ||
<pre> | <pre> | ||
ip link set eth0 | ip link set eth0 down | ||
</pre> | </pre> | ||
Revision as of 13:35, 28 January 2015
<yambe:breadcrumb>System_administration_tools|System Administration Tools</yambe:breadcrumb>
ip
In newer versions of Operating Systems such as Fedora 20 or CentOS 7, older ifconfig and route commands are discontinuted. In such operating systems the only option is to use 'ip' command for obtaining network information.
Obtaining current configuration
To look at current IP address configuration use:
ip addr show
Similarly to look at current routes use:
ip route show
Persistent IP address configuration
To configure a static IP on an interface use following steps:
- Created or edit '/etc/sysconfig/network-scripts/ifcfg-<interface>' file. For example for eth0 it would be /etc/sysconfig/network-scripts/ifcfg-eth0
- In file configure persistent IP address (DHCP or static) as follows:
- DEVICE=eth0
- BOOTPROTO=static
- IPADDR="10.0.0.2"
- NETMASK="255.255.255.0"
- GATEWAY="10.0.0.1"
- DNS1="4.2.2.2"
- DNS2="8.8.8.8"
- ONBOOT="yes"
- NM_CONTROLLED="no"
- HWADDR=<MAC-address>
- Then use command "systemctl restart network" to restart network service and new configuration to take effect
- Then use "ip addr show" to list current IP addresses in use
Persistent static route configuration
To configure persistent static routes use following steps:
- Created or edit '/etc/sysconfig/network-scripts/route-<interface>' file. For example for eth0 it would be /etc/sysconfig/network-scripts/route-eth0
- In file configure persistent static route as follows:
- 10.10.1.0/24 via 10.0.0.3 dev eth0
- Then use command "systemctl restart network" to restart network service and new configuration to take effect
- Then use "ip route show" to list current routes in use
IP configuration commands
To configure IP address using commands, where the changes would be lost on machine reboot, use:
ip addr add 10.0.0.2 dev eth0
To configure static routes for current session (till next shutdown or reboot) use:
ip route add 10.10.1.0/24 via 10.0.0.3 dev eth0
To configure default route use
ip route add default via 10.0.0.1
Note that IP addresses can be removed using:
ip addr del 10.0.0.2 dev eth0
Similarly routes can be removed using
ip route del 10.10.1.0/24 via 10.0.0.3 dev eth0
To change interface state to up
To make interface up without assigning IP adddress (for capturing packets, etc.) use:
ip link set eth0 up
Similalry to make interface down without removing IP address use:
ip link set eth0 down
Note that down interfaces do not communicate with external network. But access to IP assigned to a local interface even if it is down will work.
Steps learned from http://www.tecmint.com/ip-command-examples/