Skip to content

Commit

Permalink
small format fix6
Browse files Browse the repository at this point in the history
  • Loading branch information
IlirEdis committed Jul 3, 2023
1 parent 98b5ce5 commit 81671eb
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions additional-ip-in-linux.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ you want to add the secondary IP of `192.168.1.2` as follows
**add** the following 2 lines at the end of your config:

```bash filename="/etc/network/interfaces"
auto eth0
iface eth0 inet static
address 192.168.1.1
netmask 255.255.255.0
gateway 192.168.1.254

post-up ip a a 192.168.1.2/24 dev eth0
pre-down ip a d 192.168.1.2/24 dev eth0
auto eth0
iface eth0 inet static
address 192.168.1.1
netmask 255.255.255.0
gateway 192.168.1.254

post-up ip a a 192.168.1.2/24 dev eth0
pre-down ip a d 192.168.1.2/24 dev eth0
```

After editing, run the command `sudo ifup eth0:0` to activate the new interface.
Expand All @@ -51,14 +51,20 @@ cp ifcfg-eth0 ifcfg-eth0:0
ls -l | grep ifcfg-eth -rw-r--r-- 1 root root 119 Jan 11 19:16 ifcfg-eth0 -rw-r--r-- 1 root root 119 Feb 24 08:53 ifcfg-eth0:0
```

**edit** the file ifcfg-eth0:0, and use the following configuration for this virtual adapter.
**edit** the file `ifcfg-eth0:0`, and use the following configuration for this virtual adapter.

static IP
remove hardware address (MAC)
configure the IP address and netmask
rename the device from eth0 to eth0:0
rename the device from `eth0` to `eth0:0`

DEVICE=eth0:0 BOOTPROTO=static ONBOOT=yes IPADDR=192.168.1.2 NETMASK=255.255.255.0
```bash
DEVICE=eth0:0
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.1.2
NETMASK=255.255.255.0
```

After editing you will have to restart the networking service
with the command **service network restart**
with the command `service network restart`

0 comments on commit 81671eb

Please sign in to comment.