linux查找网络配置文件_查找Linux网络配置信息

linux查找网络配置文件

There is various network configuration information in Linux and lots tools can be used to find out those configuration information. Finding out these network information in Fedora Linux as the example will be introduced.

Linux中有各种网络配置信息,可以使用很多工具来查找那些配置信息。 作为示例,将介绍在Fedora Linux中查找这些网络信息。

IP地址,MAC地址和网络掩码 (IP address, MAC address and netmask)

ifconfig will print out all the network interfaces and their information including the IP address and netmask.

ifconfig将打印出所有网络接口及其信息,包括IP地址和网络掩码。

$ ifconfig

A typical output is like this:

典型的输出如下所示:

eth0      Link encap:Ethernet  HWaddr 00:26:22:A1:25:0F
inet addr:143.89.135.175  Bcast:143.89.135.255  Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
RX packets:305973 errors:0 dropped:0 overruns:0 frame:0
TX packets:337971 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:196287324 (187.1 MiB)  TX bytes:134890044 (128.6 MiB)
Interrupt:30

lo        Link encap:Local Loopback
inet addr:127.0.0.1  Mask:255.0.0.0
UP LOOPBACK RUNNING  MTU:16436  Metric:1
RX packets:274 errors:0 dropped:0 overruns:0 frame:0
TX packets:274 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:37244 (36.3 KiB)  TX bytes:37244 (36.3 KiB)

eth0 is the network interface. lo is the loopback device.

eth0是网络接口。 lo是回送设备。

The IP address is shown in inet addr field.

IP地址显示在inet addr字段中。

DNS服务器,主机文件和DNS查找顺序 (DNS server, hosts file and DNS look up order)

The DNS server for Linux to contact is stored in /etc/resolve.conf. The DNS server(s) can be listed by:

Linux可以联系的DNS服务器存储在/etc/resolve.conf中 。 可以通过以下方式列出DNS服务器:

$ cat /etc/resolve.conf

A line like this specifies the DNS server:

这样的行指定了DNS服务器:

nameserver 8.8.8.8

The hosts file for Linux is stored in /etc/hosts. The first two lines (127.0.0.1 and ::1) which map the localhost name shouldn’t be changed since localhost is used for interprocess communication.

Linux的hosts文件存储在/ etc / hosts中。 映射本地主机名的前两行(127.0.0.1和:: 1)不应更改,因为本地主机用于进程间通信。

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
10.0.1.8   mysite.mydomain mysite

The order of DNS look up is defined in /etc/nsswitch.conf. Whether the hosts file should be looked up first can be defined. The line in /etc/nsswitch.conf for DNS look up order is:

DNS查找的顺序在/etc/nsswitch.conf中定义。 可以定义是否应首先查找主机文件。 /etc/nsswitch.conf中用于DNS查找顺序的行是:

hosts:      files mdns4_minimal [NOTFOUND=return] dns

网关 (Gateway)

The gateway can be find out by looking at the rules in route table:

通过查看路由表中的规则可以找到网关:

$ ip route show

A line like this defines the gateway:

像这样的一行定义了网关:

default via 143.89.135.254 dev eth0  proto static

主机名 (Host name )

You can find your own hostname by running:

您可以通过运行以下命令找到自己的主机名:

hostname

The long hostname can be found by:

长主机名可以通过以下方式找到:

hostname --long

For changing your hostname: Changing Hostname of Fedora Linux.

更改主机名: 更改Fedora Linux的主机名

翻译自: https://www.systutorials.com/finding-out-linux-network-configuration-information/

linux查找网络配置文件

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值