Modify Nic IP information

Source: Internet
Author: User

There are many ways to modify the IP address of the network adapter, but there are two types in general. One is temporary modification, which will expire after the network service is restarted. The other is Permanent modification, it takes effect only after the network service is restarted. In general, the temporary modification application is in the temporary action, and we can also know through the classification name, in order to deal with the following temporary problems. The Permanent modification aims to build a stable network environment, that is, a production environment.

Now we will introduce two simple operations for modification in classification.

1. Temporary Modification

Before change:

[Root @ brief top40 network-scripts] # ifconfig br0
Br0 Link encap: Ethernet HWaddr 00: 0C: 29: 4E: 5B: F2
Inet addr: 192.168.1.131 Bcast: 192.168.1.255 Mask: 255.255.255.0
Inet6 addr: fe80: 20c: 29ff: fe4e: 5bf2/64 Scope: Link
Up broadcast running multicast mtu: 1500 Metric: 1
RX packets: 7300 errors: 0 dropped: 0 overruns: 0 frame: 0
TX packets: 613 errors: 0 dropped: 0 overruns: 0 carrier: 0
Collisions: 0 txqueuelen: 0
RX bytes: 981381 (958.3 KiB) TX bytes: 56311 (54.9 KiB)

After modification:

[Root @ brief top40 network-scripts] # ifconfig br0 192.168.0.53 netmask 255.255.255.0 up
[Root @ brief top40 network-scripts] # ifconfig br0
Br0 Link encap: Ethernet HWaddr 00: 0C: 29: 4E: 5B: F2
Inet addr: 192.168.0.53 Bcast: 192.168.0.255 Mask: 255.255.255.0
Inet6 addr: fe80: 20c: 29ff: fe4e: 5bf2/64 Scope: Link
Up broadcast running multicast mtu: 1500 Metric: 1
RX packets: 7390 errors: 0 dropped: 0 overruns: 0 frame: 0
TX packets: 631 errors: 0 dropped: 0 overruns: 0 carrier: 0
Collisions: 0 txqueuelen: 0
RX bytes: 997607 (974.2 KiB) TX bytes: 60847 (59.4 KiB)


From the above example, we can know that the temporary configuration of the nic ip address is the use of the ifconfig, ifup, and ifdown commands. The above is just a simple example. You can first change the NIC ifdown when modifying the IP address, then configure ifconfig and then use the ifup command to start the NIC.

As we have mentioned at the beginning of this article, temporary modification will automatically change back to the initial parameter configuration after the host is restarted. Let's restart the network service to see if it is as we said.

[Root @ brief top40 network-scripts] # ifconfig br0
Br0 Link encap: Ethernet HWaddr 00: 0C: 29: 4E: 5B: F2
Inet addr: 192.168.1.131 Bcast: 192.168.1.255 Mask: 255.255.255.0
Inet6 addr: fe80: 20c: 29ff: fe4e: 5bf2/64 Scope: Link
Up broadcast running multicast mtu: 1500 Metric: 1
RX packets: 7664 errors: 0 dropped: 0 overruns: 0 frame: 0
TX packets: 669 errors: 0 dropped: 0 overruns: 0 carrier: 0
Collisions: 0 txqueuelen: 0
RX bytes: 1043312 (1018.8 KiB) TX bytes: 66993 (65.4 KiB)

As we said, the initial configuration of nic ip address change back.

Ii. Permanent modification

We know that we need to modify the network configuration file to permanently modify the network configuration file. In the previous article, we have added the location of the network configuration file, so we will not fix it here.

This is the configuration of my host eth0:

[Root @ override top40 network-scripts] # cat ifcfg-eth0
DEVICE = "eth0"
BOOTPROTO = "dhcp"
HWADDR = "00: 0C: 29: 4E: 5B: F2"
IPV6INIT = "yes"
MTU = "1500"
NM_CONTROLLED = "yes"
ONBOOT = "yes"
TYPE = "Ethernet"
UUID = "a6c176f0-6f6c-4629-92b5-f13c577d37cd"
DEVICE = eth0
BOOTPROTO = none
BRIDGE = br0
ONBOOT = yes
This is the configuration of my host br0:

[Root @ override top40 network-scripts] # cat ifcfg-br0
# Bridge Networking Interface
DEVICE = br0
ONBOOT = yes
BOOTPROTO = dhcp
TYPE = Bridge
USERCTL = yes
NM_CONTROLLED = no
IPV6INIT = no
PEERNTP = no
DELAY = 0
NAME = "Bridge eth0"
[Root @ brief top40 network-scripts] #

From the above configuration, we can know that my Nic IP address is dynamic, so we will configure it as static.

Original file:

[Root @ override top40 network-scripts] # vim ifcfg-eth0

DEVICE = "eth0"
BOOTPROTO = "dhcp"
HWADDR = "00: 0C: 29: 4E: 5B: F2"
IPV6INIT = "yes"
MTU = "1500"
NM_CONTROLLED = "yes"
ONBOOT = "yes"
TYPE = "Ethernet"
UUID = "a6c176f0-6f6c-4629-92b5-f13c577d37cd"
DEVICE = eth0
BOOTPROTO = none
BRIDGE = br0
ONBOOT = yes

After modification:

[Root @ override top40 network-scripts] # vim ifcfg-eth0

DEVICE = "eth0"
BOOTPROTO = "static"
IPADDR = 192.168.0.33
NETMASK = 255.255.255.0
HWADDR = "00: 0C: 29: 4E: 5B: F2"
IPV6INIT = "yes"
MTU = "1500"
NM_CONTROLLED = "yes"
ONBOOT = "yes"
TYPE = "Ethernet"
UUID = "a6c176f0-6f6c-4629-92b5-f13c577d37cd"
BRIDGE = br0

Complete subsequent operations:

1. Stop NM

[Root @ brief top40 network-scripts] # service NetworkManager restart
Stopping NetworkManager daemon: [FAILED]
Setting network parameters... [OK]
Starting NetworkManager daemon: [OK]
[Root @ brief top40 network-scripts] # service NetworkManager stop
Stopping NetworkManager daemon: [OK]

2. Restart the network service.

[Root @ brief top40 network-scripts] # service network restart
Shutting down interface br0: [OK]
Shutting down interface eth0: [OK]
Shutting down loopback interface: [OK]
Bringing up loopback interface: [OK]
Bringing up interface eth0: [OK]
Bringing up interface br0:
Determining IP information for br0.... done.
[OK]

3. view the IP address of the eth0 Nic
[Root @ override top40 network-scripts] # ifconfig eth0
Eth0 Link encap: Ethernet HWaddr 00: 0C: 29: 4E: 5B: F2
Inet addr: 192.168.0.140 Bcast: 192.168.0.255 Mask: 255.255.255.0
Inet6 addr: fe80: 20c: 29ff: fe4e: 5bf2/64 Scope: Link
Up broadcast running promisc multicast mtu: 1500 Metric: 1
RX packets: 9069 errors: 0 dropped: 0 overruns: 0 frame: 0
TX packets: 971 errors: 0 dropped: 0 overruns: 0 carrier: 0
Collisions: 0 FIG: 1000
RX bytes: 1348353 (1.2 MiB) TX bytes: 106170 (103.6 KiB)
Supplement: static Nic configuration information:




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.