Ubuntu无线转有线教程

本来想测试一下有线转无线的,奈何网卡不支持,所以就测试了一回无线转有线的测试!(真无聊,不过也算学习一下linux网桥的知识)

 

ca0gu0@ub:~$ sudo brctl addbr br0 #添加网桥
ca0gu0@ub:~$ brctl show #查看网桥
bridge name    bridge id    STP enabled    interfaces
br0    8000.000000000000    no

 

ca0gu0@ub:~$ sudo brctl addif br0 eth0 #将物理网卡做为虚拟网桥的端口
ca0gu0@ub:~$ sudo brctl delif br0 eth0 #删除网桥接中的物理网卡
ca0gu0@ub:~$ brctl show #查看
bridge name    bridge id    STP enabled    interfaces
br0    8000.00e04c0e681a    no    eth0

 

ca0gu0@ub:~$ sudo ifconfig br0 192.168.20.2 up #开启虚拟接口

ca0gu0@ub:~$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default 
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host 
valid_lft forever preferred_lft forever
2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast master br0 state DOWN group default qlen 1000
link/ether 00:e0:4c:0e:68:1a brd ff:ff:ff:ff:ff:ff
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether c8:e7:d8:fd:9c:78 brd ff:ff:ff:ff:ff:ff
inet 192.168.90.102/24 brd 192.168.90.255 scope global wlan0
valid_lft forever preferred_lft forever
inet6 fe80::cae7:d8ff:fefd:9c78/64 scope link 
valid_lft forever preferred_lft forever
4: br0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
link/ether 00:e0:4c:0e:68:1a brd ff:ff:ff:ff:ff:ff
inet 192.168.20.2/24 brd 192.168.20.255 scope global br0
valid_lft forever preferred_lft fore

  

ca0gu0@ub:~$ sudo apt-get install isc-dhcp-server    # 安装dhcp服务
ca0gu0@ub:~$ sudo vi /etc/default/isc-dhcp-server
INTERFACES="br0"
ca0gu0@ub:~$ sudo cp /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf_bk

ca0gu0@ub:~$ sudo vi /etc/dhcp/dhcpd.conf
subnet 192.168.20.0 netmask 255.255.255.0 {
range 192.168.20.100 192.168.20.200;
option broadcast-address 192.168.2.255;
default-lease-time 600;
max-lease-time 7200;
}

ca0gu0@ub:~$ sudo /etc/init.d/isc-dhcp-server start
* Starting ISC DHCP server dhcpd [ OK ]

 

ca0gu0@ub:~$ ifconfig br0 down #停止虚拟接口
ca0gu0@ub:~$ sudo brctl delbr br0    #删除虚拟接口

 

ca0gu0@ub:~$ ifconfig br0 down #停止虚拟接口
ca0gu0@ub:~$ sudo brctl delbr br0    #删除虚拟接口

 

posted @ 2015-11-08 21:29  ca0guo  阅读(1217)  评论(0编辑  收藏  举报