Several ways to configure IP under Linux

  

First, temporarily enable the network card and configure the IP: # ifconfig -a /* View all network adapters, including inactive */

eth1 Link encap:Ethernet HWaddr 00:0C:29:34:42:D0inet addr:192.168.8.201 Bcast:192.168.8.255 Mask:255.255.255.0inet6 addr: fe80::20c:29ff:fe34:42d0/64 Scope:LinkUP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1RX packets:263 errors:0 dropped:0 overruns:0 frame:0TX packets:172 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:1000RX bytes:30752 (30.0 KiB) TX bytes:22324 ( 21.8 KiB)Interrupt:19 Base address:0x2000

lo Link encap:Local Loopbackinet addr:127.0.0.1 Mask:255.0.0.0inet6 addr: ::1/128 Scope:HostUP LOOPBACK RUNNING MTU:16436 Metric: 1RX packets:0 errors:0 dropped:0 overruns:0 frame:0TX packets:0 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:0RX bytes:0 (0.0 b) TX bytes:0 (0.0 b )

#ifconfgi eth1 192.168.8.201 netmask 255.255.255.0 up /*Configure IP address for eth1 and activate */Note: I configured by this method P restart will be invalid

Second, by directly configuring /etc/sysconfig/network-scripts/ifcfg-eth1 (generally ifcfg-eth0)#vi /etc/sysconfig/network-scripts/ifcfg-eth1

DEVICE=eth1 /*Device Name*/HWADDR=00:0c:29:34:42:d0 /*Network Card MAC*/NM_CONTROLLED=yesONBOOT=yes /* Whether to boot up*/IPADDR=192.168.8.201 /*IP address*/BOOTPROTO=noneNETMASK=255.255.255.0 /*Subnet mask*/TYPE=EthernetGATEWAY=192.168.8.8 /*Gateway*/DNS1=202.96.134.133 /*Preferred DNS*/DNS2=8.8.8.8 /* After the DNS*/IPV6INIT=noUSERCTL=no configuration is complete, use: wq to save and exit and restart the network service with the service network restart command to make the configured IP address take effect. Third, the system for the Redhat kernel, such as RHEL, CentOS, etc., can be configured through the intuitive configuration of the setup. After the configuration, the service network restart command is also used to restart the network service to make the IP address just configured effective. The specific configuration is as follows. Finally, remember to save all the way: use the up and down keys to select the network configuration and select the adapter configuration.

Copyright © Windows knowledge All Rights Reserved