College on December 29, 2017 to purchase a deep learning server, operating system for Ubuntu14.04server, the configuration process encountered a variety of pits, is now on the server Terminal command line network configuration process experience to share the following:
1. Request a fixed IP address
Start to try to connect a cable from the teaching building router to the server, set up to access the external network, but IP address access can not cover the entire campus intranet, only the computer connected to this router can be IP access. This is because the router is assigned a small local IP 192.168.1.1, need to hold a valid document and server MAC address (through Ifconfig can be viewed) to the Network Management center to apply for the campus intranet fixed IP address.
2. Set the fixed IP address
2.1 Setting the IP address
Vim/etc/network/interfaces
Make the following changes:
# The Loopback network interface
Auto Lo
Iface Lo inet Loopback
Auto Etho
Iface Etho inet Static
Address 202.204.110.243
Netmask 255.255.255.0
Gateway 202.204.110.254
2.2 Setting up DNS
Vim/etc/resolvconf/resolv.conf.d/base
The following changes are made:
NameServer 202.204.105.1
NameServer 202.204.105.5
2.3 Refreshing the configuration file
Resolvconf-u
2.4 Restarting the network
/etc/init.d/networking restart
3. Log in to the campus gateway account to access the extranet
At this point, in the campus LAN can access the server through the Ssh+ip address, but download the external network resources need to login campus gateway. Access to relevant information, there are two main ways to log into the campus gateway account password, one, shell script, the second, Python script; Here I am using the Python script command line to log in to the campus gateway, mainly including two procedures for login and logoff:
A. login source (connect.py)
ImportUrllib2ImportUrllibclassLoginer ():def __init__(self, username, password): Self.loginurl='http://202.204.105.195:803/srun_portal_pc.php?ac_id=1&' #单引号内替换为校园网登录网络地址self.username=username Self.password=Password Self.openner=Urllib2.build_opener ()defLogin (self): PostData= { 'username': Self.username,'Password': Self.password,'Action':'Login', 'ac_id':'1', 'user_ip':"', 'nas_ip':"', 'User_mac':"', 'URL':"'} postdata=Urllib.urlencode (postdata) myrequest= Urllib2. Request (Url=self.loginurl, Data=postdata) Result=Self.openner.open (myrequest). Read () Resstr=STR (RESULT) IND=resstr.find ('Font-weight:bold;color:orange') if(Ind!=-1): Print 'Connected successfully' Else: Print 'Connected faild!! Maybe your username or password is wrong!'defMain (): Username=raw_input ('Enter your username:') Password=raw_input ('Enter your password:') file=open ('Temp_username.dat','W') File.write (username) file.close () L=Loginer (Username,password) l.login ()if __name__=='__main__': Main ()Print ' Done'
B. Exit Source (logout.py)
ImportUrllib2ImportUrllibclassLoginer ():def __init__(self, username, password): Self.loginurl='http://202.204.105.195:803/srun_portal_pc.php?ac_id=1&' #单引号内替换为校园网登录网络地址self.username=username Self.password=Password Self.openner=Urllib2.build_opener ()defLogin (self): PostData= { 'username': Self.username,'Info':"', 'Action':'Auto_logout', 'usr_ip':'202.204.105.195'} postdata=Urllib.urlencode (postdata) myrequest= Urllib2. Request (Url=self.loginurl, Data=postdata)if(Str (Self.openner.open (myrequest). Read ()). Find ('Font-weight:bold;color:orange')!=-1): Print 'Logout successfully' defMain (): File=open ('Temp_username.dat','R') Username=File.readline ()Printusername L= Loginer (username,"') L.login ()if __name__=='__main__': Main ()Print ' Done'
Copy the source code and save it to connet.py and logout.py two files respectively. Then copy to the server to run: (note replacing the directory where you own the files)
SCP connect.py [Email protected]:network/connet.py
SCP logout.py [Email protected]:network/logout.py
4. Network Testing
After completing the above steps, you can ping www.baidu.com to test for a successful configuration.
China University of Geology (Beijing) Linux Deep Learning server Terminal Campus Gateway account password Login problem--take ubuntu14.04server version as an example