linux启用网卡vlan,LINUX (UBUNTU) 双网卡多VLAN的Server 配置

=========================================

PPPoE Server 配置

=======================================

环境搭建:

eth2

设为WAN侧网卡,自动获取,如:IP:4.4.4.10/MASK:255.255.255.0/GW:4.4.4.1/DNS:202.96.209.5,210.22.70.3

eth3

设为LAN侧网卡,手动配置为: IP:11:11:11:1/MASK:255.255.255.0/GW:4.4.4.1/DNS:202.96.209.5,210.22.70.3

开始配置:

sudo apt-get install vlan

modprobe 8021q

vconfig add eth3 35

vconfig add eth3 42

vconfig add eth3 6

echo "1" > /proc/sys/net/ipv4/ip_forward

iptables -t nat -A POSTROUTING -o eth2 -j MASQUERADE

iptables -t nat -A POSTROUTING -s 6.6.6.0/24 -o eth2 -j SNAT --to 4.4.4.106

iptables -t nat -A POSTROUTING -s 11.11.11.0/24 -o eth2 -j SNAT --to 4.4.4.111

iptables -t nat -A POSTROUTING -s 42.42.42.0/24 -o eth2 -j SNAT --to 4.4.4.142

iptables -t nat -A POSTROUTING -s 35.35.35.0/24 -o eth2 -j SNAT --to 4.4.4.135

killall pppoe-server

pppoe-server -I eth3 -L 11.11.11.1 -R 11.11.11.20 -N 10

ifconfig eth3.6 down

ifconfig eth3.6 6.6.6.1 broadcast 6.6.6.255 netmask 255.255.255.0 up

pppoe-server -I eth3.6 -L 6.6.6.1 -R 6.6.6.2 -N 10

ifconfig eth3.42 down

ifconfig eth3.42 42.42.42.1 broadcast 42.42.42.255 netmask 255.255.255.0 up

pppoe-server -I eth3.42 -L 42.42.42.1 -R 45.42.42.2 -N 10

ifconfig eth3.35 down

ifconfig eth3.35 35.35.35.1 broadcast 35.35.35.255 netmask 255.255.255.0 up

pppoe-server -I eth3.35 -L 35.35.35.1 -R 35.35.35.2 -N 10

=================================================

DHCP Server 配置

================================================

环境搭建:

eth2

设为WAN侧网卡,自动获取,如:IP:4.4.4.10/MASK:255.255.255.0/GW:4.4.4.1/DNS:202.96.209.5,210.22.70.3

eth3

设为LAN侧网卡,手动配置为: IP:11:11:11:1/MASK:255.255.255.0/GW:4.4.4.1/DNS:202.96.209.5,210.22.70.3

ifconfig eth3 down

ifconfig eth3 11.11.11.1 broadcast 11.11.11.255 netmask 255.255.255.0 up

DHCP server安装

1. 安装dhcp3-server

sudo apt-get install dhcp3-server

2. 备份系统原有的配置文件

sudo cp /etc/dhcp3/dhcpd.conf /etc/dhcp3/dhcpd.conf.original

3. 配置config文件,打开/etc/dhcp3/dhcpd.conf,在其中添加或修改以下几句

ddns-update-style none; #定义所支持的DNS动态更新类型(必选)默认为none

default-lease-time 36000; #租约期限,单位为秒

max-lease-time 72000;#最大租约期限

4. 执行DHCP server

/etc/init.d/dhcp3-server restart

#设置IP作用域,格式为subnet 子网ID netmask 子网掩码{}

subnet 11.11.11.0 netmask 255.255.255.0{

range 11.11.11.100 11.11.11.200;   #IP地址池

option routers 11.11.11.1;         #指定默认网关

option subnet-mask 255.255.255.0;   #指定子网掩码

option broadcast-address 11.11.11.255; #指定广播地址

option domain-name-servers 202.96.209.5,210.22.70.3; #指定DNS服务器

default-lease-time 6000;

max-lease-time 72000;

}

subnet 7.7.7.0 netmask 255.255.255.0{

range 7.7.7.100 7.7.7.200;   #IP地址池

option routers 7.7.7.1;         #指定默认网关

option subnet-mask 255.255.255.0;   #指定子网掩码

option broadcast-address 7.7.7.255; #指定广播地址

option domain-name-servers 202.96.209.5,210.22.70.3; #指定DNS服务器

default-lease-time 6000;

max-lease-time 72000;

}

subnet 8.8.8.0 netmask 255.255.255.0{

range 8.8.8.100 8.8.8.200;   #IP地址池

option routers 8.8.8.1;         #指定默认网关

option subnet-mask 255.255.255.0;   #指定子网掩码

option broadcast-address 8.8.8.255; #指定广播地址

option domain-name-servers 202.96.209.5,210.22.70.3; #指定DNS服务器

default-lease-time 6000;

max-lease-time 72000;

}

subnet 10.10.10.0 netmask 255.255.255.0{

range 10.10.10.100 10.10.10.200;   #IP地址池

option routers 10.10.10.1;         #指定默认网关

option subnet-mask 255.255.255.0;   #指定子网掩码

option broadcast-address 10.10.10.255; #指定广播地址

option domain-name-servers 202.96.209.5,210.22.70.3; #指定DNS服务器

default-lease-time 6000;

max-lease-time 72000;

}

开始配置:

sudo apt-get install vlan

modprobe 8021q

vconfig add eth3 7

vconfig add eth3 8

vconfig add eth3 10

echo "1" > /proc/sys/net/ipv4/ip_forward

iptables -t nat -A POSTROUTING -o eth2 -j MASQUERADE

iptables -t nat -A POSTROUTING -s 7.7.7.0/24 -o eth2 -j SNAT --to 4.4.4.107

iptables -t nat -A POSTROUTING -s 8.8.8.0/24 -o eth2 -j SNAT --to 4.4.4.108

iptables -t nat -A POSTROUTING -s 10.10.10.0/24 -o eth2 -j SNAT --to 4.4.4.110

ifconfig eth3.7 down

ifconfig eth3.7 7.7.7.1 broadcast 7.7.7.255 netmask 255.255.255.0 up

ifconfig eth3.8 down

ifconfig eth3.8 8.8.8.1 broadcast 8.8.8.255 netmask 255.255.255.0 up

ifconfig eth3.10 down

ifconfig eth3.10 10.10.10.1 broadcast 10.10.10.255 netmask 255.255.255.0 up

/etc/init.d/dhcp3-server restart

阅读(5174) | 评论(0) | 转发(4) |

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值