Centos7配置PPPOE+vlan多拨

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

非阿里云ECS用户会出现 Couldn’t resolve host ‘mirrors.cloud.aliyuncs.com’ 信息,不影响使用,可以修改配置

sed -i -e ‘/mirrors.cloud.aliyuncs.com/d’ -e ‘/mirrors.aliyuncs.com/d’ /etc/yum.repos.d/CentOS-Base.repo

yum makecache
yum repolist

yum -y install epel-release
yum install vconfig -y

modprobe 8021q
lsmod | grep 8021q
ip addr
vconfig add ens192 101
vconfig add ens192 102
cat /proc/net/vlan/config

cd /etc/sysconfig/network-scripts/
vi ifcfg-ens192.101

TYPE=vlan
PHYSDEV=ens192
VLAN=yes
VLAN_ID=101
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
NAME=ens192.101
DEVICE=ens192.101
ONBOOT=yes

cp ifcfg-ens192.101 ifcfg-ens192.102
vi ifcfg-ens192.102

DEVICE=ens192.102
BOOTPROTO=none
ONBOOT=yes
VLAN=yes

systemctl restart network

ip addr

yum install rp-pppoe -y

pppoe-setup

Welcome to the PPPoE client setup. First, I will run some checks on
your system to make sure the PPPoE client is installed properly…

LOGIN NAME

Enter your Login Name (default root): 1

INTERFACE

Enter the Ethernet interface connected to the PPPoE modem
For Solaris, this is likely to be something like /dev/hme0.
For Linux, it will be ethX, where ‘X’ is a number.
(default eth0): ens192.101

Do you want the link to come up on demand, or stay up continuously?
If you want it to come up on demand, enter the idle time in seconds
after which the link should be dropped. If you want the link to
stay up permanently, enter ‘no’ (two letters, lower-case.)
NOTE: Demand-activated links do not interact well with dynamic IP
addresses. You may have some problems with demand-activated links.
Enter the demand value (default no): no

DNS

Please enter the IP address of your ISP’s primary DNS server.
If your ISP claims that ‘the server will provide dynamic DNS addresses’,
enter ‘server’ (all lower-case) here.
If you just press enter, I will assume you know what you are
doing and not modify your DNS setup.
Enter the DNS information here:

PASSWORD

Please enter your Password:
Please re-enter your Password:

USERCTRL

Please enter ‘yes’ (three letters, lower-case.) if you want to allow
normal user to start or stop DSL connection (default yes): yes

FIREWALLING

Please choose the firewall rules to use. Note that these rules are
very basic. You are strongly encouraged to use a more sophisticated
firewall setup; however, these will provide basic security. If you
are running any servers on your machine, you must choose ‘NONE’ and
set up firewalling yourself. Otherwise, the firewall rules will deny
access to all standard servers like Web, e-mail, ftp, etc. If you
are using SSH, the rules will block outgoing SSH connections which
allocate a privileged source port.

The firewall choices are:
0 - NONE: This script will not set any firewall rules. You are responsible
for ensuring the security of your machine. You are STRONGLY
recommended to use some kind of firewall rules.
1 - STANDALONE: Appropriate for a basic stand-alone web-surfing workstation
2 - MASQUERADE: Appropriate for a machine acting as an Internet gateway
for a LAN
Choose a type of firewall (0-2): 0

Start this connection at boot time

Do you want to start this connection at boot time?
Please enter no or yes (default no):yes

** Summary of what you entered **

Ethernet Interface: ens192.101
User name: 1
Activate-on-demand: No
DNS: Do not adjust
Firewalling: NONE
User Control: yes
Accept these settings and adjust configuration files (y/n)? y
Adjusting /etc/sysconfig/network-scripts/ifcfg-ppp0
Adjusting /etc/ppp/chap-secrets and /etc/ppp/pap-secrets
(But first backing it up to /etc/ppp/chap-secrets.bak)
(But first backing it up to /etc/ppp/pap-secrets.bak)

cat /etc/sysconfig/network-scripts/ifcfg-ppp0
cat /etc/ppp/chap-secrets

tail -f /var/log/messages 查看 PPPoe 最新拨号日志内容

