Take eth0 as an example
**1.**Configure the network card by DHCP
Edit the file: /etc/network/interfaces:
sudo vi /etc/network/interfaces
And replace the line about eth0 with the following line:
auto eth0
iface eth0 inet dhcp
Use the following command to make the network settings effective:
sudo /etc/init.d/networking restart
Of course, you can also enter the following command directly under the command line to get the address
sudo dhclient eth0
2. Configure a static IP address for the network card
Edit the file: /etc/network/interfaces:
sudo vi /etc/network/interfaces
And replace the line about eth0 with the following line:
auto eth0
iface eth0 inet static
address 192.168.1.98
gateway 192.168.1.1
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
Use the following command to make the network settings effective:
sudo /etc/init.d/networking restart
**Note: ** After it takes effect, you need to configure DNS before you can go online (step 5)
3. Set the second IP address (virtual IP address)
Edit the file /etc/network/interfaces:
sudo vi /etc/network/interfaces
Add the following line to the file:
auto eth0:1
iface eth0:1 inet static
address 192.168.1.60
netmask 255.255.255.0
network x.x.x.x
broadcast x.x.x.x
gateway x.x.x.x
Fill in all the information such as address, netmask, network, broadcast and gateways according to your situation.
Use the following command to make the network settings effective:
sudo /etc/init.d/networking restart
4. Set the host name (hostname)
Use the following command to view the host name of the current host:
sudo /bin/hostname
Use the following command to set the host name of the current host:
sudo /bin/hostname newname
When the system starts, it will read the name of the host from /etc/hostname.
For more information about setting the host name, please visit here
5. Configure DNS
First, you can add some host names and IP addresses corresponding to these host names in /etc/hosts
To access the DNS server for query, you need to set up the /etc/resolv.conf file.
For example: Suppose the IP address of the DNS server is 192.168.1.1
Edit file: /etc/hosts
sudo vi /etc/hosts
The edit content is as follows:
nameserver 192.168.1.1
Or, edit /etc/resolv.conf and add the following content:
sudo vi /etc/resolv.conf
Use the following command to make the network settings effective:
sudo /etc/init.d/networking restart
Ubuntu turn off the firewall
root@ubuntu:/home/homer# ufw status // View status
Status: inactive
root@ubuntu:/home/homer# ufw enable // Turn on the firewall
Firewall is active and enabled on system startup
root@ubuntu:/home/homer# ufw status
Status: active
root@ubuntu:/home/homer# ufw disable // Turn off the firewall
Firewall stopped and disabled on system startup
root@ubuntu:/home/homer# ufw status
Status: inactive
1、 Turn off ubuntu's firewall
ufw disable
2、 Uninstalled iptables
apt-get remove iptables
3、 The rest of the commands to turn off the firewall in ubuntu
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
iptables -F
CentOS turn off firewall
/etc/init.d/iptables stop
[ root@homeros logs]# /etc/init.d/iptables status // View firewall status
iptables: Firewall is not running.
[ root@homeros logs]# /etc/init.d/iptables start // Turn on the firewall
iptables: Applying firewall rules: [ OK ]
[ root@homeros logs]# /etc/init.d/iptables status
Table: filter
Chain INPUT (policy ACCEPT)
num target prot opt source destination
1 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
2 ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0
3 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
4 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22
5 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
Chain FORWARD (policy ACCEPT)
num target prot opt source destination
1 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
Chain OUTPUT (policy ACCEPT)
num target prot opt source destination
[ root@homeros logs]# /etc/init.d/iptables stop // Turn off the firewall
iptables: Flushing firewall rules: [ OK ]
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Unloading modules: [ OK ]
[ root@homeros logs]# /etc/init.d/iptables status
iptables: Firewall is not running.
Recommended reference:
Original English: http://www.ubuntugeek.com/ubuntu-networking-configuration-using-command-line.html
Centos permanently turn off the firewall method
Recommended Posts