ubuntu 共享上网

1.先网卡设置

sudo vim /etc/network/interfaces

 

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

 

auto wlan1
iface wlan1 inet static
address 192.168.0.254
netmask 255.255.255.0

 

auto dsl-provider
iface dsl-provider inet ppp
pre-up /sbin/ifconfig eth1 up # line maintained by pppoeconf
provider dsl-provider

auto br0
iface br0 inet manual

auto eth1
iface eth1 inet manual

 

第二安装设置dhcp服务

sudo apt-get install dhcp3-server

 

sudo vim /etc/dhcp/dhcpd.conf

subnet 192.168.0.0 netmask 255.255.255.0 {
  range 192.168.0.100 192.168.0.200;
  option routers 192.168.0.254;
  option domain-name-servers 192.168.0.254,202.106.0.20,8.8.8.8;
}

设置dhcp分配的网卡 

sudo vim /etc/default/isc-dhcp-server

INTERFACES="wlan1"

 

设置启动 /etc/rc.local

############ adsl forword ######
sudo /sbin/iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o ppp0 -j MASQUERADE
sudo iptables -A FORWARD -s 192.168.0.0/24 -o ppp0 -j ACCEPT
sudo iptables -A FORWARD -d 192.168.0.0/24 -m state --state ESTABLISHED,RELATED -i ppp0 -j ACCEPT
############# wlan2 ssh_ctrl#####
sh /home/star/setting/runwlan2.sh

 

runwlan2.sh

 

#/bin/bash!


sudo hostapd /home/star/setting/hostapd/wlan2.conf

 

wlan2.conf

 

interface=wlan2
driver=nl80211
ssid=xxxxxxx
hw_mode=g
channel=1

wpa=2
wpa_key_mgmt=WPA-PSK
wpa_pairwise=CCMP
wpa_passphrase=xxxxxxx
 

 

在安装之前最好先用无线连接一下看是否可以无

 

以上局域网网关设置完成下面来设置pppoe

 

先安装pppoeconf

apt-get install pppoeconf

 

别忘了启动ipv4 转发

sudo vim /etc/sysctl.conf

把下面注视去了

#net.ipv4.ip_forward=1

 

你可能感兴趣的:(ubuntu)