As stated by @Henrik you can use ifconfig
, but you should use the newer ip
command from the iproute2
package if it is available on your system (it will have the same effect).
ip addr add 10.10.10.134/24 dev <interface>
while <interface>
is the interface where the IP shall be added
To be able to access the internet your routing must be setup correctly, normally those routes are handled by the dhcp-client. If you have a static IP, you have to setup the default-gateway manually.
You can check your routing table with:
ip route show
which will print out the routing table, and should look something like this:
default via 10.0.2.2 dev eth0
10.0.2.0/24 dev eth0 proto kernel scope link src 10.0.2.15
10.1.1.0/24 dev eth1 proto kernel scope link src 10.1.1.2
In most circumstances the internet is accessed using a default-gateway
entry:
default via 10.0.2.2 dev eth0
while default
stands for 0.0.0.0/0
matching any IP address. This will cause all traffic to be routed to the router with IP 10.0.2.2
if the target IP address is not matched by any of the more specific routes as shown in the example above.
To add a default-gateway
enter:
ip route add default via <router-IP> dev <interface>
while
<router-IP>
is the IP address of the next gateway in your network
<interface>
is the interface where you are connected to the network
Now to use the DNS system you may also have to add nameservers
manually.
In linux those are specified in /etc/resolv.conf
, edit the file manually and add your nameservers, as shown in the example below with google nameservers:
nameserver 8.8.8.8
nameserver 8.8.4.4
or by simply entering:
echo "nameserver 8.8.8.8" >> /etc/resolv.conf
echo "nameserver 8.8.4.4" >> /etc/resolv.conf
ifconfig
should be enough, but you can also useip(8)
. – Henrik supports the community Jun 14 '16 at 15:42netstat -rn
? – Chris Davies Jun 14 '16 at 16:25netstan -rn
gives me this – xtremelampshade Jun 14 '16 at 17:47