[root@tiny ~]$ ifconfig
eth2 Link encap:Ethernet HWaddr 00:0C:29:FE:F8:14
inet6 addr: fe80::20c:29ff:fefe:f814/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:68 errors:0 dropped:0 overruns:0 frame:0
TX packets:9 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:7385 (7.2 KiB) TX bytes:2310 (2.2 KiB)
Interrupt:19 Base address:0x2024
loLink 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:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:480 (480.0 b) TX bytes:480 (480.0 b)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
会报 UP BROADCAST RUNNING MULTICAST错误。这是因为mac地址设置的问题,在这里提供一个解决办法:
1. 切换至root用户
由于相关文件只能由root进行修改,因此我们先应该转换为root用户启动
[admin@tiny ~]$ su root
1
1
2.查看当前MAC地址相关信息
[root@tiny rules.d]# cat /etc/udev/rules.d/70-persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.
# PCI device 0x1022:0x2000 (pcnet32)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:49:e9:9d", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x1022:0x2000 (vmxnet)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:13:e9:e2", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
# PCI device 0x1022:0x2000 (vmxnet)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:fe:f8:14", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
我们可以看到其中包含三块网卡信息分别是eth0,eth1,eth2,而我们使用eth2所以我们需要删除掉其他两块网卡信息。
[root@tiny rules.d]# vi /etc/udev/rules.d/70-persistent-net.rules
[root@tiny rules.d]# cat /etc/udev/rules.d/70-persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.
# PCI device 0x1022:0x2000 (vmxnet)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:fe:f8:14", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"
1
2
3
4
5
6
7
8
9
10
11
1
2
3
4
5
6
7
8
9
10
11
我们只留下eth2的网卡信息,我们记录下eth2的mac地址:00:0c:29:fe:f8:14。
4. 修改ifcfg-eth2中的信息
在这里我发现了一件非常尴尬的事情,在/etc/sysconfig/network-scripts/文件夹下没有ifcfg-eth2
[root@tiny network-scripts]# ls /etc/sysconfig/network-scripts/
ifcfg-eth0~ ifdown-ipppifdown-tunnel ifup-isdnifup-tunnel
ifcfg-eth1 ifdown-ipv6ifup ifup-plipifup-wireless
ifcfg-eth1~ ifdown-isdnifup-aliases ifup-plusb init.ipv6-global
ifcfg-lo ifdown-postifup-bnep ifup-postnet.hotplug
ifdown ifdown-ppp ifup-eth ifup-ppp network-functions
ifdown-bnep ifdown-routes ifup-ippp ifup-routes network-functions-ipv6
ifdown-eth ifdown-sit ifup-ipv6 ifup-sit
1
2
3
4
5
6
7
8
1
2
3
4
5
6
7
8
但是,我们可以拷贝一个
[root@tiny network-scripts]# mv /etc/sysconfig/network-scripts/ifcfg-eth1 /etc/sysconfig/network-scripts/ifcfg-eth2
1
1
然后我们打开ifcfg-eth2
[root@tiny network-scripts]# cat /etc/sysconfig/network-scripts/ifcfg-eth2
DEVICE=eth1
TYPE=Ethernet
UUID=eeb8ed32-3b4d-45c4-b2fe-9c7b5fe4e2ac
ONBOOT=yes
NM_CONTROLLED=yes
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth1"
HWADDR=00:0C:29:49:E9:9D
LAST_CONNECT=1488606798
BOOTPROTO=static
IPADDR=192.168.132.114
NETMASK=255.255.255.0
GATEWAY=192.168.132.1
DNS1=210.31.249.20
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
mac地址和在70-persistent-net.rules中的mac并不一样,我们将70-persistent-net.rules中的mac地址复制过来,并且将DEVICE和NAME也做相应的修改
[root@tiny network-scripts]# vi /etc/sysconfig/network-scripts/ifcfg-eth2
[root@tiny network-scripts]# cat /etc/sysconfig/network-scripts/ifcfg-eth2
DEVICE=eth2
TYPE=Ethernet
UUID=eeb8ed32-3b4d-45c4-b2fe-9c7b5fe4e2ac
ONBOOT=yes
NM_CONTROLLED=yes
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth2"
HWADDR=00:0c:29:fe:f8:14
LAST_CONNECT=1488606798
BOOTPROTO=static
IPADDR=192.168.132.115
NETMASK=255.255.255.0
GATEWAY=192.168.132.1
DNS1=210.31.249.20
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
5. 重启服务,并测试
重启network,查看网卡信息,并测试联网情况 。执行下面的命令:
[root@tiny network-scripts]# service network restart
正在关闭接口 eth2: 设备状态:3 (断开连接)
[确定]
关闭环回接口: [确定]
d出环回接口: [确定]
d出界面 eth2: 活跃连接状态:激活的
活跃连接路径:/org/freedesktop/NetworkManager/ActiveConnection/23
[确定]
[root@tiny network-scripts]# ifconfig
eth2 Link encap:Ethernet HWaddr 00:0C:29:FE:F8:14
inet addr:192.168.132.115 Bcast:192.168.132.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fefe:f814/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1595 errors:0 dropped:0 overruns:0 frame:0
TX packets:117 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:159465 (155.7 KiB) TX bytes:33595 (32.8 KiB)
Interrupt:19 Base address:0x2024
loLink 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:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:480 (480.0 b) TX bytes:480 (480.0 b)
[root@tiny network-scripts]# ping 119.75.217.109
PING 119.75.217.109 (119.75.217.109) 56(84) bytes of data.
64 bytes from 119.75.217.109: icmp_seq=1 ttl=64 time=0.611 ms
64 bytes from 119.75.217.109: icmp_seq=2 ttl=64 time=0.261 ms
^C
--- 119.75.217.109 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1424ms
rtt min/avg/max/mdev = 0.261/0.436/0.611/0.175 ms
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
修改成功
广播地址。
专门用于同时向网络中(通常指同一子网)所有工作站进行发送的一个地址。在使用TCP/IP 协议的网络中,主机标识段host ID(简称主机 ID) 为全 1 的 IP 地址为广播地址,广播的分组传送给同一个子网的所有计算机。
例如:
对于10.1.1.0 (255.255.255.0 )网段,其广播地址为10.1.1.255 (255 即为 2 进制的 11111111 ),当发出一个目的地址为10.1.1.255 的数据包时,它将被分发给该网段上的所有计算机。广播地址应用于网络内的所有主机。
扩展资料:分类
1、受限广播
路由器不会转发受限广播的数据包,但同一个子网的所有主机都会接收到受限广播的数据包。
IP 地址的网络字段和主机字段全为 1 就是受限广播地址255.255.255.255。
2、直接广播(也叫定向广播)
直接广播可以被路由转发,发送到目标网络的所有主机,如:ip地址为 192.168.2.1 的主机也可以发送广播到192.168.1.0这个网络。当然不是所有的路由器,傻瓜式路由器是默认阻止直接广播的。
IP 地址的网络字段定义这个网络,主机字段通常全为 1,如192.168.10.0/24 的直接广播(定向广播)地址为:192.168.10.255。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)