iface eth0 inet static # static, as opposed to dhcp... replace eth0 with desired interface
address xxx.xxx.xxx.xxx # ip address you want assigned to this computer
netmask xxx.xxx.xxx.xxx # subnet mask
network xxx.xxx.xxx.xxx # optional
broadcast xxx.xxx.xxx.xxx # optional
gateway xxx.xxx.xxx.xxx # gateway (usually router/firewall) ip address
Once you have done this, restart your network interfaces with
sudo /etc/init.d/networking restart
The gateway can also be specified on the command line if it's not in the interfaces file: sudo route add default gw xxx.xxx.xxx.xxx The command netstat -nr can show the routes, including gateways, that the kernel is currently using.
To explicitly release a dhcp connection, do something like dhclient -r eth0
If your computer and network is set up correctly, you should now be able to ping your gateway and access sites on the internet by IP address. However, in order to access sites by name you need the help of DNS. Add entries to the /etc/resolv.conf file as a superuser in this format (you can have as many as you want):
nameserver xxx.xxx.xxx.xxx
Now, if you point your browser to a domain name like www.yahoo.com, you should be able to get there. Welcome to t3h 1nt3rw3b. You can also do all the above by accessing the System->Administration->Network menu.
Links:
- HOWTO Basic Network Troubleshooting An Ubuntu Forums post about basic networking... check out the great script towards the bottom of the first page
- HOWTO Ubuntu Linux convert DHCP network to static IP Explains how to do this, and much more, on the command line
- Ubuntu Networking for Basic and Advanced Users A visual guide to using the Ubuntu Networking GUI
- SearchNetworking.com A good, general-purpose networking resource
For switching from one interface configuration to another (assuming eth0 and correct /etc/network/interfaces):
- sudo ifdown eth0
- edit /etc/network/interfaces
- sudo ifup eth0
No comments:
Post a Comment