1

While I order a hp server for my Ubuntu server, I am currently temporarily using my laptop as a server instead. I installed Ubuntu 13.10 and other programs like Webmin, etc, etc while being connected to my router through wi-fi. Additionally, through a wi-fi connection, I have hosted numerous websites, game servers and an ftp server.

The issue is that when I try to connect the laptop to the same router through ethernet, the local ip changes. This means that no services, such as Webmin, work locally or publicly. When I go back to using wi-fi, the issue is solved, however, because the wi-fi connection cannot maintain the traffic to and from the server, I need to use ethernet connection to keep up with the demand.

I have portforwarded the ports I use from my wi-fi local ip to my ethernet local ip but I have no luck so far since the problem is on the local side, not from local to public.

My question is, how can I configure my services to the new IP?

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
#NetworkManager#auto wlan0
#NetworkManager#iface wlan0 inet dhcp
#NetworkManager#        wpa-ssid routername
#NetworkManager#        wpa-psk  routerpassword

The result of ip ad is:

$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
    link/ether 00:1c:23:3a:24:db brd ff:ff:ff:ff:ff:ff
    inet 192.168.***.***/24 brd 192.168.1.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet 192.168.***.***/24 brd 192.168.1.255 scope global secondary eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::21c:23ff:fe3a:24db/64 scope link
       valid_lft forever preferred_lft forever
3: wlan0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN qlen 1000
    link/ether 00:19:d2:03:0c:f8 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::219:d2ff:fe03:cf8/64 scope link
       valid_lft forever preferred_lft forever

$ ip r
default via 192.168.***.*** dev eth0  proto static
192.168.***.***/24 dev eth0  proto kernel  scope link  src 192.168.***.***  metric 1

$ sudo ethtool eth0
Settings for eth0:
        Supported ports: [ TP ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Half 1000baseT/Full
        Supported pause frame use: No
        Supports auto-negotiation: Yes
        Advertised link modes:  10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Half 1000baseT/Full
        Advertised pause frame use: Symmetric
        Advertised auto-negotiation: Yes
        Link partner advertised link modes:  10baseT/Half 10baseT/Full
                                             100baseT/Half 100baseT/Full
        Link partner advertised pause frame use: Symmetric Receive-only
        Link partner advertised auto-negotiation: Yes
        Speed: 100Mb/s
        Duplex: Full
        Port: Twisted Pair
        PHYAD: 1
        Transceiver: internal
        Auto-negotiation: on
        MDI-X: off
        Supports Wake-on: g
        Wake-on: g
        Current message level: 0x000000ff (255)
                               drv probe link timer ifdown ifup rx_err tx_err
        Link detected: yes
  • Why do I see #NetworkManager - that is not default on a server install - or are you using a GUI? – guntbert Feb 22 '14 at 17:18
  • Yes, I installed the unity package so that I can use the internet when I need to access webmin, phpmyadmin, etc from the server itself without having to use a different computer. – user251124 Feb 22 '14 at 17:19
3

Assuming you need a CLI method:

Use your favourite editor to edit /etc/network/interfaces with root permissions.

sudo nano /etc/network/interfaces

(lines starting with # are just comments, they are not effective, you can leave them as they are, you also keep the lines with lo as they are)

# The loopback network interface
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 192.168.0.100           # use the address you really want
netmask 255.255.255.0
gateway 192.168.0.254           # use the address of your router

You will have to restart the interface sudo ifdown eth0 (may throw an error, ignore that), then sudo ifup etho - you can check if the settings are effective with ip ad.

For a detailed outline see

Ubuntu Server Guide - chapter networking

  • Hi, my interfaces file has a different layout than the one shown in your comment. Mine looks like this: # This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo iface lo inet loopback # The primary network interface #NetworkManager#auto wlan0 #NetworkManager#iface wlan0 inet dhcp #NetworkManager# wpa-ssid routernamehere #NetworkManager# wpa-psk routerpasswordhere – user251124 Feb 22 '14 at 15:52
  • @user251124 those are only comments, ignore them) – guntbert Feb 22 '14 at 15:57
  • No luck so far. I replaced the auto lo etcetcetc with what you suggested, however, it still doesn't work. Just to clarift, the address I really want is the server's local ip and "the adderss of your router" is the local ip of the router or the wi-fi ip? – user251124 Feb 22 '14 at 16:01
  • @user251124 see my changed answer please. – guntbert Feb 22 '14 at 16:06
  • @guntbert This would work fine if the address is within the LAN address range allocated in the router. It would be far more effective to use a DHCP reservation in the router via MAC address for the Ethernet connection and run the port-forwarding to that LAN IP address. – douggro Feb 22 '14 at 16:13
0

There is a special loopback address (127.0.0.1) that always points to your own computer. If you have Webmin (I'm not familiar with this program) listening on port 8080 on your computer, you can just go to 127.0.0.1:8080.

Edit: My bad. I was under the impression that you wanted to access the services from your own computer.

  • He wants access from outside his LAN. – guntbert Feb 22 '14 at 15:38
  • Ah, ok. I thought he meant from his own computer. But wouldn't the public IP address stay the same while the private IP address changes (a change in router port-forwarding, then)? – saiarcot895 Feb 22 '14 at 15:40
  • Yes, for the public address, but no for the forwarding (done on the router). – guntbert Feb 22 '14 at 15:47
  • @saiarcot895 Just FYI - Webmin listens on port 10000 https://localhost:10000 – douggro Feb 22 '14 at 16:21
0

With Ubuntu 18.04 LTS, the infrastructure to set Local IP has shifted to Netplan

Go to this link for details how to configure IP Address with Netplan on Ubuntu 18.04!

Briefly, you need to modify the relevant netplan network configuration file within /etc/netplan/ directory as follows: network: ethernets: enp2s0: #Your network interface addresses: - 192.168.0.100/24 #Change to your required IP dhcp4: false gateway4: 192.168.1.1 nameservers: addresses: - 192.168.1.1 search: [] version: 2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.