rhel Linux 网络配置

时间:2023-02-09 16:04:29

--网络配置

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

1)DHCP
DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes

2)静态IP                         
DEVICE=eth0                  
BOOTPROTO=none               
IPADDR=192.168.0.22          
NETMASK=255.255.255.0
GATEWAY=192.168.0.254
DNS1=192.168.0.254
ONBOOT=yes

vi /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=serv22
GATEWAY=192.168.0.254

vi /etc/resolv.conf
nameserver 192.168.0.254

vi /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1       serv22 localhost.localdomain localhost
::1             localhost6.localdomain6 localhost6

192.168.0.22    serv22

--网络管理命令
/etc/init.d/network start|stop|restart

--查看ip命令
ifconfig

--查看网关命令
route -n