Κάποιες χρήσιμες εντολές για το σετάρισμα κάρτας δικτύου (π.χ. eth0) σε περιβάλλον linux.
- View: ifconfig -a (ή eth0)
- Assign ip address to interface: ifconfig eth0 192.168.1.102 netmask 255.255.255.0 up
ifconfig’s syntax and command layout:
ifconfig <interface> <ip_address> [ netmask <netmask> ]
Where:
<interface> = the network interface you want to configure (eth0, eth1… and so on)
<ip_address> = the ip address you want to assign to the interface (example: 1.1.1.1)
<netmask> = the subnet mask of your assigned network (example: 255.255.255.0)
- Gateway: route add default gw 1.1.2.2 eth0
route’s syntax and command layout:
route [add default gw] <ip_address> <interface>
Where:
[add default gw] = Sets up a route to add a default gateway for a network interface
<ip_address> = the ip address of the network gateway
<interface> = the network interface you are setting up a route for on your machine
- Nameservers (/etc/resolv.conf)
Κάνουμε edit το αρχείο /etc/resolv.conf με την εντολή e3 /etc/resolv.conf ή vim /etc/resolv.conf
Once you have the file open for editing, you will need to type this line for EACH DNS server address you want to enter:
nameserver <ip_address>
So, we would need to type this into the /etc/resolv.conf file:
nameserver 3.3.3.1
nameserver 3.3.3.2
Ubuntu / Debian IP Configuration Files:
File: /etc/network/interfaces
Static IP example:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 208.88.34.106
netmask 255.255.255.248
broadcast 208.88.34.111
network 208.88.34.104
gateway 208.88.34.110
Dynamic IP (DHCP) example:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
auto eth1
iface eth1 inet dhcp
auto eth2
iface eth2 inet dhcp
auto ath0
iface ath0 inet dhcp
auto wlan0
iface wlan0 inet dhcp
Interfaces:
* lo: Loopback interface (network within your system without slowing down for the real ethernet based network)
* eth0: First ethernet interface card
* wlan0: First wireless network interface
Also see “man interfaces”
How do I restart Linux network service?
E-mail this to a friend
Printable version
Last updated: Dec/2/2007by Vivek Gite · 14 comments
RedHat Linux command to reload or restart network (login as root user):
# service network restart
OR
# /etc/init.d/network restart
To start Linux network service:
# service network start
To stop Linux network service:
# service network stop
Debian Linux command to reload or restart network:
# /etc/init.d/networking restart
To start Linux network service:
# /etc/init.d/networking start
To stop Linux network service:
# /etc/init.d/networking stop
Ubuntu Linux user use sudo command with above Debian Linux command:
# sudo /etc/init.d/networking restart
To start Linux network service:
# sudo /etc/init.d/networking start
To stop Linux network service:
# sudo /etc/init.d/networking stop