配置多线路:

  方法一:

   (1)直接拷贝

cp /etc/sysconfig/network-scripts/ifcfg-ppp0 /etc/sysconfig/network-scripts/ifcfg-ppp1

(2)修改其中的ppp0为ppp1,

修改PIDFILE=/var/run/pppoe-adsl.pid 为PIDFILE=/var/run/pppoe-adsl1.pid

修改采用的新接线路的网卡,例如:改ETH=eth1 为ETH=eth2

(3)增加新线路的帐号和密码. 帐号密码一般是保存在/etc/ppp/chap-secrets 和pap-secrets

我们只需要在最后增加新的用户名2和密码2即可.

/etc/ppp/chap-secrets文件一般是这样的:

Secrets for authentication using CHAP

client serversecret IP addresses

“用户名1” * “密码1”

“用户名2” * “密码2”

“用户名n” * “密码n”

  方法二:

   重复执行pppoe-setup,选择不同的网卡和对应的账号密码配置。配置完成后,修改PIDFILE,默认生成的PIDFILE都是相同的,需要用0,1,2...对应区分。

启动脚本

#!/bin/bash
interfaces=(‘ppp0’ ‘ppp1’)
tables=(‘100’ ‘101’)
#set -x
index=0
for interface in ${interfaces[@]}
do
#sleep 60s
echo "date restarting interface $interface …"
/sbin/ifdown $interface
/sbin/ifup $interface
_ip=/sbin/ip addr show $interface | grep peer | awk '{print $2}'
_gateway=/sbin/ip addr show $interface | grep peer | awk '{print $4}' | sed 's/\/32//'
/sbin/ip route flush table ${tables[index]}
/sbin/ip route add default via $_gateway dev $interface src $_ip table ${tables[index]}
/sbin/ip rule show | grep “lookup ${tables[index]}” | awk ‘{print $3}’ | xargs -I{} /sbin/ip rule del from {} table ${tables[index]}
/sbin/ip rule add from $_ip table ${tables[index]}
echo "date route table ${tables[index]}"
/sbin/ip route list table ${tables[index]}
((index+=1))
sleep 5s
done

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Centos7与VSCode的集成环境配置可以参考以下几个步骤: 1. 首先,确保你已经在Centos7上安装了VSCode。可以通过下载安装包或者使用命令行安装来完成这一步骤。 2. 打开VSCode后,点击左侧的扩展图标(四个方块)。在搜索框中输入"Centos7",找到并安装Centos7相关的插件。这些插件可以帮助你在VSCode中进行Centos7开发环境的配置和管理。 3. 接下来,你可以创建一个Centos7的工作区。在VSCode的顶部菜单中选择"文件",然后点击"添加文件夹到工作区"。选择你要添加的Centos7项目所在的文件夹,并点击"添加"。 4. 现在,在工作区中创建一个新的文件,在该文件中编写你的Centos7代码。你可以使用C或C++语言来编写代码。 5. 在VSCode的底部状态栏中,你可以选择编译和运行你的Centos7代码。点击"终端"图标,然后选择"新终端"。在终端中,你可以使用gcc或g++编译你的代码,并运行生成的可执行文件。 6. 如果你需要使用第三方库,比如muduo,你可以在项目的配置文件中添加相应的依赖项。具体的操作可以参考该库的官方文档或者示例代码。 7. 最后,你可以使用VSCode提供的调试功能来调试你的Centos7代码。点击左侧的调试图标(虫子),然后点击"创建一个启动配置"。根据你的项目类型和需求,选择相应的调试配置,并进行相应的设置。 通过以上步骤,你就可以在Centos7上使用VSCode进行开发和调试了。希望对你有帮助!<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [linux+centos7 +vscode+C++11+muduo示例](https://download.csdn.net/download/huangdecai2/11975118)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [Chapter000 GO语言环境搭建(附Windows10+Centos7+Vscode+Goland)](https://download.csdn.net/download/weixin_38710566/14041283)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [华为数据库openGauss2.0安装指南实操篇(CentOS、openEuler篇)](https://download.csdn.net/download/karlch/88226492)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值