RHEL在VLAN Trunk模式下的IP地址配置

今天拿到客户两笼刀片机,进行RHEL6U3系统的安装操作,打算安装完第一台刀片之后,将其配置成KICKSTART服务器对其他刀片进行网络安装。

然而,安装完第一片刀之后,对其进行IP的设置。

1. 首先查看有多少个网卡

[root@blog01 ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
    link/ether 38:ea:a7:a1:fd:66 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::3aea:a7ff:fea1:fd66/64 scope link
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether 38:ea:a7:a1:fd:6a brd ff:ff:ff:ff:ff:ff
4: eth2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether 38:ea:a7:a1:fd:68 brd ff:ff:ff:ff:ff:ff
5: eth3: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether 38:ea:a7:a1:fd:6c brd ff:ff:ff:ff:ff:ff
6: eth4: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether 38:ea:a7:a1:fd:69 brd ff:ff:ff:ff:ff:ff
7: eth5: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether 38:ea:a7:a1:fd:6d brd ff:ff:ff:ff:ff:ff
8: eth6: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether 38:ea:a7:a1:fd:6e brd ff:ff:ff:ff:ff:ff
9: eth7: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether 38:ea:a7:a1:fd:72 brd ff:ff:ff:ff:ff:ff


2. 查看哪些网卡是连接正常的

[root@blog01 ~]# for i  in `seq 0 7`
> do
> res=`ethtool eth$i |grep Link |awk -F: '{print $2}'`
> echo "eth$i  Link $res"
> done
eth0  Link  yes
eth1  Link  yes
eth2  Link  no
eth3  Link  no
eth4  Link  no
eth5  Link  no
eth6  Link  no
eth7  Link  no

3. 可以看出eth0,eth1是连接成功的

4. 对eth0配置IP地址

从客户获得的IP设置范围是10.196.28.0/24 ,该网段端口被设置成了Trunk模式。

5.手动将eth0加入vlan id为528的VLAN,并配置IP

[root@blog01 ~]# vconfig  add eth0 528
[root@blog01 ~]# ifconfig eth0.528 10.196.28.43 netmask 255.255.255.0
[root@blog01 ~]# ping  -W1 -c2 10.196.28.254
PING 10.196.28.254 (10.196.28.254) 56(84) bytes of data.
64 bytes from 10.196.28.254: icmp_seq=1 ttl=255 time=1.14 ms
64 bytes from 10.196.28.254: icmp_seq=2 ttl=255 time=1.15 ms
--- 10.196.28.254 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1002ms
rtt min/avg/max/mdev = 1.149/1.154/1.159/0.005 ms

6.写入网卡配置文件

为了使得系统重启后,IP配置仍旧生效,写入系统配置文件

另外本机需要作为KVM虚拟化平台,故需要创建桥接设备br0

[root@blog01 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
TYPE=Ethernet
BOOTPROTO=none
[root@blog01 ~]#cat /etc/sysconfig/network-scripts/ifcfg-eth0.528
DEVICE=eth0.528
ONBOOT=yes
BOOTPROTO=none
VLAN=yes
TYPE=Ethernet
BRIDGE=br0
[root@blog01 ~]#cat /etc/sysconfig/network-scripts/ifcfg-br0
DEVICE=br0
ONBOOT=yes
BOOTPROTO=none
TYPE=Bridge
IPADDR=10.196.28.43
NETMASK=255.255.255.0
GATEWAY=10.196.28.254

7.重新启动网络服务,查看最终网卡配置信息

[root@blog01 ~ ]# service network restart
[root@blog01  ~]# cat /proc/net/vlan/config
VLAN Dev name     | VLAN ID
Name-Type: VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD
eth0.528       | 528  | eth0
[root@SJC42KVM01 ~]# brctl  show
bridge name    bridge id        STP enabled    interfaces
br0        8000.38eaa7a1fd66    no        eth0.528
[root@SJC42KVM01 ~]# ifconfig  eth0
eth0      Link encap:Ethernet  HWaddr 38:EA:A7:A1:FD:66 
          inet6 addr: fe80::3aea:a7ff:fea1:fd66/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:14600981 errors:0 dropped:0 overruns:0 frame:0
          TX packets:16880 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1175506152 (1.0 GiB)  TX bytes:4080056 (3.8 MiB)
[root@blog01  ~]# ifconfig  eth0.528
eth0.528  Link encap:Ethernet  HWaddr 38:EA:A7:A1:FD:66 
          inet6 addr: fe80::3aea:a7ff:fea1:fd66/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:600 errors:0 dropped:0 overruns:0 frame:0
          TX packets:313 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:66715 (65.1 KiB)  TX bytes:57925 (56.5 KiB)
[root@blog01 ~]# ifconfig  br0
br0       Link encap:Ethernet  HWaddr 38:EA:A7:A1:FD:66 
          inet addr:10.196.28.43  Bcast:10.196.28.255  Mask:255.255.255.0
          inet6 addr: fe80::3aea:a7ff:fea1:fd66/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:549 errors:0 dropped:0 overruns:0 frame:0
          TX packets:345 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:63581 (62.0 KiB)  TX bytes:64296 (62.7 KiB)


8.测试网络连接是否通畅

[root@blog01 ~]# ping -W1 -c2  10.196.28.254
PING 10.196.28.254 (10.196.28.254) 56(84) bytes of data.
64 bytes from 10.196.28.254: icmp_seq=1 ttl=255 time=1.31 ms
64 bytes from 10.196.28.254: icmp_seq=2 ttl=255 time=0.907 ms
--- 10.196.28.254 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1002ms
rtt min/avg/max/mdev = 0.907/1.108/1.310/0.204 ms
[root@blog01 ~]# ping -W1 -c2  10.192.28.254
PING 10.192.28.254 (10.192.28.254) 56(84) bytes of data.
64 bytes from 10.192.28.254: icmp_seq=1 ttl=249 time=2.63 ms
64 bytes from 10.192.28.254: icmp_seq=2 ttl=249 time=2.78 ms
--- 10.192.28.254 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1004ms
rtt min/avg/max/mdev = 2.635/2.709/2.784/0.090 ms


配置完成!

你可能感兴趣的:(RHEL,VLAN,网络配置)