dhclient //自动获取IP(通过DHCP)
ifconfig -a //查看网卡信息
[[email protected] ~]# ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:0C:29:47:DF:59
inet addr:192.168.137.22 Bcast:192.168.137.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe47:df59/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:66 errors:0 dropped:0 overruns:0 frame:0
TX packets:79 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:8105 (7.9 KiB) TX bytes:9539 (9.3 KiB)
Interrupt:19 Base address:0x2000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:10 errors:0 dropped:0 overruns:0 frame:0
TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:688 (688.0 b) TX bytes:688 (688.0 b)
手动配置IP地址
[[email protected] ~]#vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
HWADDR=00:0C:29:47:DF:59
TYPE=Ethernet
UUID=240760af-14a7-4da5-8cb5-d1e08d2319f4
ONBOOT=yes //开机自启动
NM_CONTROLLED=yes
BOOTPROTO=static //设置IP地址为静态
IPADDR=192.168.137.22 //IP地址
NETMASK=255.255.255.0 //网络掩码
GATEWAY=192.168.137.1 //网关
DNS1=8.8.8.8 //DNS
DNS2=114.114.114.114
配置好IP地址后重启网络
[[email protected] ~]# service network restart
Shutting down interface eth0: Device state: 3 (disconnected)
[ OK ]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0: Active connection state: activated
Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/1
[ OK ]
或单独重启某网卡
[[email protected] ~]# ifdown eth0
[[email protected] ~]# ifup eth0