Linux 网络配置
2011-10-18 00:06
190 查看
1. 介绍
Linux 网络管理主要涉及到一些配置文件和一些网络配置命令,熟悉这些文件和命令对于配置Linux网络十分重要。
在本文中,主要介绍一下几个重要的网络配置文件和网络配置命令。
2. 网络配置文件
(1)/etc/hosts
[root@localhost etc]# cat </etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
这个文件主要包含主机名到IP地址的映射。如果没有DNS服务器,可以通过这个进行解析。
(2) /etc/resolv.conf
[root@localhost etc]# cat <resolv.conf
search localdomain
nameserver 202.97.224.68
nameserver 即DNS,主要是用来配置DNS的。里面是DNS服务器的IP地址。
(3) /etc/sysconfig/network
[root@localhost etc]# cat /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=localhost.localdomain
所有的网络接口设备路由和主机信息。
(4) /etc/sysconfig/network-script/ifcfg-<interface-name>
[root@localhost network-scripts]# cat ifcfg-eth0
# Broadcom Corporation NetLink BCM5787M Gigabit Ethernet PCI Express
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
BOOTPROTO=none
HWADDR=00:1c:c4:d0:06:c4
TYPE=Ethernet
NETMASK=255.255.255.0
IPADDR=58.155.107.233
GATEWAY=58.155.107.1
USERCTL=no
IPV6INIT=no
PEERDNS=yes
每一个网络接口的配置信息,这里是eth0的配置信息。
3. 网络配置命令
(1)ifconfig [interface]
查看网卡信息。
如 ifconfig eth0
[root@localhost network-scripts]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:1C:C4:D0:06:C4
inet addr:58.155.107.233 Bcast:58.155.107.255 Mask:255.255.255.0
inet6 addr: 2001:250:7801:c14:21c:c4ff:fed0:6c4/64 Scope:Global
inet6 addr: fe80::21c:c4ff:fed0:6c4/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:18760 errors:0 dropped:0 overruns:0 frame:0
TX packets:4838 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:13988920 (13.3 MiB) TX bytes:1002075 (978.5 KiB)
Interrupt:18
(2)配置IP地址
ifconfig eth0 222.27.253.108 netmsk 255.255.255.0
配置IP地址与子网掩码。
ifconfig eth0 hw ether xx:xx:xx:xx:xx:xx
配置Mac.
(3) 网卡禁用与启用
ifconfig eth0 down
ifconfig eth0 up
通常情况下,先禁用网卡,进行配置之后才再次启用网卡,正常配置以后就能够上网了。
关于Linux下网络配置就简单的介绍到这里了。
Linux 网络管理主要涉及到一些配置文件和一些网络配置命令,熟悉这些文件和命令对于配置Linux网络十分重要。
在本文中,主要介绍一下几个重要的网络配置文件和网络配置命令。
2. 网络配置文件
(1)/etc/hosts
[root@localhost etc]# cat </etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
这个文件主要包含主机名到IP地址的映射。如果没有DNS服务器,可以通过这个进行解析。
(2) /etc/resolv.conf
[root@localhost etc]# cat <resolv.conf
search localdomain
nameserver 202.97.224.68
nameserver 即DNS,主要是用来配置DNS的。里面是DNS服务器的IP地址。
(3) /etc/sysconfig/network
[root@localhost etc]# cat /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=localhost.localdomain
所有的网络接口设备路由和主机信息。
(4) /etc/sysconfig/network-script/ifcfg-<interface-name>
[root@localhost network-scripts]# cat ifcfg-eth0
# Broadcom Corporation NetLink BCM5787M Gigabit Ethernet PCI Express
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
BOOTPROTO=none
HWADDR=00:1c:c4:d0:06:c4
TYPE=Ethernet
NETMASK=255.255.255.0
IPADDR=58.155.107.233
GATEWAY=58.155.107.1
USERCTL=no
IPV6INIT=no
PEERDNS=yes
每一个网络接口的配置信息,这里是eth0的配置信息。
3. 网络配置命令
(1)ifconfig [interface]
查看网卡信息。
如 ifconfig eth0
[root@localhost network-scripts]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:1C:C4:D0:06:C4
inet addr:58.155.107.233 Bcast:58.155.107.255 Mask:255.255.255.0
inet6 addr: 2001:250:7801:c14:21c:c4ff:fed0:6c4/64 Scope:Global
inet6 addr: fe80::21c:c4ff:fed0:6c4/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:18760 errors:0 dropped:0 overruns:0 frame:0
TX packets:4838 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:13988920 (13.3 MiB) TX bytes:1002075 (978.5 KiB)
Interrupt:18
(2)配置IP地址
ifconfig eth0 222.27.253.108 netmsk 255.255.255.0
配置IP地址与子网掩码。
ifconfig eth0 hw ether xx:xx:xx:xx:xx:xx
配置Mac.
(3) 网卡禁用与启用
ifconfig eth0 down
ifconfig eth0 up
通常情况下,先禁用网卡,进行配置之后才再次启用网卡,正常配置以后就能够上网了。
关于Linux下网络配置就简单的介绍到这里了。
相关文章推荐
- Linux网络配置详解
- VMware12中的Linux系统利用NAT网络连接方式访问外网配置
- Linux系统基础网络配置老鸟精华篇
- Linux基础-配置网络、集群内主机名设定、ssh登入、bash命令、通配符(元字符)
- Linux网络接口配置文件解析
- Linux网络属性配置
- Linux网络配置
- Linux下的网络环境配置
- Linux 网络接口配置文件及相关工具 (v0.1b)
- Linux配置网络(无图形界面)
- Linux网络配置
- 大数据开发【Linux系统 本地虚拟机网络配置】
- linux--高级网络配置 bond team br0
- LINUX网络配置文件
- 【网络安全】Linux数据路由转发配置
- Linux命令 — 设置或查看网络配置命令ifconfig
- linux 虚拟机模拟配置网络路由环境-简版
- Linux网络管理 (一)虚拟机网络配置
- linux高级编程三网络以及网络配置
- Linux 配置完IP网络服务后重启,发现未知错误连接