修改网卡,网关ip,校园网

13 篇文章 0 订阅
5 篇文章 0 订阅

1、使用校园网的脚本程序:

环境:树莓派,debian10,
修改文件:wpa_supplicant.conf
/etc/wpa_supplicant/目录下的:wpa_supplicant.conf

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=CN

network={
        ssid="BUPT-mobile"
        key_mgmt=WPA-EAP
        pairwise=CCMP TKIP
        group=CCMP TKIP
        eap=PEAP TTLS
        scan_ssid=1
        identity="2019180100"  # 学号
        password="QWEasd321~"  # 密码
        phase1="PEAP"
        phase2="MSCHAPV2"
        priority=1
        proactive_key_caching=1
}

之后使用如下命令获取动态ip:

sudo killall wpa_supplicant 
sudo wpa_supplicant -dd -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf

另开一个窗口:

ifconfig  #查看网卡wlan0 的ip和子网掩码,然后计算网关

在这里插入图片描述

2、固定wlan0通过wifi获取来的ip

修改文件:/etc/dhcpcd.conf

# Example static IP configuration:
interface eth0
static ip_address=192.168.0.2/24
static ip6_address=fd51:42f8:caae:d92e::ff/64
#static routers=192.168.0.1  # 注释掉这个集群局域网的网关
static domain_name_servers=192.168.0.1 8.8.8.8 fd51:42f8:caae:d92e::1


interface wlan0
static ip_address=10.28.210.35/17
static routers=10.28.128.1  # 使用这个网关
static domain_name_servers=10.28.128.1 8.8.8.8


设置树莓派网关绑定的网卡:
eht0 -->wlan0

# Example static IP configuration:
interface eth0
static ip_address=192.168.0.47/24
static ip6_address=fd51:42f8:caae:d92e::ff/64
#static routers=192.168.0.1
static domain_name_servers=192.168.0.1 8.8.8.8 fd51:42f8:caae:d92e::1



interface wlan0
static ip_address=10.28.165.172/17
static routers=10.28.128.1
static domain_name_servers=10.28.128.1 8.8.8.8



10.28.165.172/17  子网掩码:255.255.128.1,165比128大?
wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.28.210.35  netmask 255.255.128.0  broadcast 10.28.255.255
        inet6 2001:da8:215:3c02::b688  prefixlen 128  scopeid 0x0<global>
        inet6 fe80::c628:92be:6836:3eea  prefixlen 64  scopeid 0x20<link>
        ether dc:a6:32:94:02:c3  txqueuelen 1000  (Ethernet)
        RX packets 169  bytes 17735 (17.3 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 445  bytes 61708 (60.2 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值