ubuntu 配置静态ip && git clone ssh port 22问题 && git 全局代理

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/starry_skyWW/article/details/76417298

一)

1. 找到文件并作如下修改:

sudo vim /etc/network/interfaces

修改如下部分:

auto eth0
iface eth0 inet static
address 192.168.0.117
gateway 192.168.0.1 #这个地址你要确认下 网关是不是这个地址
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255

注意ifconfig查看本地的网卡名字(不一定是eth0)

2. 修改dns解析

因为以前是dhcp解析,所以会自动分配dns服务器地址

而一旦设置为静态ip后就没有自动获取到的dns服务器了

要自己设置一个

sudo vim /etc/resolv.conf

写上一个公网的DNS

nameserver 202.96.128.86

直接写本地的127.0.0.1 也可以

3 完全修改

vim /etc/resolvconf/resolv.conf.d/base

永久修改

4. 重启网卡:

sudo /etc/init.d/network restart

二)

出现如下问题时:

ssh: connect to host github.com port 22: Connection refused
fatal: The remote end hung up unexpectedly

Add the following to your ./.ssh/config:

host github.com
    hostname ssh.github.com
    port 443
三)git全局代理

通过在终端输入

export all_proxy=socks://addr:port

export ALL_PROXY=socks://addr:port

然后终端上执行的git所有操作都会走代理

取消代理:

unset all__proxy

unset ALL_PROXY

查看当前代理:

cd /etc/

env grep | proxy

更多方式可以查看

https://segmentfault.com/q/1010000000118837

猜你喜欢

转载自blog.csdn.net/starry_skyWW/article/details/76417298