Linux命令行配置IP、GW、DNS

一、修改IP地址文件:

                     /etc/sysconfig/network-scripts/ifcfg-eth0

静态地址:

DEVICE=eth0
BOOTPROTO=static
IPADDR=192.168.1.242
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
HWADDR=00:0C:29:E4:7C:BB
ONBOOT=yes
TYPE=Ethernet

 

动态分配

DEVICE=eth0
BOOTPROTO=dhcp
#IPADDR=192.168.1.242
#NETMASK=255.255.255.0
#GATEWAY=192.168.1.1
HWADDR=00:0C:29:E4:7C:BB
ONBOOT=yes
TYPE=Ethernet

 

 

二、修改DNS:

                     /etc/resolv.conf

 

 

search localdomain
nameserver 192.168.230.2

 

 

三、重启网络配置:

                     service network restart

 

 

四、开启/关闭防火墙:

                     service iptables start/stop

                     service  iptables on/off

你可能感兴趣的:(Linux基础)