> [root@localhost ~]# ifconfig
eth1 Link encap:Ethernet HWaddr 00:0C:29:33:4A:0C
inet addr:192.168.4.115 Bcast:192.168.4.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe33:4a0c/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:8133 errors:0 dropped:0 overruns:0 frame:0
TX packets:5861 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:818322 (799.1 KiB) TX bytes:835205 (815.6 KiB)
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:16436 Metric:1
RX packets:14 errors:0 dropped:0 overruns:0 frame:0
TX packets:14 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:946 (946.0 b) TX bytes:946 (946.0 b)
[root@localhost ~]# hostname
localhost
[root@localhost ~]# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.4.0 * 255.255.255.0 U 1 0 0 eth1
default localhost 0.0.0.0 UG 0 0 0 eth1
[root@localhost ~]# netstat -antput
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:875 0.0.0.0:* LISTEN 2262/rpc.rquotad
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1963/rpcbind
tcp 0 0 0.0.0.0:33073 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:40337 0.0.0.0:* LISTEN 2266/rpc.mountd
tcp 0 0 0.0.0.0:53586 0.0.0.0:* LISTEN 2010/rpc.statd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 2345/sshd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 2084/cupsd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2590/master
tcp 0 0 0.0.0.0:35161 0.0.0.0:* LISTEN 2266/rpc.mountd
tcp 0 0 0.0.0.0:2049 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:42759 0.0.0.0:* LISTEN 2266/rpc.mountd
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 3041/mysqld
tcp 0 756 192.168.4.115:22 192.168.4.105:52347 ESTABLISHED 2788/sshd
tcp 0 0 :::111 :::* LISTEN 1963/rpcbind
tcp 0 0 :::53461 :::* LISTEN 2266/rpc.mountd
tcp 0 0 :::22 :::* LISTEN 2345/sshd
tcp 0 0 ::1:631 :::* LISTEN 2084/cupsd
tcp 0 0 ::1:25 :::* LISTEN 2590/master
tcp 0 0 :::60442 :::* LISTEN 2266/rpc.mountd
[root@localhost ~]# ping www.baidu.com
PING www.a.shifen.com (123.125.65.78) 56(84) bytes of data.
64 bytes from 123.125.65.78: icmp_seq=1 ttl=56 time=141 ms
64 bytes from 123.125.65.78: icmp_seq=2 ttl=56 time=18.9 ms
64 bytes from 123.125.65.78: icmp_seq=3 ttl=56 time=17.3 ms
64 bytes from 123.125.65.78: icmp_seq=4 ttl=56 time=19.9 ms
[root@localhost ~]# nslookup
> www.baidu.com
Server: 192.168.1.1
Address: 192.168.1.1#53
Non-authoritative answer:
www.baidu.com canonical name = www.a.shifen.com.
Name: www.a.shifen.com
Address: 123.125.65.78
Name: www.a.shifen.com
Address: 123.125.65.82
[root@localhost ~]# traceroute www.baidu.com
traceroute to www.baidu.com (119.75.218.70), 30 hops max, 60 byte packets
1 192.168.40.1 (192.168.40.1) 1.223 ms 3.555 ms 4.307 ms
2 117.100.128.1 (117.100.128.1) 8.126 ms 8.927 ms 8.623 ms
3 124.205.97.48 (124.205.97.48) 8.430 ms 8.248 ms 8.100 ms
4 219.239.249.25 (219.239.249.25) 7.906 ms 7.953 ms 7.887 ms
5 14.197.177.9 (14.197.177.9) 7.874 ms 14.197.178.45 (14.197.178.45) 7.672 ms 14.197.178.41 (14.197.178.41) 7.485 ms
6 14.197.253.49 (14.197.253.49) 11.445 ms * *
一. 臨時配置:一般用命令來配置,馬上生效,重啟無效
[root@localhost ~]# ifconfig eth1 192.168.40.20 netmask 255.255.255.0
[root@localhost ~]# ifconfig eth1 192.168.40.20/32
[root@localhost ~]# ifconfig eth1 down
[root@localhost ~]# ifconfig eth1 up
[root@localhost ~]# ifdown eth1
[root@localhost ~]# ifup eth1
[root@localhost ~]# service network restart
[root@localhost ~]# ifconfig eth1:0 10.1.1.1
[root@localhost ~]# route add -net 192.148.40.0/32 gw 192.148.40.1
[root@localhost ~]# route del -net 192.148.40.0/32
[root@localhost ~]# route add default gw 192.168.4.1
[root@localhost ~]# route del default gw 192.168.4.1
[root@localhost ~]# hostname bkjia
[root@localhost ~]# bash
[root@bkjia ~]#
二. 固定配置:一般是更改配置文件,需要重啟生效
DEVICE=eth0 #設備名字
ONBOOT=yes #是否隨系統啟動而啟動
BOOTPROTO=static (dhcp) # 網絡參數配置方式
IPADDR=192.168.4.1 #ip地址
NETMASK=255.255.255.0 # 子網掩碼
GATEWAY=192.168.4.2 # 默認網關
DNS1=202.106.0.20 # DNS地址
[root@bkjia ~]# vim /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=localhost
[root@bkjia ~]# vim /etc/resolv.conf
# Generated by NetworkManager
nameserver 192.168.1.1
nameserver 192.168.4.1
[root@bkjia ~]# vim /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
[root@bkjia ~]# service network restart
[root@bkjia ~]# ifdown eth1
[root@bkjia ~]# ifup eth1
本文永久更新鏈接地址:
http://xxxxxx/Linuxjc/1135369.html TechArticle